Jamilton

Ring road with IDM car following and MOBIL lane changes.

Click a car to follow it. Shift+click, or press and hold, to brake it. Scroll to zoom, drag to pan.

Time
Mean speed
Slowest car
Density
Lane changes

Ride-along

Vectors:

Statistics

Lane changes

Total
To the left
To the right
Per minute

Left is towards lane 1, the inside lane.

Per lane change, m/s²

Selfish gain
Imposed on others
Net gain

Cooperation

Cars yielding
Mean loss
Speed given up

Lanes

LaneCarsMeanSlowest

IDM Parameters

MOBIL Parameters

Braking

Road

Density
Equilibrium speed

Changing the road restarts the run. Each lane starts at the speed its drivers settle to.

Presets

Each row is a ring with the default drivers, started at its settled speed. One car braked once and the traffic was watched for 60 simulated minutes. On one lane, sparse traffic absorbs the brake; from about a 5 s brake grows into a stop-and-go jam, and from even a 1 s brake does. That tipping point sits at the model's peak flow, about 1,830 cars an hour per lane.

Pick an outcome to load that density and brake duration with the default drivers. The run starts straight away; brake a car to disturb it. Times are simulated; a jam means the slowest car fell below 5 m/s.

About this simulation

The road
The ring stands in for a long stretch of motorway with no junctions, with one to ten lanes. Lane 1 is the inside lane; cars overtake towards the outside and may not pass on the inside while the lane outside them is flowing freely. Road geometry, in Settings, only changes how the loop is drawn; bends do not slow the cars.
Colours and vectors
Cars are coloured by speed to begin with: red at rest, and the same green for anything at 27.8 m/s () or faster. Colour by, under the ride-along view, can instead show live acceleration (red braking, grey steady, green accelerating) or any driver parameter. A parameter's scale runs from the lowest value on the road to the highest, so it only tells cars apart when that parameter varies between drivers. Vectors draws lines from each car, to the road's scale: desired speed and speed ahead of it, as the distance covered in half a second, and acceleration ahead when speeding up or behind when braking. They show in the ride-along view, and on the road once you zoom in far enough for cars to be drawn as cars.
Lane-change lines
The lane changes vector works like an indicator. A full, bright line points the way a car is moving while it changes lane. A shorter, fainter line marks a driver who wants to change and has been held back for at least a second, by safety or by consideration for others, and it lengthens over the next five seconds of waiting. Do not expect the two to match one for one. About half of all changes happen with no wait at all, so no faint line comes first; and most held-back wishes fade without a change, because drivers decide afresh every half second and a small shift in the gaps is enough to change their mind.
Zoom and pan
Scroll or pinch to zoom, drag to pan, or use the buttons above the road. Zoomed in far enough, cars are drawn to scale. Zoomed out, each car becomes a mark across the road, and the marks merge into a band of colour where traffic is dense.
Starting speed
Every run starts with each lane at the speed its drivers settle to at that density, every car at its own steady gap, so nothing happens until something disturbs the flow. With identical drivers that means evenly spaced cars and no reason to change lane until a car brakes. When drivers differ, a lane can go no faster than its slowest driver, and faster drivers soon start looking for a way past.
Drivers who differ
Each driver has their own value of every IDM and MOBIL parameter. To begin with they are all the same. The button beside a parameter's name opens an editor where you choose how it varies: a few fixed values with a share of drivers each, a uniform range, or a normal distribution cut off at the ends of the slider. The picture there shows the shape asked for and a tick for the value each driver would have. The exponent δ takes fixed whole values only. Sliders in the panel apply at once; edits in the editor apply when you press Save. Either way every driver keeps their rank, so the fastest driver stays the fastest. Resample deals the drivers a new set of values from the same distributions: in the editor for one parameter, or with the dice at the top of a parameter box for every parameter in it that varies. All of it is worked out from one seed, which Settings lets you fix so that a run can be repeated. The View/edit selected button under the ride-along view lists the followed driver's own values beside those of the driver ahead. The presets and the two findings below were measured with identical drivers.
Following a car
Click the road to follow the car nearest that spot. It is outlined in blue, and the ride-along view under the road shows it from above with the cars around it in every lane, on the road unrolled straight. Click a car there to follow that one instead. Brake lights come on when a car is slowing. The line under the view gives the followed car's speed and gap, and its driver's own value of any parameter that varies. Settings has the view's zoom: a fixed scale, or one that moves to keep the nearest cars in view.
Braking
Shift+click the road, or press and hold it, to make the one car nearest that spot brake at 2 m/s² for the chosen duration. In the ride-along view, Shift+click a car to brake it, or use the buttons to brake the followed car or the one ahead of it. A car that is already braking keeps whichever end time is later.
Traffic at the speed limit cannot jam with this driver model
Cruising at needs traffic as sparse as about , and at that density disturbances die out: a 10 s brake among 85 cars on faded away. Jams need busy traffic, at around or slower.
Desired speed barely matters in busy traffic
Raising it from 33 to 36 m/s changed little about when jams formed at and denser. There the gaps between cars set the speed, not what the drivers would like to do.
Sliders
Driver sliders take effect immediately, mid-run, without moving any car. Road sliders restart the run. Brake duration applies to the next click.
Run speed and skipping
Run speed stops at 32× because faster than that the display cannot follow the motion: cars appear to crawl or run backwards, as wheels do on film. To jump ahead, the skip buttons run 1, 5 or 10 simulated minutes as fast as the engine can; if a skip takes more than a moment, the button you pressed fills up to show how far it has got, and with the engine in a worker (the default) the page stays usable meanwhile. If the computer cannot keep up with the chosen speed, it runs as fast as it can and the line under the road says what speed it is managing.
Collisions
Extreme driver settings can make cars collide. The run then stops; adjust the sliders and press Reset.

