Xây dựng mô hình của bạn: Kiểm soát phản hồi của dây chuyền lắp ráp
Giờ bạn đã xác định xong môi trường và tài nguyên SimPy, cũng như bộ phát sinh tạo các đơn hàng máy bay, đã đến lúc tạo một bộ phát sinh để mô tả phản hồi của dây chuyền lắp ráp, dựa trên thời gian xử lý đã biết và các tài nguyên hạn chế hiện có.
Bài tập này là một phần của khóa học
Mô phỏng Sự kiện Rời rạc bằng Python
Hướng dẫn bài tập
- Tạo yêu cầu slot cho
step_2_wingsdưới tênslot_request_2và yield yêu cầu. - Tạo yêu cầu slot cho
step_3_power_plantdưới tênslot_request_3và yield yêu cầu. - Tạo yêu cầu slot cho
step_4_landing_geardưới tênslot_request_4.
Bài tập tương tác thực hành trực tiếp
Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.
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]])