Hacker News new | past | comments | ask | show | jobs | submit login
Traffic Simulator (traffic-simulation.de)
372 points by ohjeez on Feb 13, 2022 | hide | past | favorite | 85 comments



One thing that really annoys me is "elephant racing" where trucks battle to overtake at very small relative speeds (probably because they're both on their limiters but one has a slight calibration advantage). Especially on 2 lane roads where they block everyone while doing so.

Say a truck has a length of 16m, and starts the overtake 10m behind another one, and merges back in 10m in front. So that's an overtake distance of 36m. At 1mph relative speed, this takes 80 seconds.

Meanwhile, the cars behind the truck have all had to drop out of cruise and are now doing 10mph under their preferred speed (car speed limit is 70, lorries are 60). So that 80 seconds and 10mph under is 10 seconds of overall journey time. Not enormous, but it multiplies across all the cars in the queue, and across the number of lorries making this move in a journey.

However, the point is that if the overtaken lorry could just ease off the throttle by a single mph, he'd halve the overtake time, at a cost to himself of 1mph less for 40 seconds, which is less than a second of journey time.

So, when overtaken, a very minor "altruistic" gesture on the part of the shower lorry pays back dozens or hundreds of times over to other road users. And that's without considering the travelling waves that linger after dozens of cars slow down from a rolling roadblock and can make the whole road slower for everyone for a long time.


> probably because they're both on their limiters

I suspect this happens less often than people think. Most elephant races are up hills and are at speeds significantly under the demonstrated maximum of the truck on level ground. I routinely get passed by tractor/trailers when I'm doing 65mph in the right lane of the freeway with my travel trailer. Even a slight incline and I end up blowing right past them.

My guess is that two fully loaded trucks just have a similar maximum speed in a given power-limited situation, and when combined with the natural desire to not give up even 1 mph of hard-won kinetic energy, we end up with elephant races.


> I suspect this happens less often than people think.

depends what you think is "less often than people think", plus you need to put it in country context.

In Poland it is a real problem. On the distance o 100 km (60 miles) it can happen 3-4 times. If you travel for 300 km it means you will be swearing 10 times when stuck in a line after some lorry.


My read of your parent's comment was that elephant racing due to speed limiters happens less often than people think... Not the races themselves.


Depends on the country I guess. In Poland there is really no other reason than slight differences between speed limtliters callibration (+-2kph). No uphills on Polish highways, no other variables, just that one. 2 minutes of trucks overtaking each other on 2-lane is still very common view even though there are more and more places when overtaking is explicitly prohibited for trucks only to prevent these situations from happening in critical areas.

Also the speed difference is much higher on Polish highways because cars can legally go as fast as 140kph while upper limit for trucks is 90kph. This is a huge difference, lots of brakes to burn before you slow down to match that speed.


Elephant racing could have the unintended benefit of reducing accidents (and their severity) by slightly lowering the overall speed of traffic.

If elephant racing very occasionally prevents an accident due to slower speeds, it might benefit all road users as they don't have to pull over for emergency vehicles, and don't have to wait for debris to clear.


What I see is definitely more dangerous. Cars stack up in the passing lane behind the passing truck. Impatient people then jump into the empty slow lane to pass the line of cars on the right, then merge greedily cutting in front of the line, making the whole situation worse.


So drop the limit to 60 for everyone?


Low limit for everyone leads to more accidents - drivers watch speed and try to race between speedcameras instead of riding through quickly but safely.


Right: even with current limits, I spend a completely unreasonable amount of time glancing at the speedo, worrying about if I'm going over the limit and trying to shepherd the speed within the limit, rather than paying more attention to the traffic conditions around me. This is actually much worse on 20 roads that are converted from 30s by just swapping the signs: they were specifically designed for higher speed, so it's a constant, conscious effort to keep the speedo in mind and sight and carefully not drive to the road.

I feel that this is something people didn't have to do so much: with an analogue speedo, you can't really see your speed to 2 sig figs while driving, with a digital one, you know if you're at 20 or 23 (after your car speedo error, obviously). The implication is that it previously wasn't so important to drivers.


Unlikely. I think 10%+ changes in speed are much more dangerous than a 1% higher speed overall.


Dense traffic is less safe than loose traffic. Having a dense traffic flow behind the blockage is going to negate any wishful thinking improvement you get by reducing traffic speed by 10%.


> Dense traffic is less safe than loose traffic.

It's not that simple. According to [1] the relationship is U-shaped, with the least accidents per million miles driven occurring at about 1500 vehicles per hour. Less traffic increased accidents number, more traffic decreased accidents number but increased average number of cars in each accident. The sweet spot was in the middle.

Additionally after a certain traffic threshold accidents stop being deadly (because of slow speed).

But the results varied depending on road types, countries, time resolution of data and weather conditions.

[1] https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6766193/


I don't think the reduction in speed from 70 to 60 is as significant as bunching cars from 10+ seconds gap to 2, or less for BMWs.


Breaking distance and collision energy scale with square of the speed. So reduction from 70 to 60 is 27% reduction.

Also minimal safe distance is 3 seconds at your current speed. If you can't keep that distance because of traffic - you should slow way down, not to 60 km/h but much lower. So either your comparison isn't fair or the person doing 60 km/h with 2 seconds of gap is the reason the road is unsafe, not the traffic.


Two seconds is a very standard rule of thumb. https://en.m.wikipedia.org/wiki/Two-second_rule

And if you've ever actually encountered a queue behind a slow vehicle, you'll know that leaving too much of a gap will cause undertaking luxury German cars to magnetically be sucked into it (no fault if their drivers of course, its all done in the engine control software I hear), suddenly leaving you with 1 second of gap, until you can ease off and grow the gap gently without having the car behind you pile into your rear end.

Either way, the separation in free traffic is hugely greater than in any queue.


I totally agree with the elephant racing. If we saw traffic as team-play, things would be much easier.

A similar case, more frequent case here in a touristic place with single-lane routes is lines of vehicles right after each other, that don't know how to overtake the one before, but neither leave space in between so someone else _can_ overtake them.

In a complicated mountain road, I _may_ be able to overtake a truck once in a while (depending on incoming traffic, turns, and going uphill/downhill) - but the effort required to overtake 2, 3 or more vehicles at a time is almost impossible.


It's actually 52 m. The cab of the overtaking truck has to clear both the truck it's overaking and place itself one full length ahead.


I can't remember the last time I saw a truck have at least one full length of space in front of them, except when there's basically no traffic at all. They're usually one to one and a half car lengths apart.


While I agree with your overall point, I think there's even lower hanging fruit that's still not picked up.

In France, at least, when there are more than two lanes, basically no one drives on the rightmost lane.

Yes, I know about the traffic law requiring staying in your lane if there is dense traffic. I'm specifically talking about the case when there is little to no traffic.


That's a huge issue too in the UK, especially on three lane roads and wider, where you can just sit in lane two forever, if your skin is thick enough, and everyone will just have to over- and under-take you.

It's actually been illegal for some years and can get you a £100 fine, though I don't know if that's ever actually happened: you'd have to have the bad luck to encounter traffic police who do anything other than speed-gun free-flowing motorways from bridges.


Or the overtaking truck could just go faster to match the speed of the lane it's getting into.

It doesn't matter what you're driving, if you're getting into a flow that's going faster than you are you are either going to force it to slow down or cause a crash, depending on how much space is in front of whoever you choose to cut off.

I'll generally cut the trucks some slack because it's not like they can gain 10-15mph at the drop of a hat but when car drivers do it it's impolite and amounts to a big middle finger to everyone else.


The parent comment suggested that both trucks were going as fast as their engine control would allow.


Commercial trucks usually have speed limiters.


I guess it depends on the country. Here in the US trucks don't have limiters.


In the US, speed limiters have been required on heavy-duty trucks since model years in the early 90s (1992 I think). They are not required to be set to a speed matching the prevailing highway speed limit, but the overwhelming majority of fleet has them.


They do if they want to cross the border into Ontario or Quebec.


Aren't these elephant races deliberate traffic shaping by the truckers? I think I heard that somewhere.


This is delightful! As someone with urban planning background, my friends often stubbornly bring up in the conversation that "why doesn't the city just build more lanes on the roads?". I have to explain how that's not how it works and the more lanes cause more turbulence.

You can try it with this! In one of the road scenarios make lots of lanes. Then give the system a "shock". I.e. move one of the sliders until you cause a traffic, then move it back. See how long it takes for it to clear up. The problem is that cars start changing lanes and cause mayhem. Lots of failure of this kind in the USA.


If you let the system play and then just change the politeness so that many cars switch lanes you create turbulence and the average speed drops down. I found it very interesting to see.


There are lots of options like express lanes or secondary roads.

On the other hand hitting Georgia on 95 south really shows the advantage of adding a third lane. Hard to argue with that example.


It shows the short term advantages of adding a lane. It pays no mind to what sort of development the new, higher traffic flow will bring, and how that will eventually doom that third lane addition to be just as congested as before. The solution isn’t adding more capacity to roads, it’s getting more people and things off the roads and onto alternative means of transportation.


Make alternative means better (chiefly faster or overall cheaper) and people will adopt them. People might not all be geniuses, but they’re not stupid.


Add the externalities to the cost of transport and then you can discuss the cost


Corollary: when people can’t see the externalities, they reach decisions that logically ignore them.


You're assuming that satisfying demand is not a good. You're also arguing that we should wear a hair-shirt until the rapture. (If the alternatives can't compete with relatively good traffic, if they're only used when nothing else works, how good are they.)


> On the other hand hitting Georgia on 95 south really shows the advantage of adding a third lane. Hard to argue with that example.

Road widening projects are usually pretty easy to argue against, though winning these arguments is usually based on emotions and political clout and not an actual rational perspective.

A couple questions that are always good to ask is:

1) When the road was built or last expanded, was it clogged with drivers right away?

