M·LAB

Traffic Pattern Laboratory

Live physics simulations of UK motorway behaviour · Intelligent Driver Model + MOBIL

SIM RUNNING

Reduced motion is on in your system settings; simulations start paused. Use Resume to run them.

// One driver brakes. Everyone behind pays.

A closed loop of traffic, every driver following the Intelligent Driver Model. Hit BRAKE to make one car slam on for 1.5 seconds, then watch the stop-and-go wave it creates travel backwards through traffic, long after the original car has driven off. At high density, waves form on their own; nobody has to do anything wrong.

RING ROAD · FREE FLOW
stopped → free flow braking car
Mean speed
Slowest car
Wave speed (rearward)
Flow rate
Cars trapped <10 mph
0

// Space–time diagram

The instrument traffic engineers actually use. Each car draws a horizontal trace through time, coloured by its speed. A phantom jam appears as a red band sloping down-left: the jam moving backwards along the road while time moves forward. On real motorways these waves roll rearward at roughly 10 to 12 mph.

POSITION ↑ · TIME → · GANTRY FEED
What the research says Sugiyama et al. (2008) put 22 drivers on a 230 m circular track and asked them simply to cruise. With no bottleneck and no incident, stop-and-go waves emerged spontaneously and rolled backwards at about 20 km/h, almost exactly matching motorway measurements. Above a critical density, jams are a property of the system, not of any individual driver; one over-firm brake input is enough to crystallise one.

// Is the weaver actually winning?

Two lanes of heavy motorway traffic. The amber car weaves aggressively into whichever lane looks faster (MOBIL lane-change model, zero politeness). The white car starts beside it and holds its lane. Every forced merge makes the car behind brake, and that braking propagates. Watch who is actually ahead, and what the weaving does to everyone else.

M-WAY · 2 LANES · RUNNING
weaver (changes lanes) steady (holds lane) other traffic by speed long vehicle = HGV (56 mph limiter, holds the inside lane)
Weaver lane changes
0
Weaver lead over steady
Projected gain per 10 mi
Brake events caused
0
Mean traffic speed
What the research says Trajectory data from Sydney's M1 (2023) found lane changing brings no significant speed benefit to the individual in most conditions, with a narrow exception around 45 to 50 km/h. A University of Toronto simulation put the best-case gain from aggressive weaving at roughly 2% of journey time. Meanwhile, a 2024 study of a 3.3 km weaving section concluded that concentrated lane changing is the main contributor to speed collapse there: the manoeuvre punches "voids" into the receiving lane and forces braking that ripples rearward.

// What does the extra speed actually buy?

Pure arithmetic first, then reality. Time saved is not linear: t = d ÷ v, so each extra 10 mph buys less than the last. The realism slider accounts for the share of the journey genuinely spent at cruise speed (junctions, roadworks and traffic apply equally to both runs). Fuel model is calibrated to the AA's published figures.

Time @ baseline
Time @ faster
Time saved
Extra fuel
Extra cost this trip
Stopping distance
JOURNEY TIME vs CRUISE SPEED · DIMINISHING RETURNS
RELATIVE FUEL USE PER MILE · 70 MPH = 100
The honest summary

// Why smart motorways set 50 in congestion

Two identical rings of dense traffic get an identical disturbance every 15 seconds. Lane A is signed at 70: drivers rush gaps, so each disturbance crystallises into a stop-and-go wave. Lane B is signed at 50: the smaller speed differences absorb the same disturbance. Watch which lane actually delivers more vehicle-miles.

A: SIGNED 70 · B: SIGNED 50 · SAME DENSITY, SAME DISTURBANCE
A · mean speed (signed 70)
B · mean speed (signed 50)
Distance delivered A vs B

// Lane capacity: the headway equation

A lane's maximum throughput is set almost entirely by the time gap drivers keep. Capacity ≈ 3600 ÷ (headway + car-length time). Tailgating raises theoretical capacity but destroys stability, which is exactly how phantom jams start; this is the trade the whole lab is about.

Lane capacity
Gap to car ahead
Stability
FUNDAMENTAL DIAGRAM · FLOW vs DENSITY · ONE LANE
Reading the curve Left of the peak, adding cars adds flow: the road is under-used. Right of the peak, every extra car reduces what the lane delivers, and operation becomes unstable; this is where one brake tap becomes a wave rolling back at the slope of the falling branch (about 10 to 12 mph). Variable speed limits work by holding traffic just left of the peak instead of letting it tip over it.

// The data pipeline: ingest, match, predict

A synthetic motorway day (24h compressed into 144 seconds) with morning and evening peaks. The pipeline below is the real one used at scale: ingest live detector samples, match them against a stored historical pattern for that time of day, then predict ahead with a seasonal AR(2) model, the ARIMA family's working core. The forecaster and the clustering both run live in this page on the sim's own sensor feed; nothing is pre-baked.

