traffic_simulation
traffic_simulation,
a Python code which
simulates the way cars must wait at a traffic light.
The user can only input the number of 10-second time periods to
be simulated.
The code operates with the following internal parameters:
-
GREEN, the number of 10-second time periods that
a green light lasts, set to 2.
-
P, the probability that a new car will come to the light
in the next second, set to 0.3.
-
PERIOD_LENGTH, the number of seconds in one time period,
set to 10.
-
RED, the number of 10-second time periods that
a red light lasts, set to 4.
Usage:
traffic_simulation ( n )
where
-
n is the number of 10-second time cycles.
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the MIT license
Languages:
traffic_simulation is available in
a MATLAB version and
an Octave version and
a Python version.
Related Data and codes:
traffic_simulation_test
python_simulation,
a Python code which
uses simulation to study card games, contests, and other processes
which have a random element. Usually, the purpose is to try to
predict the average behavior of the system over many trials.
Reference:
-
Brian Hahn, Dan Valentine,
Essential MATLAB for Engineers and Scientists,
Academic Press, 2009,
ISBN13: 978-0123748836,
LC: TA345.V34.
Source Code:
-
sim_25.png,
a PNG image of the simulation for 25 time periods.
-
sim_50.png,
a PNG image of the simulation for 50 time periods.
-
sim_100.png,
a PNG image of the simulation for 100 time periods.
-
sim_200.png,
a PNG image of the simulation for 200 time periods.
Last revised on 25 November 2022.