1. Learn
  2. /
  3. Courses
  4. /
  5. Discrete Event Simulation in Python

Connected

Exercise

Build your model: Generate aircraft orders

Now that the SimPy environment and resources have been created, let's link it with a generator that simulates aircraft purchase orders. There are 30 aircraft orders.

The assembly_line() function makes sequential resource requests for the different aircraft component manufacturing sections. The code below shows one such request.

# Open the resource step_1_fuselage request
with step_1_fuselage.request() as slot_request_1:
  request_1_time = env.now
  yield slot_request_1
  print(f"time: {env.now:7.4f} | Aircraft {aircraft_id:02d} 
                               | Enters: step_1_fuselage 
                               | Queued for {env.now-request_1_time} hours")
  yield env.timeout(processing_time[processing_time_step_names[0]])

Instructions

100 XP
  • Create a for-loop to make all order requests (total_num_orders) using a dummy variable named request_i.
  • Create a new process for each aircraft request during the for-loop; all processes are based on the generator assembly_process_request.
  • All 30 aircraft have been requested in one batch, so complete the code to reflect no waiting time between requests.