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:
- Build a correct agent-based traffic simulator.
- Connect microscopic update rules with macroscopic observables.
- Explain when and why congestion appears.
Submission
Submit two files:
- Code that reproduces all figures and metrics.
- A short report, 1 to 2 pages, that summarizes your experiments and interpretation.
Required
- Implement
initialize_road(),step(), andsimulate()for the Nagel-Schreckenberg model. - Produce space-time diagrams for at least three densities, one low-density regime, one intermediate regime, and one congested regime.
- Estimate the fundamental diagram \(q(\rho)\) using at least 10 density values and a burn-in period before you average the flow.
- Compare the flow-density curve for at least two values of
p_slow. - Write a short discussion of where the maximum flow occurs and how the onset of congestion changes when
p_slowincreases.
Short Discussion
Include a brief paragraph that answers these questions:
- At what density does free flow begin to break down in your experiments?
- Does higher random slowdown mostly change the peak flow, the jam onset, or both?
- Which figure best explains the transition from microscopic rules to macroscopic congestion?
Optional Extensions
- Add sliders for density,
p_slow, orvmax. - 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.