File: carwash.rst

package info (click to toggle)
python-simpy3 3.0.11-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,080 kB
  • sloc: python: 2,885; makefile: 138
file content (30 lines) | stat: -rw-r--r-- 868 bytes parent folder | download | duplicates (4)
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