Simulating Stopping Traffic Waves with Autonomous Vehicles
Apr 11, 2026
5 minute read

Can autonomous vehicles help reduce traffic jams by stopping traffic waves?

Inspired by a thought from a coworker who had heard of this before, and to practice more LLM development, I ran some simulations based on Stern et al’s 2018 paper: Dissipation of stop-and-go waves via control of autonomous vehicles: Field experiments. I attempted to replicate the results in simulation and extend to 3 lanes of traffic with drivers changing lanes.

Almost all of this (apart from this blog post) was vibe coded, the base prompt is Anthropic’s web-artifact-builder skill.

Trying it yourself

Source code is on github, and you can play with the simulation interactively below to see if it makes a difference, or press “AV Impact Analysis” to get a full sweep of relative jam impact vs AV fraction.

Hint: Try a medium-high density (~40 cars/km), and no AVs vs 5% AVs, with the PI controller. With no AVs, the standing wave ends up being fairly continuous, while with 5% AVs it gets dissipated. You can see the AVs start moving back before the wave hits them as well.

Learnings about Traffic

Warning: I haven’t hand checked the maths or code, and overall I’m not that happy with trusting these results, I don’t think I understand them well or have good intuition enough to catch bugs other than asking the LLM “are you sure” a lot. It feels quite likely some different tuning parameters or more realistic driver behavior (e.g. slowing when adjacent lanes slow) would give a completely different result. The 3 lane simulation in particular is suspect as there is no ground truth to check it against.

A main finding was that a single lane experiment (as done by Stern) is the ideal scenario, the gap added by the AVs stops the red wave of stalled traffic.

Without AVs
With AVs

When you have multiple lanes you have merging into the “gap” an AV leaves to stop the wave, which reduces the effectiveness (86% vs 30% on standard speed deviation at high density traffic, and 60 cars/km).

Any real world implementation is also going to be limited by the lack of V2V comms preventing autonomous vehicles seeing that far ahead.

There’s a more detailed (and AI generated) report that gives a fair bit more detail, some nice graphs, and citations, but I certainly wouldn’t trust that to be correct either!

Learnings about AI / Artifacts

My learnings were (expectedly) the importance of good tests, having an oracle (so many bugs were found after forcing the model to check a simulation vs stern’s results) and the unreasonable seeming complexity of web development, I can’t believe how many build steps and config files I’ve ended up with. If I did it again I would probably push for a simpler base prompt to reduce the codebase complexity, e.g. Simon Williamson just uses vanilla html/js/css. It also got a bit tricky merging the “style” after only deciding later to put this into my blog, it’s not as elegantly cascading as the dream of CSS suggests, especially if you want to have dark/light mode switching.

Frequently switching between agents and command line tools a lot also made it important to write more context down, e.g. I have lost the code to some of the graphs, as the agent just ran it directly rather than saved it to disk first. The short (270K tok) context window of Z.AI’s GLM-5.1 hasn’t helped with this.

This was also quite expensive to run for a “I wonder if” type experiment, I reckon about $20 worth split between copilot usage and openrouter credits, and at least 3-4 hours of prompting (while watching The Pitt). Better model choice and judgement on how much guidance to give and when could have probably helped with this, as would have sitting down and understanding the literature myself first.

How does this compare to the real world literature?

This simulation does roughly match (according to the automated tests) the results of the 2018 Stern Experiment, but matching more complex field experiments looks hard, as the experiments were both less conclusive and more complex in implementation.

The MegaVanderTest was carried out in 2022 with 100 AVs on the 4 mile long I-24 motion testbed, with preliminary results a bit inconclusive as to if it helped overall.

Overall, although getting precise measurements from a large amount of camera video data is complicated, we observe a trend of 15 to 20% of energy savings around our controlled cars.

and a good overview summary of the entire field from Feb 2025 states full results are yet to be published.

The plot also confirms the expectation that the control vehicles were at too low a penetration rate to completely remove traffic waves, but upcoming publications will reveal whether the CAVs reduced the magnitudes of the waves.

The data from MegaVanderTest is freely available, but very complex due to the huge number of vehicles, and “matching” a relatively small result that even the original study authors can’t clearly see is likely to be quite difficult difficult.

In addition, more complex field experiments use much more complex algorithms to avoid problems like “resonance” between AVs, so any simulation that tried to replicate these real world results would also need to implement these. The controllers here in this simulation are just very basic “leave a gap” from trafficwaves.org and the PI control vs average speed of Stern (but limited to seeing a fixed number of vehicles ahead, instead of omniscience).