1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
=======
Carwash
=======
Covers:
- Waiting for other processes
- Resources: Resource
The *Carwash* example is a simulation of a carwash with a limited number of
machines and a number of cars that arrive at the carwash to get cleaned.
The carwash uses a :class:`~simpy.resources.resource.Resource` to model the
limited number of washing machines. It also defines a process for washing
a car.
When a car arrives at the carwash, it requests a machine. Once it got one, it
starts the carwash's *wash* processes and waits for it to finish. It finally
releases the machine and leaves.
The cars are generated by a *setup* process. After creating an intial amount of
cars it creates new *car* processes after a random time interval as long as the
simulation continues.
.. literalinclude:: code/carwash.py
The simulation's output:
.. literalinclude:: code/carwash.out
|