시작하기무료로 시작하기

자동차 조립 라인: SimPy로 비결정적 이벤트 추가하기

이 연습 문제는 SimPy를 사용한 비결정적(비확정적) 프로세스에 초점을 맞춥니다.

이전에 만든 자동차 조립 라인 모델의 SimPy 버전을 수정하면서, 동일한 결정적 이벤트를 SimPy 메서드로 추가하는 데 집중할 거예요.

"용접 및 도색"은 평균 15시간이 걸리지만, 그 시간은 위아래로 5시간씩 변동합니다. 이어서 "부품 조립 및 테스트"는 평균 24시간이 걸리지만, 그 시간은 위아래로 6시간씩 변동합니다.

SimPy 라이브러리는 이미 임포트되어 있습니다.

이 연습은 강의의 일부입니다

Python으로 배우는 이산 사건 시뮬레이션

강의 보기

연습 안내

  • random.randint() 메서드를 사용하여 변동성을 반영해 "용접 및 도색" 프로세스의 소요 시간을 기록하세요.
  • random.randint() 메서드를 사용하여 변동성을 반영해 "부품 조립 및 테스트" 프로세스의 소요 시간을 기록하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

def car_production_line(env):
    car_number = 0
    while True:
        car_number += 1

        # Adding process 1: Clock-in time requirement for Welding and Painting
        yield env.____(random.____(10, 20))
        print(f"Time = {env.now:7.4f} | Car {car_number:02d} | Welding and Painting")

        # Adding process 2: Return/yield time after completing the process and print the current time
        yield env.____(random.____(18, 30))
        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!")

env = simpy.Environment()
env.process(car_production_line(env))
env.run(until=SIMULATION_TIME)
코드 편집 및 실행