How the statistics are measured

All figures describe the current run and start again from zero on Reset. Simulated time, not real time, throughout.

Lane changes
Counts since the run began. Left is towards lane 1, the inside lane. Per minute is the total divided by the time elapsed, so it is an average over the whole run, not a recent rate.
Per lane change
Each change is scored at the instant it happens, from the IDM accelerations before and after: the changer's own gain, and the summed change for the two cars behind it (the one it left and the one it pulled in front of). The figures shown are running averages over every change in the run. They say how much harder cars accelerate at that moment, not how much speed anyone eventually gains; following the cars for longer would need a run in which the change had not happened.
Cars yielding and mean loss
Each step, every car easing off to let a would-be changer in is counted, together with the acceleration it gives up (what the IDM would have had it do minus what it does). Both are averaged over the last 3 seconds of simulated time, which is why the count can be fractional: 6.2 means about six cars were yielding at any one moment during those 3 seconds. Mean loss is the window's total loss divided by its total count.
Speed given up
The unsmoothed yielding loss integrated over time (loss × step length, summed over the run), across all cars. It is the total speed that cooperation has cost drivers, so it grows for as long as anyone is yielding.
Lanes
Cars in each lane now, with their mean and slowest speed at this instant.
Strip above the road
Instantaneous values, except the lane-change total, which is the run's count.

The Intelligent Driver Model

The IDM (Treiber, Hennecke and Helbing, 2000) is a car-following model. Each driver picks an acceleration from three things: their own speed, the gap to the car ahead, and how fast they are closing on it. Every car applies the same rule, every 0.1 s.

acceleration = a · [ 1 − (v / v₀)δ − (s* / s)² ]
s* = s₀ + max(0, v·T + v·Δv / (2√(a·b)))

The first bracketed term is the urge to reach the desired speed v₀, which fades as v approaches it. The second is the urge to keep a safe gap: s* is the gap the driver wants right now and s is the gap they have. The wanted gap grows with speed (v·T) and with closing speed Δv, so a driver bearing down on a slower car brakes, and brakes harder the faster they close.

