Ring-Road Traffic Simulation

Cars drive around a circular track using the Intelligent Driver Model (IDM) of Martin Treiber and co-authors. Even without obstacles, small perturbations grow into stop-and-go waves — the classic Sugiyama experiment.

Enable the Driver noise slider to add stochastic acceleration error and compare three stochastic car-following models: white noise (B-IDM), a Gaussian-process kernel from Zhang & Sun (2024), MA-IDM, and an autoregressive process from Zhang, Wang & Sun (2024), dynamic-regression IDM.

Live traffic diagnostics speed, flow, density and the fundamental diagram

Average speed (m/s)

Flow (cars / hr, region)

Density (cars / km, region)

Fundamental diagram (flow vs density)

The line is the measuring arc's time trajectory, so its loops are real loading/unloading cycles. The faint dots are four spatial sub-bins sampled at the same instants — a cross-section, deliberately left unconnected.

Time–space diagram (time →, position ↑; colour = local speed)

Frequently asked questions

What is traffic-sim?

traffic-sim is a free, open-source simulator that runs the Intelligent Driver Model on a one-lane circular road entirely in your browser. You set the traffic density, the IDM parameters and the driver-noise model, then watch whether the ring settles into uniform flow or breaks into stop-and-go waves. There is nothing to install, and no data leaves your machine.

Why do traffic jams form on a ring road with no bottleneck?

Because dense car-following is unstable. Each driver reacts to the car ahead with a delay and with imperfect precision, so a small speed fluctuation is amplified rather than damped as it travels back through the queue. Past a critical density the amplification wins and the disturbance grows into a stopped cluster that moves backwards against the traffic — a phantom jam. Sugiyama and colleagues demonstrated exactly this with real drivers on a real circular track in 2008. Press Perturb to seed one here.

What is the Intelligent Driver Model (IDM)?

The IDM is a microscopic car-following model published by Treiber, Hennecke and Helbing in 2000. It gives every vehicle a continuous acceleration derived from only its own speed, the gap to the vehicle ahead and the rate of approach, using five interpretable parameters: desired speed v₀, safe time headway T, minimum gap s₀, maximum acceleration a and comfortable braking b. It is collision-free by construction and is the standard deterministic baseline in traffic-flow research. The models page gives the equations.

What is driver noise, and why does its colour matter?

Driver noise is the acceleration residual that is left over after a deterministic model has been fitted to a real trajectory — everything the equation does not explain. Measured on HighD data that residual has a standard deviation of roughly 0.2 m/s² and stays correlated for several seconds, so it is not white noise. The colour matters because a car-following chain behaves like a low-pass amplifier: white noise is mostly high-frequency jitter that averages out along the platoon, whereas correlated noise puts the same variance into the low frequencies the chain amplifies into jams.

What is the difference between MA-IDM, DR-IDM and B-IDM?

All three add a random residual to the same IDM acceleration and differ only in the process that generates it. B-IDM uses independent Gaussian noise with no memory. DR-IDM uses an AR(p) process, so the residual is a weighted sum of its own recent past plus a fresh innovation. MA-IDM uses a Gaussian process with a stationary kernel, so memory is governed smoothly by a lengthscale of about 1.4 s rather than by a fixed number of lags. The compare page runs all three side-by-side on identical rings.

Can I reproduce or share an exact run?

Yes. The Copy link button writes every control into the URL fragment, so the link reopens the simulator with the same scenario. Add seed=<integer> (non-zero) to that URL and the random-number stream is seeded as well, which makes the run reproducible bit for bit.

Does this reproduce the results in the papers?

No, and it is not meant to. It is a research-inspired teaching demo. Every driver here shares one parameter vector, whereas both papers’ ring experiments draw heterogeneous per-driver parameters from a joint posterior that was never published. Integration is semi-implicit Euler rather than the papers’ ballistic update, the Gaussian process is approximated with 32 random Fourier features instead of conditional Gaussian sampling, and flow is computed as density × space-mean speed rather than from detector crossings. The README lists every deviation.

What do I need to run it?

Any modern browser with JavaScript and HTML5 canvas. There is no build step, no framework and no dependency — the simulator is a handful of plain JavaScript files. You can also clone the repository and open index.html straight from disk, or serve the folder with python -m http.server.

How should I cite it?

Cite the two underlying papers — the BibTeX is in the Citation card above, and CITATION.cff in the repository carries the same metadata in machine-readable form: Zhang & Sun (2024), Bayesian Calibration of the Intelligent Driver Model, IEEE T-ITS, doi:10.1109/TITS.2024.3354102; and Zhang, Wang & Sun (2024), Calibrating Car-Following Models via Bayesian Dynamic Regression, Transportation Research Part C, doi:10.1016/j.trc.2024.104719.

Reproduce a published ring-road scenario in traffic-sim

  1. Load the preset. Open the Scenario panel and choose a preset — for example "MA-IDM ring — calibrated θ (Fig. 10b)". The ring geometry, vehicle count, initial speed and time step jump to the values both papers state: a 128 m radius, 37 vehicles, 11.6 m/s and Δt = 0.2 s.
  2. Leave the IDM sliders alone. The preset has already loaded that paper’s calibrated parameter vector θ. Moving any IDM slider drops the scenario back to Custom, so change them only when you mean to depart from the paper.
  3. Pin the random stream. Press Copy link, paste the URL into the address bar, append &seed=1 to the fragment and reload. The noise is now drawn from a seeded generator and the run is reproducible bit for bit.
  4. Watch the time–space diagram. Raise Sim speed to 5–10× and let the ring evolve. Diagonal bands running backwards across the time–space diagram are stop-and-go waves; the fundamental diagram loops as each wave crosses the measuring arc.

Author & contact

Chengyuan Zhang
Department of Civil Engineering
McGill University, Montreal, Canada

Citation

If this simulator is useful in your work, please cite the underlying papers:

  1. Zhang, C., & Sun, L. (2024). Bayesian Calibration of the Intelligent Driver Model. IEEE Transactions on Intelligent Transportation Systems. doi:10.1109/TITS.2024.3354102 [arXiv:2210.03571]
  2. Zhang, C., Wang, W., & Sun, L. (2024). Calibrating Car-Following Models via Bayesian Dynamic Regression. Transportation Research Part C: Emerging Technologies, 104719. doi:10.1016/j.trc.2024.104719 [arXiv:2307.03340]
BibTeX
@article{zhang2024maidm,
  title   = {Bayesian Calibration of the Intelligent Driver Model},
  author  = {Zhang, Chengyuan and Sun, Lijun},
  journal = {IEEE Transactions on Intelligent Transportation Systems},
  year    = {2024},
  doi     = {10.1109/TITS.2024.3354102}
}

@article{zhang2024dynamicidm,
  title   = {Calibrating Car-Following Models via Bayesian Dynamic Regression},
  author  = {Zhang, Chengyuan and Wang, Wenshuo and Sun, Lijun},
  journal = {Transportation Research Part C: Emerging Technologies},
  year    = {2024},
  pages   = {104719},
  doi     = {10.1016/j.trc.2024.104719}
}