← mohithgajjela.com
FIELD / 09
MOHITH GAJJELA
TRAINS IN YOUR BROWSER
no network calls
FIELD 09 / TRAFFIC X-RAY

Finding traffic jams
between road sensors.

Road sensors only see the cars driving over them. A small neural network with one physics rule built in fills in the gaps. Drop cars on the loop below and watch it train live in your browser.

8.3 vs 20.9cars/mi off: physics model vs connect-the-dots, live loop
269days of Caltrans I-880 sensor data, 2026
8.4MNGSIM vehicle positions, ground truth
187models trained in the offline study
the model on this page is a physics-informed neural network training in a background thread, in plain JavaScriptthe cars are simulated · the numbers in section 03 are from real roads
CONSERVATION LAW + LIVE TRAINING + 6-FT LOOP DETECTORS + CAR-FOLLOWING MODEL + REAL CALTRANS DATA + CONSERVATION LAW + LIVE TRAINING + 6-FT LOOP DETECTORS + CAR-FOLLOWING MODEL + REAL CALTRANS DATA +
01THE INSTRUMENT · TRAINS WHILE YOU WATCH

Drop cars on the loop. Watch it
find them between the sensors.

The white markers are sensors. The three rings outside the road are three guesses at the traffic everywhere else. Compare them to the real cars.

1 · MAKE TRAFFIC

Drag the car chip onto the road to drop a bunch of cars, or use a preset. Enough cars and a jam appears by itself.

2 · CAUSE TROUBLE

Pick stalled car, then click on the road, ideally halfway between two sensors where nothing can see it.

3 · MOVE THE SENSORS

Drag the white markers. Fewer sensors, bigger blind spots. The slider goes down to two.

4 · COMPARE THE RINGS

Sensors alone, a naive "connect the dots" guess, and the model. The readout grades all three against the real cars every five seconds.

drag onto road · 8 cars stalled car slow truck remove cars
click the road to drop cars
model (PINN) · cars/mi off
—
graded against the real cars, right now
connect the dots · off
—
blend the two nearest sensors
sensor average · off
—
assume the loop looks like the sensors' mean
training
—
steps per second
on the loop
—
cars · sim time
warming upsensor fit —physics residual — emptyjammedsensor

Everything in the box above is computed live. The model is a Fourier-feature MLP (48 features, two hidden layers of 32) trained with Adam on the last eight minutes of sensor readings, plus a finite-difference residual of the Lighthill-Whitham-Richards conservation law at 250 random points in space and time, in a Web Worker. Training speed depends on your machine; the readout shows it.

02BEHIND THE SCENES · THE LAST EIGHT MINUTES

A jam is a diagonal stripe.
Only one method draws it.

Each strip below is a map of the loop over time: left to right is distance around the loop, top to bottom is the last eight minutes, bottom row is now. A jam that passes one sensor has to reach the next one later, so on this kind of map every jam is a stripe that leans to the left. The sensors see thin columns of that stripe. The physics is what connects the columns.

What is really there

Counted from every car. The model never sees this; it is only used to grade the answers.

What the sensors report

Only the thin columns under each sensor are known. Everything else is a blind spot.

Connect the dots

Blend the nearest two sensors. A jam sitting between them is invisible until it reaches one.

The model

Same sensor data, but trained to obey "cars don't vanish". It carries the stripe across the blind spots.

How it works, in one paragraph: the network takes a position on the loop and a moment in time and outputs one number, how packed the road is there. It is trained to match the sensor readings, and at thousands of random places and times where there is no sensor it is penalised if the number of cars in a stretch of road changes by more than the cars driving in or out of it. Together with a measured relationship between how packed a road is and how fast it moves (the fundamental diagram, calibrated on real Bay Area freeways in section 03), that law fixes how fast a jam crawls backwards, so the network can place jams where no sensor is looking.

03REAL NUMBERS · TWO REAL DATASETS, 187 TRAINED MODELS

On real roads it halves the neural net's error.
Against interpolation, it depends on the sensor.

The loop above is a simulation. The same model was then trained 187 times on two real datasets: NGSIM, 8.4 million recorded vehicle positions on US-101 and I-80, where the true density of every 100 ft of road every 10 seconds is known exactly, and Caltrans PeMS, every day of 2026 for 43 sensors on I-880 South between Hayward and Fremont, pulled from the Clearinghouse. In each test the model sees a few sensors (or a few percent of cars sharing their GPS) and is graded on the ones it never saw.

settinginterpolateneural net, no physicssame net + physics
NGSIM · 3 fixed detectors29.1%54.6%27.2%
NGSIM · 2% of cars as GPS probes38.7%54.3%34.8%
NGSIM · 10% of cars as GPS probes35.9%41.3%30.4%
I-880 · 3 fixed detectors48.2%150.9%48.7%
I-880 · 12 fixed detectors37.2%62.2%34.9%

Relative error of the reconstructed density on held-out sensors, mean over days and seeds, lower is better. Green is the best of the three. Physics beat the plain network in 41 of 41 configurations. It beat interpolation in all 12 probe-vehicle tests and 6 of 9 fixed-sensor tests on NGSIM, and only tied it on I-880. Every number comes from the run logs; the full per-day tables are in the explorer.

20×
On 5-minute sensor data, the flow-imbalance term is twenty times the storage term and uncorrelated with it. Vehicle conservation is not observable at that resolution, which is why physics only ties interpolation on I-880.
88%
Of Los Angeles mainline detectors reported nothing usable on the day I scanned them. The probe-vehicle mode exists because the sensors are dying.
1e-5
The physics weight above which a naive PINN collapses to a flat field on real data. Non-dimensionalising the residual by the advection scale is what made it train at all.
1 of 3
Fundamental-diagram parameters the model could recover from sparse sensors as an inverse problem (jam density yes, free-flow speed and wave speed no). Reported as measured.
04LIMITS · STATED PLAINLY

What this page cannot
claim.

01

The loop is a simulation.

The cars follow the Intelligent Driver Model with simple lane changes. Real drivers are messier, and a real corridor has on-ramps that add and remove cars, which is exactly the term that broke conservation on I-880. The live demo shows the mechanism, not a deployment.

02

It ties interpolation on 5-minute loop data.

Where density comes from counting real cars (NGSIM) the physics wins. Where it comes from station averages every five minutes, the storage term is buried under flow-measurement noise and ramp inflows, and the physics acts as a regulariser, not a constraint. That is a property of the data, and it is in the tables.

03

The "now" edge is the weakest.

The most recent readings have had the fewest training steps. The strips in section 02 show the estimate a few seconds behind the leading edge is better than the estimate at it. Slower machines widen that gap; the training-rate readout tells you how much.

04

Recovering physics constants mostly failed.

Asked to learn free-flow speed, wave speed and jam density from sparse sensors, the model recovered only the jam density. US-101 is congested for the whole recording, so free-flow speed is simply not in the data.

Home