Building a car washer model with SimPy
Consider that a company purchased a commercial car washer and wants to optimize its operation to increase profitability. Building a discrete-event model can be helpful because it can help identify bottlenecks, streamline resources, and incrementally adjust processes towards reaching full capacity.
The commercial car washer takes five minutes to complete a car wash cycle.
Build a discrete-event model that mimics the behavior of this machine, and run it for eight hours (480 minutes) to predict the number of cars washed, and log the time of completion of each cycle.
This exercise is part of the course
Discrete Event Simulation in Python
Exercise instructions
- Import the SimPy package.
- Complete the
print()
statement to write the current simulation time in the console. - Build the SimPy Environment.
- Run the model for eight hours, using minutes as the time units.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import SimPy
import ____
def car_wash(env):
car_wash_num = 0
while True:
car_wash_num += 1
# Get the current simulation time and add process time
print(f'Time {env.____:02d} min | Car Wash # {car_wash_num:02d}')
yield env.timeout(5)
# Create SimPy Environment and add process generator
env = simpy.____()
env.process(car_wash(env))
# Run model
env.____(until=8*60)