Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Discrete Event Simulation in Python

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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)
Code bewerken en uitvoeren