Desired speed v₀
Speed on an empty road.
Time gap T
Following distance expressed as time; 1.5 s is a typical real value.
Standstill gap s₀
Gap kept when queuing.
Acceleration a
Maximum acceleration, and how quickly a driver responds in general.
Comfortable braking b
The deceleration drivers aim not to exceed; the model brakes harder when a gap closes too fast.
Exponent δ
How abruptly the urge to accelerate dies away near v₀. 4 is the usual value.

With identical drivers, traffic settles at the speed where the two urges balance for the gap available, which is why density alone sets the cruising speed here. Whether a disturbance then dies out or grows depends on the density and on a, b and T: when drivers respond sluggishly (small a) and gaps are short, a line of cars amplifies each other's braking and a stop-and-go wave forms.

In this demo the dynamic part of s* is clamped at zero, cars cannot reverse, and there is no reaction delay. Drivers are identical until you make a parameter vary between them; a lane of mixed drivers settles at the one speed they can all hold, each at their own gap.

MOBIL lane changes

Lane changes follow MOBIL (Kesting, Treiber and Helbing, 2007), "minimising overall braking induced by lane changes". Every half second a driver asks what acceleration the IDM would give them in the lane beside them. A change is safe if neither they nor the car they would pull in front of would have to brake harder than bsafe. It is worth it if their own gain, plus the politeness share p of what the cars behind them in both lanes lose, exceeds the threshold Δa.

Politeness p
Weight on the braking a change forces on others. 0 is selfish; 1 counts their loss as much as the driver's own gain.
Threshold Δa
Net gain a change must deliver before it is made; it stops cars flipping between lanes for nothing.
Keep-left bias
On a keep-left road the threshold is raised by this for moving out and lowered by it for moving back in, so cars drift back to the inside lane when they can.
Safe braking bsafe
Hardest braking a change may force on the changer or the new follower.
Impatience time τ
Published MOBIL has no memory, and a driver stuck beside fast traffic would wait for ever. Here a driver who would gain from a change but is held back grows impatient: over τ seconds their politeness and threshold fade to nothing and the braking they will impose on others doubles, then keeps growing to at most three times bsafe.
Cooperation
A driver who sees a held-back car wanting in ahead of them eases off as if it were already there, braking no harder than this share of bsafe. With 0 nobody makes room, and a car in a stopped lane can only get out once the traffic beside it has slowed on its own.

A car may not pass a slower car in the lane outside it while that lane is flowing freely (above 60 km/h), as the Highway Code requires; in congested traffic the rule is lifted. Each car waits 4 s between lane changes, a car you have braked does not consider one until it is released, and when two cars want the same gap the one further ahead takes it. When drivers differ, a change is judged by the changer's own values of these parameters, and each affected driver's response by that driver's own IDM values; a driver making room uses their own cooperation.

Parameter

Parameters that differ between drivers are highlighted. Edit how they vary from the parameter boxes.

Settings

Distances

Used for road speeds, densities and road distances. Anything shown in metres or m/s stays as it is.

Engine

Which implementation runs the model: the original TypeScript, or the same model in Rust compiled to WebAssembly. Both give identical runs. Changing it restarts the run.

Where the engine runs

In a worker the page stays responsive while long skips run. Shared memory avoids copying each frame's state but needs the page to be cross-origin isolated. Changing it restarts the run.

Random drivers

Optional. Left empty, each visit uses a new random seed, shown in the box. A seed you type is kept for future visits and always gives the same drivers, resample by resample, so a run can be repeated. Only matters for parameters that vary between drivers. Changing it starts the resampling again from the beginning.

Ride-along zoom

Dynamic zoom moves in and out to keep the followed car's nearest neighbours in view. Otherwise the view holds the zoom set here, zooming out only if the lanes would not fit.

Road geometry

Only changes the drawing. Bends do not slow the cars.