ComenzarEmpieza gratis

Car assembly line: adding deterministic events with SimPy

This exercise focuses on deterministic processes using SimPy.

Let's build the same car assembly line model using the SimPy package.

We will focus on adding the same deterministic events using SimPy methods. Recall that you did your research and came up with 15 hours for welding and painting and 24 hours for the assembly of parts and testing.

The SimPy library has been imported for you.

Este ejercicio forma parte del curso

Discrete Event Simulation in Python

Ver curso

Instrucciones del ejercicio

  • Complete the code to clock-in the duration of process 1.
  • Complete the code to clock-in the duration of process 2.
  • Create a SimPy environment and store it in a variable named env.
  • Run the model until SIMULATION_TIME.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

def car_production_line(env):
    car_number = 0

    while True:
        car_number += 1

        # Clock-in the time requirement for: Welding and Painting
        yield env.____(15)
        print(f"Time = {env.now:7.4f} | Car {car_number:02d} | Welding and Painting")

        # Clock-in the time requirement for: Assembly and Testing
        yield env.timeout(____)
        print(f"Time = {env.now:7.4f} | Car {car_number:02d} | Assembly of parts and Testing")
        print(f"Time = {env.now:7.4f} | Car {car_number:02d} | Car ready for shipping!")

SIMULATION_TIME = 1000

# Create the SimPy environment
env = simpy.____()

env.process(car_production_line(env))

# Run the SimPy model
env.____(until=SIMULATION_TIME)
Editar y ejecutar código