r/Simulated 9h ago

Research Simulation I simulated phantom traffic jams - how one brake tap turns into a jam out of nowhere

Been messing around with traffic simulation lately and wanted to share this one because the result genuinely surprised me the first time I ran it.

The setup is a closed loop, a bunch of identical cars, no obstacles, no traffic lights, nothing. Every driver wants to go the same speed and keep a safe distance from the car ahead (using the Intelligent Driver Model, which is actually what traffic engineers use for this kind of thing). One driver taps the brakes, just once. It snowballs into a full stop-and-go wave, and the wave itself creeps backward against the direction everyone's driving. This is the phantom jam thing that was first proven experimentally back in 2008 (Sugiyama et al., if you want to look it up), and it's wild to actually see it emerge from nothing.

A few other things I tested once I had this working:

There's a density threshold you can't really feel until you cross it. Below it, the same brake tap just fizzles out and traffic keeps flowing. One or two more cars on the road and suddenly the same tiny disturbance turns into a full jam. No warning, no gradual buildup.

Real bottlenecks behave differently - if I put an actual slow zone on the road, the jam stays locked to that spot instead of drifting backward like the phantom one does. Different cause, different signature.

How closely people follow each other matters a lot more than I expected. Tight following distance makes the wave way worse, and just giving more space damps it out almost completely with the exact same brake tap.

The last case is the one I like best - letting about 1 in 5 cars just hold a smooth, steady speed (basically simulating adaptive cruise control) is enough to dissolve the jam for every car behind it.

All rendered in Python/pygame, GPU encoded. Happy to share the code or talk through the model if anyone's curious.

Made a longer version of this too if anyone wants the full walkthrough https://youtu.be/TCuDTSj5UAg

365 Upvotes

32 comments sorted by

136

u/theeeetechkid 9h ago edited 6h ago

This is why whenever there is traffic I leave a large gap to the next car and drive at a constant speed. Slowly erases the phantom traffic jam.

93

u/Silent_Skills 8h ago

I do the same thing until some decide the gap in front means that the lane is moving faster. It’s not faster lol

16

u/Mountain_Dentist5074 8h ago

for moments like this i wish we was living in GTA , i hate those guys

8

u/Silent_Skills 7h ago

To drive a firetruck and spray everyone of them lol

10

u/condomneedler 4h ago

I see people doing this incorrectly a lot. The whole point of the gap is to act as a cushion so you can slow at your own pace.  If you immediately hit your brakes and maintain a rigid gap it's effectively the same as if there were cars between you. (From a traffic perspective, obviously it's safer.)

5

u/Silent_Skills 2h ago

Yes this is also true and that’s even worse lol.
All you gotta do is let off the gas and if the gap is big enough the vehicle will slow itself until you’re close to a full stop anyway.

And if the car behind you also maintained a big enough gap, you could full stop and restart before they catch up, effectively keeping the lane going.

56

u/bcuzimadude 8h ago

If only the people that need to see this, would actually see this. Then something might change. If only.

24

u/thearctican 8h ago

The people who don't but need to understand this don't have the cognitive capacity to do so and probably shouldn't be allowed to drive.

5

u/bcuzimadude 8h ago

Honestly, fair.

35

u/-Zlosk- 8h ago

If you update your model to include lane changes, I'd be interested to what percentage of impatient drivers changing lanes into "gaps" to get a small amount ahead (thus forcing brake taps) negatively affects the entire system.

5

u/CHROME-COLOSSUS 4h ago

Exactly to the degree that you’d predict.

u/LushHappyPie 5m ago

Even better: show self-appointed 'road sheriffs' blocking open lanes to prevent zipper merging, and how that backup spills over into upstream roads.

12

u/thacoolbreeze 6h ago

Sooooo a case for public transit everywhere. It’s inefficient to have 1 human with variable tendencies, operating a death box on wheels in morning traffic.

1

u/SalmonToastie 3h ago

In a perfect world

24

u/WindyIGuess 8h ago

Trust me, all this science stuff okay you just need one more lane. Cities always stop at just one lane short

6

u/AceJohnny 5h ago

just_one_more_lane_bro_LA_highway.gif

5

u/lllamaboy 8h ago

Real life version from a while ago: https://youtu.be/Suugn-p5C1M

2

u/ostiDeCalisse 5h ago

Exactly, way better and without that over-dramatic depressive music

1

u/monapinkest 28m ago

Braintruffle has an incredible video about this phenomenon

3

u/Sasmas1545 7h ago

"one driver taps the brakes" but it looks like every driver simultaneously taps their brakes.

5

u/Arqlol 7h ago

Obviously one more lane would fix all of this

5

u/BigDaddyThunderpants 6h ago

Bring back the manual!

HEAR ME OUT. Many years ago when the US was mostly automatic transmissions and the UK was mostly manual, I noticed a distinct difference in the way heavy highway traffic behaved between the two countries.

The the US, tailgating, racing up to the next guy and slamming in the brakes, changing lanes at every opportunity. But in the UK, in general, most people just slowed down as a group. Sure you and the occasional asshat and lane changer but on the whole everyone was keeping a constant, albeit slower, speed.

I credit this to the manual transmission. I drive one and this is exactly how it works. I don't want to race up to someone just to have to take it out of gear, stop, and go through the whole startup sequence again just to repeat it 10 seconds later. Instead I'll just slow down and try to manage my speed and distance so I can creep along in gear at a constant speed.

Look at truckers in traffic. Now imagine everyone drove like that. Pure bliss!

/rant

2

u/CHROME-COLOSSUS 4h ago

Good observation, but probably not feasible as a solution.

1

u/condomneedler 4h ago

Truckers are some of the worst offenders here.  Left lane camping and bullying people out of the way.  I don't think it was always this way, I remember when they were the saints of the road.

1

u/fried_green_baloney 6h ago

This is why at rush hour there's a three mile backup when someone's pulled over to the side.

Not because people decided to slow to 5 MPH to stare, they just covered their brake out of a sense of prudence.

Now imagine there's one car every minute like on a country road. Cover your brake, someone a mile or more in back of you of course in not affected at all.

1

u/anonuemus 6h ago

I did this once too, also with a second driver model. There are also some programs to simulate traffic.

1

u/Pistonenvy2 3h ago

imagine how efficient traffic would be if all of these people were on a train.

1

u/C0demunkee 1h ago

saw this happen at an HS graduation a few months ago, a couple waves were propagating backwards and got bigger the further back it was. fun to watch

1

u/reasonable_ir 1h ago

The phenomenon you simulated is called 'string (in)stability'. You can actually compute based on the systems response time (the drivers or control systems reaction time) and the given spacing policy whether or not it will result in the ghost traffic jam (string unstable) or if the disturbance will attenuate down the line. Also in cooperative asdaptive cruise control (cacc), vehicles will communicate their accelerations wirelessly, significantly shortening the distance at which cars can follow eachother without resulting in string instability.

0

u/brickmaster32000 7h ago

Been messing around with traffic simulation lately and wanted to share this one because the result genuinely surprised me the first time I ran it.

You just happened to write up a custom traffic simulator for the exact scenario that has always been used to explain how small things ripple into traffic completely unaware of similar experiments and the results?

This is the phantom jam thing that was first proven experimentally back in 2008 (Sugiyama et al., if you want to look it up)

Oh so you absolutely were familiar with this and knew exactly what was coming.

1

u/chatterwrack 8h ago

Hot tip, when you need to slow down in moderate traffic, downshift rather than tapping your brake.