2) Does the extension narrow back to fewer lanes at some point?

Give any road extension a couple of years and drivers will be asking for an additional lane on that same road, and/or you’ll be moving the target to the next ‘bottleneck’ down the line.


So why have two lanes over 1 lane? If you have two roads merging for a few miles then splitting, going to one lane will cause a bottleneck

Obviously there is a point where an extra lane is useful and a point where dropping a lane is useful.

Other questions you ask - when the road was built did traffic in nearby roads drop, did you get fewer cars rat-running through residential areas, is the increased traffic because of closure of rat runs making travel in the congested freeway more attractive despite the lack of capacity.

There’s other long term questions too, did the freeway allow people to live further from their destination, encourage longer or more frequent journeys, although the answer to that could be positive or negative depending on your viewpoint. Eventually you get to asking “is the motor car a good thing or a bad thing”.


That would be another instance of the Braess paradox (https://en.wikipedia.org/wiki/Braess%27s_paradox#Traffic), correct?


I haven't heard about more Lanes causing more turbulence, but I would bet on it at face value.

The main argument for not widening roads is that it creates induced-demand for more traffic on general, which doesn't solve your problem.


Braess's paradox?


This is unintuitive and quite interesting. Whats your background?


> urban planning background

He just said it.

The argument that I usually hear against more lanes is induced demand, but when I looked at some of the data this problem was very overblown. Going from 2 -> 3 or 3 -> 4. This is quite different from increasing 5 lanes to 6 though, then I can imagine it becomes chaotic and other problems such as the ones mentioned start to dominate.


Well, the fixed parameter is people's tolerance for driving time. Everything else (including number of users) will scale up practically indefinitely.

So if you give people more capacity, they will use it until they're back to their trip time tolerance, which is roughly at the same level of congestion.

Is that not the case?


It is, in the case where roads are free to use.

Price is an extremely effective means of restoring flow to a congested system. Usually, how this works out is that a toll is placed on, say, an existing bridge to finance a parallel or upgraded replacement, and then magically traffic tends to disappear to the point where the new span is no longer needed.

Of course, tolling untolled roads is extremely unpopular.


>Price is an extremely effective means of restoring flow to a congested system.

That's like saying famine is a great way of dealing with overpopulation.

You're fundamentally taking a small subgroup (the trips that are justified despite the increased cost) and saying "look how good things are for them" while completely ignoring everything not in that subgroup. By that same (asinine) logic the SF housing market is great for homeowners.

At best toll roads function as fuzzy rationing (and that isn't great either) where the masses only take the most critical trips.


Roads don’t come for free, and user fees are a very widely used method of paying for them.

Some of the trips brought on by induced demand is just shuffling around of economic activity that would’ve happened elsewhere.

———

You may not like that tolls can re-establish speeds on congested roads, but every solution has drawbacks, including building more free roads.


Right, of course! Price is a fantastic general way to reduce demand for limited resources so it matches supply.

(It's also a great way to ensure the rich get richer, but that doesn't detract from your point.)


No, because the limit isn't driving time, it is things they wany to do. Induced demand is people who can finally do something better. The only time you are right is when you are so far behind that people who used to stay home pick a second best thing because what they really want still isn't in their time tolerance.

Note that building roads is in general not the rigjt answer, build good transit so they don't drive is much cheaper in the long run.


As an addendum:

Induced demand happens in all types of transportation, but cars are so space inefficient relative to other modes that it does not take a whole lot to get back to where you started, whereas the same cannot really be said of say a subway.


I wish we could put the induced demand idea to bed. There are a finite number of people so eventually more roads will help.

There are a certain class of ideas that make people feel superior in conversation so they just stick around no matter how true.


People are not finite. They change addresses, have kids, get different jobs, etc. The flows of people shift around over time, and the transportation infrastructure is one factor that influences those flow patterns.


“Eventually” = all pavable land is dedicated to roads or parking

I feel superior because I also have an urban planning background, and I’ve literally done the reading on this.


I don't take issue with the concept of induced demand but when people trot it out like it's a bad thing and is a reason not to build something it makes me want to buy a bulldozer and a welder and pay them a house call.

Trips are a good thing. They're economic activity. They're people going to visit friends/family. Each trip is a case where the benefit outweighed the cost of the trip.

The really infuriating part is that 99.999% (yes, 5 9s) of people who complain about induced demand on roads talk about it like it's a good thing when the context is literally any other form of infrastructure. You can induce demand for parks and subways by carpet bombing a city with them too or making the existing ones more attractive. The concept isn't just for public infrastructure. All sorts of business can induce a lot of demand if you plop it down in the right spot where a lot of potential customers were letting the need go unfilled because the opportunity cost of the next existing best option was too high.


> Trips are a good thing. They're economic activity.

Spoken like a true capitalist. Not all "economic activity" is good.

Sitting in traffic driving to an out-of-town shopping centre to buy groceries because there are no local shops in walking distance may be economic activity, but I'd struggle to call these boring, wasteful trips I'm forced to make a good thing. More like an irritating waste of time and gas.


If people's local options didn't suck they wouldn't travel. Time isn't free, nobody gets more of it and people love convenience.

The fact that the local grocer has to compete with the out of town grocer may be derided by the whole foods crowd but it's a boon for the price sensitive masses.

If the local grocer doesn't exist then why? It's either going to boil down to the population density not supporting it or local regulatory oddities making the business economically non-viable.


Often times I feel like every HN comment is just restating the is-ought problem but with $TECH or $MONEY jargon. This is another one of those times.


I have a neighborhood grocer in easy walking distance. The best way I could describe it is “imagine a tiny Whole Foods, except more expensive”.

So, we drive to the neighboring, more suburban town to grocery shop.


There is also another mechanism.

You can model traffic as something resembling a network flow problem. You have many individual drivers choosing routes, often using a greedy algorithm without full awareness of traffic conditions. If you add more capacity somewhere, some drivers will start making different choices. That could make existing bottlenecks worse, reducing overall throughput.

On the other hand, if you have a good central traffic planner that gives everyone a route, adding more capacity will never reduce throughput. Some drivers may just get routes that are suboptimal from their perspective.

This is the expected outcome of any system where people make individual choices.


I meant educational degree. What educational degree covers traffic analysis as part of the curriculum. I think civil engineering comes close but i am not sure.


If you'd like to see similarly counterintuitive behavior in computer-land, check out Bélády's anomaly (increasing the number of pages in memory results in more page faults, not less for the FIFO page replacement strategy): https://en.wikipedia.org/wiki/B%C3%A9l%C3%A1dy%27s_anomaly


Past related threads:

Traffic Simulator - https://news.ycombinator.com/item?id=25669316 - Jan 2021 (140 comments)

Microsimulation of Traffic Flow - https://news.ycombinator.com/item?id=19670831 - April 2019 (159 comments)

Traffic Simulation - https://news.ycombinator.com/item?id=11881964 - June 2016 (21 comments)


This is a lot of fun! It took me a minute to realize you could drag in traffic lights, hazards, and speed changes.

The source for this project is available here: https://github.com/movsim/traffic-simulation-de


Related project that goes more in depth with modelling a whole city section (with focus on realistic traffic patterns:

https://github.com/a-b-street/abstreet - Transportation planning and traffic simulation software for creating cities friendlier to walking, biking, and public transit

Very interesting project which I played around with a bit and tried hacking on it to add cities I live in, but the slow Rust build times makes it kind of chore so never really managed to create something good with it.


When being interested in traffic simulations, you may try https://www.eclipse.org/sumo/ as well.


This looks very cool, thanks for sharing!


Freeways is also an excellent sandbox where you can try your prowess in highway design.

https://captaingames.itch.io/freeways

(not affiliated, I just had a good time playing)


If you want to understand some of the theory behind this, and applications (some of them counterintuitive - slow down the traffic at specific points to achieve higher throughput overall, etc.), I can recommend this edX course:

https://www.edx.org/course/intro-to-traffic-flow-modeling-an...


Related -

Gridlock vs Bottleneck Simulator: https://setosa.io/blog/2014/09/02/gridlock/


That looks good- you should submit it to HN sometime! Just not right away—it's best to wait for the hivemind caches to clear. If you do post it, email us at hn@ycombinator.com so we can put it in the second-chance pool (https://news.ycombinator.com/pool, explained at https://news.ycombinator.com/item?id=26998308), so it will get a random placement on HN's front page.


The best lesson here, is how much tuning the "Politeness" parameter impacts the creation of traffic jams. Maybe public authorities could take the hint, and use it in public campaigns to reduce congestion?

Edit - The book behind the site: "Traffic Flow Dynamics" http://traffic-flow-dynamics.org/


Increasing "Max Accel a" results in much happiness. Faster cars, and more aggressive drivers?


That's not too surprising. One of the reasons we get traffic jams that persist is that when the car ahead of you accelerates out of it at the other end, you wait a little until there's some distance between you until you accelerate out of it.

So effectively, by waiting for separation before speeding up, you're transmitting the congestion upstream.

Of course, real people can't just floor it at the same time as the person ahead of them. When the military drives in tight convoys, they use things like hand signals to make everyone throttle up at the same time and maintain the distance between them. It's frightening the first few times you do it because it goes against all instincts.

So yes, that works. No, it's not a practical solution.


One of few good reasons for connected cars.


Aren't the things you're describing more like "Time Gap T" than "Max Accel a"?


I guess I'm hand-wavily referring to both. The time gap might be the actual delay, but after waiting for some separation, most people also don't aggressively maintain that separation -- they let the distance grow longer for a little while to get even more separation. I guess that's the max accel.


I’ve wanted to play with something like this for ages. Really nice, thx :)


CGP Grey: The Simple Solution to Traffic.

https://youtu.be/iHzzSao6ypE


The ACTUAL Solution to Traffic - A Response to CGP Grey

https://youtu.be/oafm733nI6U


Trains are fine for inter-city traffic > 20 km or so, below that, if you can, take a bicycle. It is a much better solution than a train for door-to-door.


Cars seem to be able to switch line even when slowed down to ridiculously low speed. Is there a parameter to control minimum speed for a line change that I'm failing to see?


When I'm stuck in a traffic jam on the autobahn in Germany and it's almost impossible to move forward at all, I see it all the time that people want to change lanes in the hope that they can gain a few meters there.

In return, they cause a traffic jam in the new lane to the rear.

Therefore, I would report from anecdotal experience that lane changes are possible even at near standstill.


True, but on the simulation some cars look like they move laterally. Maybe I should just assume that the scale of the rendering is not 1:1.


Agree! If anything, people seem to be more likely to change lanes the slower traffic is. If the traffic is flowing, people tend to stay in the lane that matches their preferred speed.


I love the 'politeness' slider :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: