Assignment

Agent-Based Traffic

You now have the core ingredients of an agent-based traffic model: local update rules, a reproducible simulator, a space-time diagram, and macroscopic observables such as density and flow (Nagel and Schreckenberg 1992; Wilensky and Rand 2015).

You can follow the guide here:

Traffic Model Flow and Congestion

Summary of Goals

Your submission should show that you can do three things:

  1. Build a correct agent-based traffic simulator.
  2. Connect microscopic update rules with macroscopic observables.
  3. Explain when and why congestion appears.
Submission

Submit two files:

  1. Code that reproduces all figures and metrics.
  2. A short report, 1 to 2 pages, that summarizes your experiments and interpretation.

Required

  1. Implement initialize_road(), step(), and simulate() for the Nagel-Schreckenberg model.
  2. Produce space-time diagrams for at least three densities, one low-density regime, one intermediate regime, and one congested regime.
  3. Estimate the fundamental diagram \(q(\rho)\) using at least 10 density values and a burn-in period before you average the flow.
  4. Compare the flow-density curve for at least two values of p_slow.
  5. Write a short discussion of where the maximum flow occurs and how the onset of congestion changes when p_slow increases.

Short Discussion

Include a brief paragraph that answers these questions:

  1. At what density does free flow begin to break down in your experiments?
  2. Does higher random slowdown mostly change the peak flow, the jam onset, or both?
  3. Which figure best explains the transition from microscopic rules to macroscopic congestion?

Optional Extensions

  • Add sliders for density, p_slow, or vmax.
  • Compare random initial conditions with a localized dense cluster of cars.
  • Introduce a small fraction of slow vehicles and study the effect on the flow curve.
  • Replace the periodic road by open boundaries with inflow and outflow.

Tips for Success

  • Test one update step on a short road before you launch long runs.
  • Fix the seed when you debug.
  • Discard an initial burn-in window when you estimate stationary flow.
  • Keep the plotting code separate from the simulation code so repeated experiments stay simple.
Tip

Reference code is available in amlab/cellular_automata/traffic.py.

Good luck.

References

Nagel, Kai, and Michael Schreckenberg. 1992. “A Cellular Automaton Model for Freeway Traffic.” Journal de Physique I 2 (12): 2221–29. https://doi.org/10.1051/jp1:1992277.
Wilensky, Uri, and William Rand. 2015. An Introduction to Agent-Based Modeling: Modeling Natural, Social, and Engineered Complex Systems with NetLogo. MIT Press.