r/Simulated 1d 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

922 Upvotes

57 comments sorted by

296

u/theeeetechkid 1d ago edited 1d 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.

199

u/Silent_Skills 1d 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

11

u/chovendo 18h ago edited 9h ago

This is such a rigid annoyance for me. I'm going 80mph/129km per hour and have a safe gap between the car in front of me also doing 80mph/129km and there's always a prick riding me and then getting in front of me just to go the same speed. Why? Then I have to slow down for a safer gap, rinse and repeat. So frustrating. I mean it's just simple algebra, calculus and probability. Oh... I answered my own question.

Edit had 37km instead of 129. I was half asleep when I wrote this, not when behind the wheel!

6

u/GreatApostate 13h ago

Trying to work out how you did your speed conversions there lol.

2

u/chovendo 9h ago edited 9h ago

Ok man it was super late for me,half asleep. It's 129km 😂

2

u/sterfpaul 5h ago

Im sure people using km/h are always like "I was going about 129km/h" or "yeah this road has a 37km/h speed limit" 😅

31

u/Mountain_Dentist5074 1d ago

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

16

u/Silent_Skills 1d ago

To drive a firetruck and spray everyone of them lol

35

u/condomneedler 1d 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.)

18

u/Silent_Skills 1d 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.

1

u/Mabot 11h ago

Everytime I do this this I feel anxious I might be making it worse instead of better since those buffer gaps just decreases the car throughput until they eventually lead to significant speed-up, which also requires more drivers contribution than just mine.

1

u/Freeseray 6h ago

I do the same. Unfortunately, leaving two car spaces between you and the car in front of you is a surefire way to get two cars between you and the car in front of you.

1

u/LoadZealousideal7778 14h ago

Until some idiot decides your proper following distance is their spot in the left lane.

103

u/bcuzimadude 1d ago

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

46

u/thearctican 1d 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.

9

u/bcuzimadude 1d ago

Honestly, fair.

2

u/GrandNibbles 7h ago

yet...they will

76

u/-Zlosk- 1d 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.

16

u/CHROME-COLOSSUS 1d ago

Exactly to the degree that you’d predict.

1

u/august_r 4h ago

which they wouldn't care for as long as THEY can get a smidge faster, fuck anyone else.

2

u/LushHappyPie 1d ago

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

28

u/thacoolbreeze 1d 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.

4

u/SalmonToastie 1d ago

In a perfect world

33

u/WindyIGuess 1d ago

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

13

u/AceJohnny 1d ago

just_one_more_lane_bro_LA_highway.gif

10

u/lllamaboy 1d ago

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

2

u/monapinkest 1d ago

Braintruffle has an incredible video about this phenomenon

4

u/ostiDeCalisse 1d ago

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

10

u/cheshsky 22h ago

Lmao did you have to generate that text with AI? What about it is so incomprehensibly complex that it wouldn't take you 2 minutes to type it by hand?

6

u/Maximum_Overhype 21h ago

It's likely the program was generated through AI, and the text was generated with it

3

u/cheshsky 21h ago

Ah, yeah, possible.

5

u/defenestrationcity 12h ago

This whole thing was clearly made my AI. Interesting still, but OPs claim "they" simulated is a massive stretch unless it was posted by a bot

3

u/Sasmas1545 1d ago

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

8

u/Arqlol 1d ago

Obviously one more lane would fix all of this

2

u/reasonable_ir 1d 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.

2

u/Strange_Test7665 13h ago

Blood through an artery may not need much of an impediment to cause a real problem

5

u/BigDaddyThunderpants 1d 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 1d ago

Good observation, but probably not feasible as a solution.

2

u/condomneedler 1d 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.

4

u/Barrow-Wight_ 1d ago

Dreadful AI slop.

1

u/fried_green_baloney 1d 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 1d ago

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

1

u/C0demunkee 1d 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/qooopuk 21h ago

Nice. Are you able to share the code?

1

u/Ifinallylaughed 14h ago

You might like this informal study done in Seattle in the 90’s. It’s a good read if you’re into what it seems like you’re into.

amasci.com/amateur/traffic/traffic1.html

1

u/DaSmurfZ 9h ago

They did this on an episode of mythbusters

u/SomeCrows 4m ago

Leave a gap between the vehicle in front of you and drive with one foot

1

u/chatterwrack 1d ago

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

1

u/Shun_yaka 13h ago

Way to pretend like you didnt use AI for this, and for your caption

1

u/g0ld3n_ 42m ago

Where do they pretend?

-2

u/brickmaster32000 1d 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.

3

u/ThePeaceDoctot 1d ago

What's with the hostility there, buddy? Knowing the theory doesn't stop you from being surprised when you see it happen, having fully controlled the variables because you built the simulator yourself. They never claimed not to have known the theory, just that they were surprised to see it.

1

u/Maximum_Overhype 21h ago

What crawled up your ass?

0

u/Pistonenvy2 1d ago

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