자동차 조립 라인: SimPy로 결정론적 이벤트 추가하기
이 연습 문제는 SimPy를 사용한 결정론적 프로세스에 초점을 맞춥니다.
동일한 자동차 조립 라인 모델을 SimPy 패키지로 만들어 보겠습니다.
SimPy 메서드를 사용해 앞서와 같은 결정론적 이벤트를 추가하는 데 집중할 거예요. 사전 분석 결과, 용접과 도장은 각각 15시간, 부품 조립과 테스트는 각각 24시간이 걸린다고 가정했죠.
SimPy 라이브러리는 이미 임포트되어 있습니다.
이 연습은 강의의 일부입니다
Python으로 배우는 이산 사건 시뮬레이션
연습 안내
- 프로세스 1의 소요 시간을 기록하도록 코드를 완성하세요.
- 프로세스 2의 소요 시간을 기록하도록 코드를 완성하세요.
- SimPy 환경을 생성하고
env라는 변수에 저장하세요. - 모델을
SIMULATION_TIME까지 실행하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
def car_production_line(env):
car_number = 0
while True:
car_number += 1
# Clock-in the time requirement for: Welding and Painting
yield env.____(15)
print(f"Time = {env.now:7.4f} | Car {car_number:02d} | Welding and Painting")
# Clock-in the time requirement for: Assembly and Testing
yield env.timeout(____)
print(f"Time = {env.now:7.4f} | Car {car_number:02d} | Assembly of parts and Testing")
print(f"Time = {env.now:7.4f} | Car {car_number:02d} | Car ready for shipping!")
SIMULATION_TIME = 1000
# Create the SimPy environment
env = simpy.____()
env.process(car_production_line(env))
# Run the SimPy model
env.____(until=SIMULATION_TIME)