This page was automatically generated by NetLogo 5.0.3. The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.

powered by NetLogo

view/download model file: trafficCA.nlogo


This is model of city traffic based on elementary cellular automata (ECA) .
More info at


Click on “Setup” and then on “Go” or “Step”. The controls above these buttons should be set before “Setup”, the others can be changed anytime.

GRID-SIZE-X and GRID-SIZE-Y determine how many streets will be with each orientation (vertical and horizontal). Use GRID-SIZE-X=0 for freeway model (Rule 184), i.e. no intersections

FOUR-DIRS? If true, streets flow in four directions (alternating). If false, only south and eastboud.

DENSITY. Determines probabilistically how many cells are occupied by vehicles.

%VERTICAL Determines probabilistically the percentage of cars on vertical streets (complementary to horizontal ones)

TOPOLOGY. Choose boundary conditions:
“cyclic”: periodic boundaries
“simple Moebius”: horizontal roads continue as vertical roads and vice versa, i.e. roads intersect with themselves once. Thus, GRID-SIZE-X should be equal to GRID-SIZE-Y.
“single Moebius”: whole city is a single self-intersecting street…

METHOD. Choose between following methods:
“Marching”: all lights march in step, either vertical or horizontal
“Green-wave”: Lights are synchronized so that vehicels flowing eastbound or southbound would not need to stop (at a flow speed of 1)

The next parameter affects the marching or green wave methods

P Duration of a green light, i.e. half a period (T/2). To avoid stopping of vehicels, set this equal to half the length of the street or equal to a factor of half the length of the street.

The following parameters affect the self-organizing method. See paper for a description.



MINGREEN (t_min)





The Velocity plot shows the percentage of vehicles moving, i.e. if v=1, no vehicle stops, and if v=0, all vehicles are stopped.

The Flux plot shows the velocity multiplied by the density. In the rule 184 model of highway traffic (i.e. no intersections, grid-size-x = 0), the maximum possible flux is $J=0.5$, at a density $rho=0.5$. This is because vehicles need at least one cell between them to move. If there are less vehicles, the flux will be lower, since there is no movement in free space. If there are more vehicles, then the flux will also be lower, since stopped vehicles do not move.


The green wave method works fine for only two directions (set FOUR-DIRS? to false). However, when vehicles flow in four directions (and there are more than two streets in any orientation), the performance is relatively bad, because vehicles going opposite to the green wave face anti-correlated lights.

The self-organizing mehtod can achieve free flow in four directions for low densities.

At which densities each method reaches a gridlock (flow=0)?

See how performance varies as more streets are added (for different methods).


Based on: Wilensky, U. (1998). NetLogo CA 1D Elementary model. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Gershenson, C. & D. A. Rosenblueth (2012). Adaptive self-organization vs. static optimization: A qualitative comparison in traffic light coordination. Kybernetes 41(3):386-403.

Rosenblueth, D. A. & C. Gershenson (2011). A model of city traffic based on elementary cellular automata, Complex Systems 19(4):305-322.

About ECA:


Carlos Gershenson's homepage