開始使用免費開始

建立你的模型:控制組裝線的回應

你已經定義了 SimPy 環境與資源,還有用來產生飛機訂單的產生器。現在該建立另一個產生器,根據已知的處理時間與有限的可用資源,來描述組裝線的回應。

本練習屬於課程

Python 的離散事件模擬

檢視課程

練習說明

  • 為 step_2_wings 建立槽位請求為 slot_request_2,並對該請求進行 yield。
  • 為 step_3_power_plant 建立槽位請求為 slot_request_3,並對該請求進行 yield。
  • 為 step_4_landing_gear 建立槽位請求為 slot_request_4。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

def assembly_line(env, aircraft_id, step_1_fuselage, step_2_wings, step_3_power_plant, step_4_landing_gear):

    processing_time_step_names = list(processing_time.keys())

    with step_1_fuselage.request() as slot_request_1:
        yield slot_request_1
        yield env.timeout(processing_time[processing_time_step_names[0]])

    # Make slot request for step_2_wings and yield the request
    with step_2_wings.request() as ____:
        request_2_time = env.now
        ____ slot_request_2
        yield env.timeout(processing_time[processing_time_step_names[1]])

    # Make slot request for step_3_power_plant and yield the request
    with step_3_power_plant.request() as ____:
        request_3_time = env.now
        ____ slot_request_3
        yield env.timeout(processing_time[processing_time_step_names[2]])

    # Make slot request for step_4_landing_gear
    with step_4_landing_gear.request() as ____:
        request_4_time = env.now
        yield slot_request_4
        yield env.timeout(processing_time[processing_time_step_names[3]])
編輯並執行程式碼