Interactive Nagel-Schreckenberg traffic cellular automaton: from local car-following and random slowdowns to flow-density curves and jam waves
This page implements a discrete traffic cellular automaton rather than an HPP lattice gas. Each vehicle occupies one cell, carries an integer velocity from 0 to Vmax, and all vehicles update synchronously from local headway and stochastic braking rules.
Each step follows the four NaSch rules: accelerate, brake to the available gap, apply random slowdown with probability p, then move forward by v cells. Obstacles and boundary conditions modify the available gap and can trigger queues or jams.
Even without accidents, sufficiently high density or a bottleneck can amplify local speed fluctuations into stop-and-go waves and upstream-moving jam fronts. The fundamental diagram and time series visualize this link between microscopic car-following and macroscopic flow collapse.
The flow J = ρ·v relationship. At low density (free flow), vehicles travel at Vmax and J grows linearly. Beyond critical density ρc, speed drops and J decreases, forming an inverted-U curve.
As density increases, the system moves from free flow to constrained flow and then to stop-and-go congestion. The NaSch model is simpler than Kerner-style three-phase theory, but it still captures the sharp capacity drop and phantom jams near critical loading.
Obstacles or high density trigger jam waves that propagate upstream. Because vehicles react to headway, a local slowdown is transmitted backward through the stream and forms the characteristic wedge-shaped congestion front.
This kind of cellular automaton is widely used to teach capacity, bottlenecks, speed limits, ramp control, and road works in a compact and computationally cheap traffic-flow model.
The NaSch model reproduces phantom traffic jams without any accident or lane change: density and stochastic slowdowns alone are enough to produce self-organized stop-and-go waves.
Similar exclusion and queueing rules appear in packet routing, production lines, and pedestrian cellular automata, making this a useful generic framework for studying emergent congestion.