Get startedGet started for free

Car assembly line: adding deterministic events

This exercise focuses on deterministic processes without using SimPy. In the next exercise, we will focus on SimPy.

A discrete-event model has been requested to simulate a car production line. The model aims at helping to increase productivity, identify bottlenecks, and manage resources. To get started, you had to first identify the main groups of processes involved in the production line. These are (1) welding and painting and (2) assembly and testing. Of course, each of these groups of processes involves many sub-processes and tasks, but for now, you are focused on coding the first version of your model at a high level.

Now that you have identified the critical groups of processes, it's time to determine the average time each process takes to complete. You did your research and came up with 15 hours for welding and painting and 24 hours for assembling parts and testing. Let's represent these deterministic processes in a discrete-event model without using SimPy.

This exercise is part of the course

Discrete Event Simulation in Python

View Course

Exercise instructions

  • Clock-in the duration of the "Welding and Painting" process.
  • Clock-in the duration for "Assembly and Testing" process.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

def car_production_line(SIMULATION_TIME):
    car_number, time  = 0, 0
    while time < SIMULATION_TIME:

        car_number += 1

        # Clock-in the time requirement for: Welding and Painting
        time += ____
        if time >= SIMULATION_TIME: break
        print(f"Time = {time:7.4f} | Car {car_number:02d} | Welding and Painting")

        # Clock-in the time requirement for: Assembly and testing
        time += ____
        if time >= SIMULATION_TIME: break
        print(f"Time = {time:7.4f} | Car {car_number:02d} | Assembly of parts and Testing")
        print(f"Time = {time:7.4f} | Car {car_number:02d} | Car ready for shipping!")

SIMULATION_TIME = 1000
car_production_line(SIMULATION_TIME)
Edit and Run Code