← Iris
Running

Space-time diagram — position (x) vs time (y↓), color = speed

Statistics

Cars 0
Road cells 200
Avg speed
Flow rate
Timestep 0

Speed legend

Stopped (v=0)
Slow
Medium
Fast (v=vmax)
Density 30%
Speed limit (vmax) 5
Random braking probability 0.30
Simulation speed 10 steps/s
Use the sliders to adjust traffic density, speed limit, and random braking probability. Watch the space-time diagram below for phantom jams — backward-propagating waves visible as diagonal bands.

About this lab

The Nagel-Schreckenberg model

In 1992, Kai Nagel and Michael Schreckenberg proposed a minimal cellular automaton that reproduces the essential features of real highway traffic. A one-dimensional lattice represents the road. Each cell is either empty or occupied by a car with an integer velocity from 0 to vmax. At each timestep, four rules are applied simultaneously to every car:

1. Acceleration:   v → min(v + 1, vmax)
2. Braking:        v → min(v, gap - 1)     (gap = distance to car ahead)
3. Randomization:  v → max(v - 1, 0)       with probability p
4. Movement:       position → position + v

The first rule models drivers wanting to go faster. The second prevents collisions. The third introduces human imperfection — the slight hesitation, the momentary distraction. The fourth moves everyone forward. That is the entire model. From these four rules, realistic traffic phenomena emerge.

Phantom traffic jams

The most striking phenomenon is the phantom traffic jam — a jam that forms without any bottleneck, accident, or obstruction. One driver brakes slightly (rule 3). The driver behind brakes harder to compensate. This amplifies backward through the traffic stream, creating a standing wave that propagates upstream at roughly 15 km/h in real traffic. In the space-time diagram, these appear as diagonal bands sloping upward and to the left. You are in traffic, you slow to a crawl, you eventually accelerate again — and there was never anything there.

The fundamental diagram

Traffic engineers plot flow (cars per unit time) against density (cars per unit length). At low density, flow increases linearly — more cars means more throughput. But at a critical density, flow peaks and then decreases. Adding more cars makes the road move less total traffic. This is the phase transition from free flow to congested flow. The critical density depends on vmax and the braking probability p. Use the density slider to explore this transition: watch the average speed drop suddenly as you pass the critical point.

Why randomness matters

Set the random braking probability to zero and traffic flows perfectly — no jams ever form. This is the deterministic limit, and it reveals that all congestion in this model comes from the randomization step. Without human imperfection, the system finds a stable equilibrium. With even a small braking probability, metastable states collapse into jams. The “aggressive drivers” preset (low p) shows a road that flows well most of the time but occasionally develops severe jams — less frequent but more dramatic.

Circular road

The road here is periodic — cars that leave the right end reappear on the left. This eliminates boundary effects and makes the system a clean testbed for studying emergent phenomena. Real highways have on-ramps, off-ramps, merges, and grades, but the periodic road isolates the fundamental dynamics of car-following behavior.