ComenzarEmpieza gratis

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]])

Este ejercicio forma parte del curso

Discrete Event Simulation in Python

Ver curso

Instrucciones del ejercicio

  • 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.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

def order_aircraft(env, total_num_orders, step_1_fuselage, step_2_wings, step_3_power_plant, step_4_landing_gear):
    
    # Generate the orders with a for-loop
    ____ request_i in range(total_num_orders):

        assembly_process_request = assembly_line(env, request_i, step_1_fuselage, step_2_wings, step_3_power_plant, step_4_landing_gear)

        # Initiate an assembly line process for each request
        env.____(assembly_process_request)

        # Clock-in the time between requests
        yield env.timeout(____)
Editar y ejecutar código