CORRIDOR · 3 LANES · DAY CLOCK
Live speed
Flow
Regime (K-Means)
Samples ingested
AR(2) fit
1-step forecast MAE

// Forecast against the pattern store

Teal is the observed feed. The dashed grey line is the learned time-of-day pattern (48 half-hour bins, built from previous days). Amber is the live forecast: pattern plus an AR(2) model fitted to the residuals every two seconds, with a 95% band that widens with horizon. Trigger an incident and watch the observation fall out of the band, the regime chip flip to ANOMALY, and the forecast chase the new reality.

SPEED · OBSERVED vs PATTERN vs FORECAST
TRAFFIC REGIMES · K-MEANS ON (SPEED, FLOW, VARIABILITY) · LIVE POINT CIRCLED
What the research says This is the published Google Maps recipe: aggregate live location pings, merge with a database of historical patterns for that road at that time, then let the model produce ETAs and forecasts. Short-term traffic forecasting has leaned on the ARIMA family since the Box-Jenkins era because seasonal differencing strips out the rush-hour cycle and leaves a learnable residual; the surveys in the references map forty years of that literature. Clustering (K-Means here, DBSCAN in much of the literature) turns the raw feed into a small set of named regimes, while the anomaly flag trips when the live feed breaks from the stored time-of-day pattern beyond the forecast band for several samples running, which is exactly what an incident looks like to a pattern store. The shoulder-lane recommendation is the dynamic lane management play: capacity follows the demand pattern instead of waiting for the queue.

// Evolving a green wave

An arterial with four signalled junctions and cross traffic. Three controllers run in parallel on identical arrivals: a fixed 50/50 plan, an adaptive controller that re-splits green time each cycle from live queues, and a genetic algorithm that breeds whole timing plans (green split + offset per junction), scoring each chromosome by simulated total delay. Offsets matter because platoons take 32 seconds between junctions: the GA has to discover the green wave, nobody tells it one exists.

ARTERIAL · 4 JUNCTIONS · IDENTICAL DEMAND PER CONTROLLER
Fixed plan delay
Adaptive delay
GA plan delay
GA status
not yet run
Offline improvement

// Fitness over generations

Population of 24 timing plans, tournament selection, blend crossover, gaussian mutation, two elites carried over. Each generation evaluates every chromosome with a full 6-minute headless simulation. Watch the best line fall below the fixed-plan baseline within a handful of generations, then plateau as the green wave locks in.

GENETIC ALGORITHM · DELAY PER VEHICLE, LOWER IS BETTER
What the research says Evolutionary search is the standard answer when the timing space is too big to enumerate: even this toy corridor has an effectively continuous space of splits and offsets per junction, and city grids multiply that into the billions. GA approaches to signal timing repeatedly find double-digit delay reductions against fixed plans by discovering coordination (offsets) humans would tune by hand. The adaptive controller alongside it is the SCOOT/SCATS idea in miniature: measure queues, re-split greens every cycle. Adaptive wins when demand shifts, the GA wins when coordination matters; real deployments layer both, which is what active traffic management means in practice.

// The network as a graph: prediction by message passing

Junctions as nodes, road segments as edges, exactly how graph neural networks see a city. Traffic flows S→T over a motorway, an A-road and two cut-throughs, with route choice responding to live ETAs and real spillback between edges. Every second the page runs two rounds of neighbour message passing on the line graph, the core GNN operation: each edge updates its expectation from the state of the edges its traffic feeds into, because congestion physically propagates backwards along exactly those connections. The halo around each edge is that 15-second-ahead prediction; the inner line is live truth. Honesty note: the message-passing structure is real and the weights are hand-set; a production GNN learns them from millions of trajectories.

S→T NETWORK · LIVE + PREDICTED STATE · ⚠ = QUEUE WARNING SIGN
Network mean speed
Throughput
M-way ETA
A-road ETA
Early-warning hit rate

Route shares (logit on live ETA):

What the research says Google's DeepMind collaboration moved Maps ETAs onto graph neural networks precisely because the road network's structure is the prediction problem: a crash on one highway changes arrival times on parallel routes it never touches, and only a model that sees the graph can anticipate that. Recent work (including the 2025 Nature Scientific Reports line of GNN traffic predictors) keeps extending the same skeleton: spatial dependency from the adjacency, temporal dependency from each edge's history, both of which this demo carries in miniature. The stadium button is the planning use case: simulate the development against historical patterns before pouring concrete, which is what tools like PTV Vissim sell to highway authorities. The ⚠ markers are queue-warning systems doing their actual job, telling drivers about a jam the model can see forming before they can, which is how secondary collisions get prevented.