Most people have probably already encountered the phenomenon: One is cruising down the freeway, when suddenly the traffic thickens and slows to a complete stop. When traffic resumes moving one notes there was no apparent reason for the halt, no accident, no detour, no construction. Traffic jams seem to appear out of the blue without any apparent reason. The first model of freeway traffic to successfully explain the occurence of these “phantom traffic jams” was invented at the university of Cologne by Kai Nagel and Michael Schreckenberg in ’92. They proposed a probabilstic cellular automaton (CA) model for single-lane freeway traffic.

Using very simple rules, this model is able to reproduce the basic phenomena of real traffic, such as the occurance of the traffic jams out of nowhere. The model is a minimal model in the sense that any further simplification of the rules no longer produces realistic simulation results. A proper modelling of the “fine-structure” of traffic, however, necessitates the introduction of additional and/or the modification of the existing rules.

The NaSch model (as a cellular automaton) discretizes both space and time. The road is divided into cells of (approximately) 7.5 m length. Each cell can be in one of two states, being either occupied by a car or not. The state of car () is characterized by its position and velocity (). The state of the system at time can be obtained from the state at time by applying the following four rules to all cars at the same time (parallel update):

**Acceleration**

or in code:for (var i=0;i<no_of_cars;i++) { if(cars[i].velocity < maxV) { cars[i].velocity = cars[i].velocity + 1; } }

**Braking**

or in code:for (var i=0;i<no_of_cars;i++) { cars[i].velocity = Math.min( cars[i].velocity, (cars[(i+1)%no_of_cars].position+c - cars[i].position ) % c -1 ); }

**Randomization**

With probability :

or in code:for (var i=0;i<no_of_cars;i++) { var r = Math.random(); if( (cars[i].velocity > 0) && ( r < l ) ) { cars[i].velocity = cars[i].velocity - 1; } }

**Driving**

or in code:for (var i=0;i<no_of_cars;i++) { cars[i].position=(cars[i].position+cars[i].velocity / steps); }

One time step in the simulation corresponds to roughly 1 second. The NaSch model does not attempt to describe traffic flow accurately on a microscopic level. The motion of a single car may therefore exhibit unnatural features, but averaging over a large number of cars or a large timescale produces quite realistic results. Macroscopic effects, such as spontaneous formation of a jam, can therefore be readily understood from the model by varying the car density and the braking probability .

Below a the output of a JavaScript implementation of the CA is shown. The one-dimensional street is divided into 200 cells and subject to periodic boundary conditions. Car density and braking probability can be set using the spinner boxes. Cars are randomly colored. The lower plot has time on the -axis and shows that the congestions themselves move in the direction opposite to the direction of the cars. The avg. velocity is given by and the avg. flow as with the density.

For a braking probability of the avg. flow peaks around . For higher densities the congestions build up, which reduce the strongly and lead to a suppression of the avg. flow.

avgV2

flow2