สร้างโมเดล: ควบคุมการตอบสนองของสายการประกอบ
หลังจากกำหนด environment และทรัพยากรของ SimPy รวมถึง generator ที่สร้างออร์เดอร์อากาศยานแล้ว ขั้นตอนต่อไปคือสร้าง generator เพื่อจำลองการตอบสนองของสายการประกอบ โดยอิงจากเวลาการประมวลผลที่ทราบอยู่แล้วและทรัพยากรที่มีอยู่อย่างจำกัด
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การจำลองเหตุการณ์แบบไม่ต่อเนื่องด้วย Python
คำแนะนำการฝึกหัด
- ขอ slot สำหรับ
step_2_wingsโดยกำหนดเป็นslot_request_2แล้ว yield request นั้น - ขอ slot สำหรับ
step_3_power_plantโดยกำหนดเป็นslot_request_3แล้ว yield request นั้น - ขอ slot สำหรับ
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]])