12 ms·
Traffic Simulator
- searedsteak 6y agoLooks like maxing out acceleration solves all other problems. I guess we should require a minimum power-to-weight ratio for cars from now on.
- shellfishgene 6y agoThis would actually be possible to implement with the general switch to electric cars...
- jschwartzi 6y agoWhat about electric trucks? I set the veh/hr to max and then when I changed truck percentage to 14% I almost immediately stopped traffic at the onramp as the trucks inevitably don't have enough space to accelerate from the meter point. Especially if one of the cars cuts the truck off.
- Cthulhu_ 6y agoIn practice that would mean a lot more head/tail accidents, I've seen that happen plenty of times in traffic jams from over-eager drivers, sudden stops (either people trying to go too fast or not paying attention), etc.
- bhupy 6y agoEasier to do with self driving cars, and can probably be attained with Level 3 autonomy.
- amcoastal 6y agoYeah, and there would be no reason to increase acceleration -- increasing the acceleration only aids in this project because it shortens the time when the car behind the stopped car in front of it can get up to speed. If the cars are all talking to each other -- they can all start accelerating at the exact same time and rate as soon as the light turns green etc.
- andrewstuart2 6y agoThere's also the frequent problem of split attention when you're accelerating like that. Often you may be trying to change lanes, and checking a mirror for an opening. Even without that kind of better communication, computers are just better at tracking multiple data points at once.
- bhupy 6y agoThat's true only when every car is a self driving car. In the interim, if only a subset of cars is running Level 3 autonomy, then including a quick acceleration into the adaptive cruise control is a good way to minimize these phantom traffic jams.
- InitialLastName 6y agoNot to mention killing a lot more non-car road users who don't have access to the same acceleration.
- kharak 6y agoI've made the same observation. But I don't believe human drivers could reasonably take advantage of high acceleration, at least not as well as the simulated cars here. This is a great showcase of the usefulness of autonomous cars, though. Take humans out of the equation and traffic will flow.
- andrewstuart2 6y agoThe other thing that really seems to make the biggest difference (in combination with better acceleration) is following distance, which is another thing that presumably gets less important with autonomous cars because you don't really have to account for a relatively slow reaction time or poor braking. The observation on acceleration does make me wonder whether teaching proper merging etiquette better (reach freeway speeds before you're at the merge junction) would make a significant difference if properly followed.
- epanchin 6y agoHow do autonomous cars deal with cheap or worn tyres? Is there still a lot of allowance for braking distance?
- bob1029 6y agoOr weather/road conditions. Reaction time is irrelevant if you happen to be driving over an irregular/wet/oily/sandy/etc section of roadway at the moment maximum braking force is demanded.
- throwaway0a5e 6y agoA burnout at the beginning of every drive cycle would do wonders for calibration.
- gnopgnip 6y agoAutonomous cars still need to have adequate following distance. Without that one small problem turns into a 10+ car pileup.
- yabones 6y agoMaxing out 'politeness', 'acceleration', and 'inflow' I could achieve nearly 7000veh/hr. Probably impossible, since it would cause heaps of rear ending accidents. Maybe if driver assist features both prevent lane changes and optimize avg. speed.
- throwaway0a5e 6y agoRegardless of how I change the map layout, traffic in/out flow or truck/car ratio I seem to get the best results when I crank accel, speed and right bias for trucks to the max and lane-change threshold and following distance to the minimum. Which makes sense since those are basically the ideal conditions for reducing the number of obstructions low speed (merging, exiting, trucks on grade) traffic poses to higher speed traffic and reduces the effective road area of the obstruction.
- snarfy 6y agoYou can almost always fix the traffic by maxing out acceleration. Sadly, this vindicates my real world aggressive driving behavior.
- throwaway0a5e 6y agoWhy is it sad if it turns out a subset of people are already behaving in a way that analysis indicates promotes better flow?
- t0astbread 6y agoBecause aggressive driving is dangerous? Perhaps aggressive driving also contributes negatively to the overall flow in the real world when not everyone drives equally aggressive (i.e. through extra lane switches caused). But I don't know much about traffic analysis so idk.
- ripperdoc 6y agoProbably you need to add the factor of accidents. Not only do they kill people, they are also the major reason for blocking traffic.
- vegetablepotpie 6y agoIt seems that decreasing politeness increases lane changing behavior. The effect of reducing politeness is that people in the on ramp get in the highway quicker but the whole highway slows down.
- reallymental 6y agoPerhaps these questions are appropriate for this post. I'm beginning to delve into this space and I've not managed to get any satisfactory answers to these questions, despite my month(s) long search. 1) How does one build a traffic (i.e state-space system), forgetting the visualization aspect of things ? Just generating sparse matrices, and adding elements to interact (add/subtract) from these matrices would be a great start! Any way to do this in a compiled language ? 2) Are there any libraries out there that help you simulate traffic in an existing network of roads, extracted from OpenStreetMaps perhaps?
- skrunch 6y agoThis doesn't exactly answer your question, but what I settled on during my dissertation (granted, that was a few years ago now) was SUMO: https://www.eclipse.org/sumo/ https://www.eclipse.org/sumo/ IIRC you could import maps from from open street map, but I'm not sure if it has a "headless" mode, without all the visualisation.
- 2Gkashmiri 6y agohaving your route to office simulated with this would be super cool on osm
- adamjb 6y agoOn 2) there's Matsim and AequilibraE off the top of my head.
- mlaretallack 6y agoFor 2, Eclipse Sumo allows import of a road network from openstreetmap.
- dabreegster 6y ago1) There are different choices you can make about simulating individual agents or aggregate flows along roads. Assuming you're interested in the former, you can advance the simulation in discrete time-steps using approaches like the intelligent driver model mentioned in another thread. Chapter 4 of https://apps.cs.utexas.edu/tech_reports/reports/tr/TR-2157.pdf https://apps.cs.utexas.edu/tech_reports/reports/tr/TR-2157.p... is a different approach to the discrete time system that tries to handle complications that come up when applying to OpenStreetMap, like having a vehicle cross multiple roads and intersections in a single 0.1 second timestep, due to really short roads. If you're willing to throw away detailed movement (including acceleration and lane-changing), you can try a discrete-event approach, where you say "this vehicle enters one end of a road at time t, don't calculate anything for it until t + best_case_time_to_cross". https://dabreegster.github.io/abstreet/trafficsim/index.html https://dabreegster.github.io/abstreet/trafficsim/index.html has some ideas there. 2) Another option with much less detailed traffic simulation, but much more UI focus, is abstreet.org
- parhaml 6y agoWhat is the source of the logic for these mechanics? Meaning, how did you model the results of these inputs? Traffic phenomena is really interesting to me. This is a great way to present these inputs and visually present the outcomes.
- acvny 6y agoTo model these types of processes people usually use stochastic processes (https://en.wikipedia.org/wiki/Stochastic_process https://en.wikipedia.org/wiki/Stochastic_process). I don't know what the author used, but seems inaccurate.
- jeremiecoullon 6y agoThe author used the "intelligent driver model" (IDM): https://traffic-simulation.de/info/info_IDM.html https://traffic-simulation.de/info/info_IDM.html It's a system of ODEs that describes the dynamics of each driver. So the inputs are: the parameters of the model and the inflow of cars in the section of road
- mbank 6y agoLove these kind of micro simulations! They really help to discover non intuitive behaviour of complex systems just by playing around. Great job!
- vbtemp 6y agoThings like this are cool. What I would be curious to see though, rather than setting global parameters (i.e., politeness), would be to have each agent have its own politeness score (as well as other attributes). Models like the one linked to here work as if each agent is a particle, rather than autonomous decision-maker adapting to their circumstances locked in long-term, iterated games with other anonymous drivers. This way, agents would adapt their attributes to maximize their own local advantage, and therefore could see how large scale trends develop. I've driven in many countries and regions within countries, and it's just wild how "driving cultures" vary so much. Some places the drivers are so polite to the point it really makes things dangerous, other places the drivers are vindictive (distinct from being aggressive driver). It would be interesting to model how driving cultures emerge. Edit: I guess the short story is I'm really curious why some places, like Bangkok driving is chaotic, dangerous, gridlocked, and no one adheres to traffic laws much or yields to pedestrians, but relatively devoid of road rage (and people will let you merge over if you need to). In DC, people carefully adhere to red lights, stop signs, pedestrians, etc but will go far, far out of their way to block you from changing lanes once they see your turn signal go on. Also, exploring the game theoretic (probably prisoner's dilemma?) aspects of tailgating and how that seriously depends on the driving culture. When someone tailgates, the tailgatee can slow down (everyone loses), speed up or move out of the way (tailgater wins/tailgatee loses), etc. If everyone slowed down when tailgated, there would be no benefit of tailgating; if enough people give in when tailgated, that keeps rewarding the behavior. Anyway, that would be something fun to explore in one of these traffic simulations.
- pc86 6y agoThis would be a neat reinforcement learning project. > Some places the drivers are so polite to the point it really makes things dangerous I've known people like this, who will approach a 4-way intersection and stop even when they don't have a stop sign and the perpendicular street does.
- jeffhuys 6y agoParticipating in traffic all comes down to being as predictable as possible, I think.
- bones6 6y agoOn the ring map, with default settings, just stopping traffic with the traffic light for a second produces the dreaded rubber-band effect propagating forever around the circle. Fun simulator!
- billfruit 6y agoThat behaviour is mesmerising to observe in the simulation.
- ishikawa 6y agoThis was first posted without https and with www in 2013. https://news.ycombinator.com/item?id=6756360 https://news.ycombinator.com/item?id=6756360
- timvdalen 6y agoI saw a comment about this site earlier on a different thread, so I think someone dug it up because of that.
- dogline 6y agoI've always wanted to program something like this. What are good references to simulation programming to handle this kind of use case?
- bob1029 6y agoIf you want to build a large scale, real-time simulation with many participants, you might want to check out some paradigms being used in the game development arena. Particularly concepts like Unity's DOTS/ECS approach. Ultimately, the task is producing a good model of your domain and then organizing the data in such a way that you can quickly mutate a very large number of instances with each tick (if you are seeking real-time). If you are not seeking real-time, you could probably do whatever the hell you want.
- billfruit 6y agoI was also looking to learn more about this. Discrete Event Simulation books may be of some help.
- deleted 6y ago[deleted]
- aj7 6y agoAppears to violate divJ + rhodot = 0.
- iamflimflam1 6y agoTurning the politeness down to zero really messes things up for everyone. There's a lesson in there somewhere...
- niea_11 6y agoI found that changing the politeness in either directions causes traffic jams. But I feel it happens faster if you decrease the value (but I'm not sure). Also it's best to set "timewrap" to 20 times to see the effects quickly.
- xixixao 6y agoNeeds an American mode where people don’t know they should stick to the right-most lane, unless passing.
- NwtnsMthd 6y agoOther uniquely American things: - Passing on the right - Taking an exit from the passing lane (cutting everyone off) - Couch in the middle of the highway
- throwaway0a5e 6y agoAnd a Connecticut mode where nobody uses the right lane to pass people who do that.
- C19is20 6y agoJust set 'Politeness', to zero: don't touch anything else.....Italy. *Things have got better year on year, though. I have f+r dashcams - rarely needed, nowadays. If anything, they do ensure I drive better.
- analog31 6y agoTo simulate my neighborhood, it needs some parked cars and trees that appear out of nowhere.
- trap_chateau 6y agoUnless you are approaching a red light with a right turn, and intend to go straight. I wanted to turn, now you're in the way damnit!!
- fooyc 6y agoThe more lanes you add, the more cars you get. Adding more lanes doesn't solve traffic issues. https://en.wikipedia.org/wiki/Induced_demand#Induced_traffic_and_transport_planning https://en.wikipedia.org/wiki/Induced_demand#Induced_traffic...
- throwaway0a5e 6y ago"Induced demand" is just a backhanded way of complaining that more people can be served by expansion of a particular piece of infrastructure that you don't like. Nobody ever complains about induced demand on the subway from more frequent service causing more people to decide that's the best option for them. Rush hour is like pouring a 5gal bucket into a sink. You can't reasonably handle that all at once will have some water in it until it all makes its way through the pipe. But you have to be insane to use that as an argument against making the pipe bigger. Increasing the max capacity of the pipe (so more lanes, in the case of highways) means that it can have normal flow before it starts backing up. The "induces" demand because at the margins some people who were voluntarily changing their usage times to avoid the peak hours will commute at peak hours. I am intentionally trying to use generic language here because this isn't a unique phenomenon to highways.
- asdff 6y agoThe issue with widening highways is that traffic doesn't exist in a vacuum. You aren't widening the surface roads that back up into the highway or the interchanges to other highways, that is the crux of traffic. You widen one pipe but it feeds into the same set of narrow straws anyway, and your sink is just as backed up.
- beerandt 6y agoStill, this is an argument for upgrading all "pipes", not one for attempting to control demand on the supply/capacity side. But even absent that, you want surface, collector, and feeder streets to be the natural "rate-limiting" parts of the network (in that order). It's why it's especially egregious to wave-in people from a driveway or parking lot into traffic on an already congested street. It breaks the natural rate limiting. The right-of-way rules are surprisingly well-thought out, from a systems perspective.
- gfxgirl 6y agoI don't know if "right bias" is enough to simulate my experience in traffic which includes trying to get in the fastest lane and also trying to get over to the exit for my exit. As well as when my exit is backed up a couple of miles but the lane I'm in is moving faster such that I have to block my lane to wait for an opening into the lanes that will exit.
- albertzeyer 6y agoCities Skylines is very nice for such traffic simulations. https://www.youtube.com/watch?v=yITr127KZtQ https://www.youtube.com/watch?v=yITr127KZtQ (https://news.ycombinator.com/item?id=17182008 https://news.ycombinator.com/item?id=17182008) (https://www.reddit.com/r/CitiesSkylines/comments/7h6zr0/traffic_flow_measured_on_30_different_4way/ https://www.reddit.com/r/CitiesSkylines/comments/7h6zr0/traf...) https://www.youtube.com/c/BiffaPlaysIndie/search?query=lane+mathematics https://www.youtube.com/c/BiffaPlaysIndie/search?query=lane+... This is frequently posted here on HN. E.g. https://news.ycombinator.com/item?id=25632642 https://news.ycombinator.com/item?id=25632642.
- waiseristy 6y agoUnfortunately CS suffers from many "dumb computer tricks". The pathing algorithm is open loop, often causing huge 1 lane jams even though it would be more efficient for through traffic to use other less congested lanes. You end up needing to create crazy unrealistic spaghetti interchanges in order to trick the AI into behaving
- Shared404 6y agoI agree, Computer Science does suffer from many dumb computer tricks. Wait a second. Ah well, point still stands. E: It was a joke...
- sumtechguy 6y agoHaving watched way too many Biffa vids. The way to fix that is to create/force dedicated turning lanes. There is a plugin that lets you manage it. It should be built in. If you do not have the plugin sometimes you can fix it by changing the number of lanes on both sides of an interchange (what biffa calls lane mathematics). Basically if you have 3 lanes merging into 3 you need a 6 lane on the other side. If you have 6 and 3 dumping off you need 3 for both exits. That does not fix 4 way intersections though and usually you need the plugins to fix that.
- waiseristy 6y ago
- mickallen 6y agoThis looks really cool! What's the tech stack?
- sandworm101 6y agoI love these little simulators because while they purport to show that slower more polite driving is more efficient, more often than not they show the exact opposite. Want to shove the most cars through per hour? Remove the speed limit. Accelerate and brake like every intersection is a drag race. Leave absolutely no distance between cars. And dump any notion of polite lane changes. NASCAR was right: Minimize unused pavement. The most efficient way to move large numbers of cars down a road is at 200mph with only inches between each car.
- recursive 6y ago> they purport to show that slower more polite driving is more efficient Where are you seeing this?
- jonnycomputer 6y agoIn this instance, upping the politeness bar seems to reduce traffic ...
- recursive 6y agoThe comment I was responding to indicated the opposite.
- deleted 6y ago[deleted]
- falcrist 6y agoAdjusting it in either direction seems detrimental.
- jonnycomputer 6y agohmm. it could be an interaction with some of the other settings I was fiddling with, i.e. could make it better in some conditions but not others.
- sokoloff 6y agoAny idea why the max Accel figure is set so low by default? 0.3 m/s/s requires over a minute and a half to accelerate to 60 mph/100kph. I'd expect something more like 2 m/s/s (0-100 kph in 14 seconds) if it's a safety-related threshold and at least 1 m/s/s if it's a general operation setting. That it's set so far away from that makes me wonder if I don't understand what it's used for.
- leetcrew 6y agoit is odd, especially since the "info" section on the same page lists reasonable figures as being in the range of 0.8-2.5 m/s/s. even 0.8 makes a big difference over 0.3. I can only assume they set the initial conditions to actually result in a traffic jam.
- whalesalad 6y agoMy favorite observation is that you can move the 'politeness' slider all the way up - touch nothing else - and watch the world burn.
- Geminidog 6y agoYou don't need AI based non linear simulations to see what's going on. The simulation shows that traffic can be described in much simpler terms. You'll notice that traffic is actually a longitudinal wave that travels through the system. The cars are particles and traffic is crests in the wave. The wave usually travels backwards against the direction of the cars. The worst type of traffic is when you get a standing wave where the crest of the wave just stays in the same place. Take a look at the simulation with this knowledge in mind. Then you will actually see the wave. An elegant solution to alleviating traffic would be to then take techniques that dampen waves in materials and translate them into techniques that work for traffic.
- mlrtime 6y agoOne way to dampen the wave is to leave a lot of space between you and the car in front of you to keep a constant speed. I do this in tunnels with heavy traffic where I know someone can merge in front of me. I keep a large space so I can prevent breaking and keep a constant speed. I get to the other end at the same time but everyone behind me gets a benefit from my constant speed instead of speeding up and breaking (wave).
- Daho0n 6y agoAny games out there with good traffic simulation (IE. that doesn't break down as soon as there's a lot of traffic like Cities Skyline)?
- mongol 6y agoI would like to use a driving simulator to learn how to drive on the left side. Is there something like that? Good if I would rent a car on Ireland.
- roryokane 6y agoEuro Truck Simulator 2 is the most realistic street driving simulator I know of, and it includes roads in the U.K. I found it good driving practice when I hadn't driven for a while (as I don't own a car). ETS2 only comes with trucks as driveable vehicles. A lot of the skills are the same as driving normal cars, but trucks have more gears, are larger, and accelerate more slowly. Truck cabs also don't have rear-view mirrors; to look backward you have to either use side mirrors or stick your head out the window. I have seen mods that add normal cars to drive. I downloaded one of those mods but haven't tried installing it. I'm not sure if those mods unlock the cars from the start or if you have to first save up for and buy five trucks to unlock the in-game online vehicle ordering catalog (which takes many hours of gameplay).
- darrennix 6y agoClearly we just need to make all cars accelerate at 4.0m/s and our traffic problems would’ve solved.
- docpytr 6y agoabout the one lane backups, one method that i employ are 3 lane roads, all only lanes and by use of TM:PE, say do not switch lanes for 5 points before intersection, forcing traffic to use all lanes.
- jchook 6y agoReminded of Java simulations that show yielding control of your vehicle 100 yards before a 4-way "smart" intersection can allow the central command to get every car through safely without adjusting anyone's speed more than 5 MPH. Wish I could find it again.
- germanka 6y agoAnd that was fun!
- SubiculumCode 6y agoOkay, this made me dread returning to work and its commute. Stressballs!
- ajsharp 6y agowhy....why is this so satisfying??
- afinlayson 6y agoThis is amazing!! I'm so glad you open-sourced it!