이 기사에서는 Python으로 간단한 유통 공급망 에이전트 기반 모델을 게시합니다. 에이전트 기반 모델링(ABM으로 약칭)은 이미 다양한 다른 블로그 게시물에서 소개되었습니다. 다음은 시작하는 데 도움이 되는 몇 가지 소개 참조입니다.
그리드 기반 에이전트 기반 시뮬레이션을 위한 Python 패키지도 개발했습니다. 이 패키지는 그리드 기반 ABM을 구현하는 데 사용할 수 있습니다. 에이전트가 위치한 환경을 그리드로 모델링할 수 있음을 의미합니다. 그리드 기반 모델이 필요하지 않은 모델도 이러한 프레임워크로 구현할 수 있습니다. 이제 패키지를 사용할 수 있습니다. 예:
그리드 기반 모델은 거리(예: 사회적 거리와 같은 추상적인 거리 측정 포함)를 정의하는 개념을 제공하므로 유용할 수 있습니다. 또한 에이전트 간의 상호 작용을 모델링하기 위한 표준화된 개념을 제공합니다. 이 게시물에서는 그리드 기반 시뮬레이션 모델을 구현하지 않습니다 . 여기서 논의되는 SCM 분배 모델의 경우에는 필요하지 않기 때문이다.
개념적 공급망 모델
이 간단한 모델에는 두 가지 유형의 논리 흐름이 있습니다. 정보 흐름 및 자료 흐름:
- 소매업체는 유통업체에 주문할 수 있습니다. 유통업체는 제조업체에 주문할 수 있습니다. 이것이 정보 흐름 입니다 .
- 제조업체는 제품을 생산하여 유통업체에 배송할 수 있습니다. 유통업체는 소매업체에 제품을 배송할 수 있습니다. 이것은 재료 흐름 입니다 .
이것은 가장 단순한 형태의 소매 유통 공급망입니다. 모델에 대한 추가 사항은 예를 들어 리드 타임, 최소 주문 수량, 제품 로트 크기, 재고 정책 등이 될 수 있습니다. 이러한 모든 추가 사항은 이 기사에서 논의된 것과 같은 에이전트 기반 모델에 추가될 수 있습니다.

위의 그림은 개념적 모델을 보여줍니다. 다음 섹션에서는 Python에서 위의 공급망 ABM을 구현합니다.
Python에서 공급망 ABM 구현
아래에서는 공급망 ABM을 Python으로 구현합니다. 먼저 사용할 클래스의 프레임워크를 구현합니다. Retailer 클래스 , Distributor 클래스 및 Manufacturer 클래스가 필요합니다 . 아래에 잘린 코드에서 이러한 클래스를 구현합니다.
# RETAILER class
class Retailer:
def __init__(self, inventory_level):
self.inventory_level = inventory_level
def order_from_distributor(self, quantity):
if quantity > self.inventory_level:
order_quantity = quantity - self.inventory_level
return order_quantity
else:
return 0
def receive_shipment(self, quantity):
self.inventory_level += quantity
# DISTRIBUTOR class
class Distributor:
def __init__(self, inventory_level):
self.inventory_level = inventory_level
def order_from_manufacturer(self, quantity):
if quantity > self.inventory_level:
order_quantity = quantity - self.inventory_level
return order_quantity
else:
return 0
def receive_shipment(self, quantity):
self.inventory_level += quantity
# MANUFACTURER class
class Manufacturer:
def __init__(self, production_capacity):
self.production_capacity = production_capacity
def produce_goods(self, quantity):
if quantity <= self.production_capacity:
return quantity
else:
return self.production_capacity
다음으로 시뮬레이션 모델 자체를 구현합니다 . 이를 위해 4개의 인수를 취하는 함수를 작성합니다. 소매업체, 유통업체, 제조업체 및 반복 횟수. 무작위 모듈을 사용하여 무작위 주문 수량을 생성합니다.
import random
# SIMULATION implementation
def simulate_supply_chain(retailer :Retailer,
distributor :Distributor,
manufacturer :Manufacturer,
num_iterations :int
) -> None:
""" supply chain simulation
simulates a supply chain with a retailer, a distributor, and a manufacturer;
simulates over a specified amount of iteration;
uses random to generate random order quantities
Args:
# retailer (Retailer): retailer agent that place orders at distributor
# distributor (Distributor): distributor that palces order at manufacturer
# manufacturer (Manufacturer): manufacturer that ships to distrubtor
# num_iterations (int):
Returns:
# None
"""
for i in range(num_iterations):
# retailer places order with distributor
order_quantity = retailer.order_from_distributor(random.randint(5, 15))
# distributor places order with manufacturer
order_quantity = distributor.order_from_manufacturer(order_quantity)
# manufacturer produces goods and ships to distributor
shipped_quantity = manufacturer.produce_goods(order_quantity)
distributor.receive_shipment(shipped_quantity)
# distributor ships goods to retailer
shipped_quantity = distributor.inventory_level
retailer.receive_shipment(shipped_quantity)
이것으로 Python에서 예시적인 공급망 ABM을 완성합니다.
맺음말 및 관련 내용
현실적이고 상업적인 모델은 많은 추가 사항을 통합해야 합니다. 예를 들어 리드 타임, 주문 포인트, MOQ, 로트 크기 등 처음에 지적했듯이 주문 자체는 이 경우와 같이 간단한 난수 생성기에 의해 생성되지 않을 가능성이 큽니다. 그럼에도 불구하고 이 간단한 예는 공급망 모델링을 위한 에이전트 기반 모델링의 개념을 보여줍니다. 매우 복잡한 공급망도 이러한 방식으로 모델링할 수 있습니다.
에이전트 기반 시뮬레이션 에 관심이 있다면 내 그리드 기반 에이전트 시뮬레이션 모델 예제를 확인하는 것이 좋습니다 .

최적화 및 시뮬레이션을 전문으로하는 산업 엔지니어 (R, Python, SQL, VBA)
Leave a Reply