开始使用免费开始使用

搭建您的模型:控制装配线响应

现在,您已经定义了 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]])
编辑并运行代码