Traffic light algorithms
|
random trip report |
Berkeley has lots of intersections of streets A and B where
At most of these intersections, the traffic light is timed: X seconds for A, Y seconds for B, repeat. The traffic sensors are apparently not used. X and Y are about the same even though the arrival rates are much different. This is sub-optimal, of course. A lot of the time cars are stopped by a red light (usually on A), and there's no traffic in the other direction. This pisses me off. Time is the most precious thing I have, and it's being wasted by a lazy and dumb algorithm.
My algorithmHere's my attempt at a better algorithm for such intersections. I assume no left-turn lanes or left-turn signals. Notation:
G(A) initially. If G(A), switch to G(B) if either of the following is true:
1) means that if there hasn't been any traffic on A for a while, and a car arrives on B, it will get a green pretty much immediately. The T2 pause is so that if the car turns right, the light won't change. 2) means that if there is steady traffic on A, and a car arrives on B, it will get a green after a while. If G(B), switch to G(A) if one of the following is true:
Hence B's green light will end after TB sec, or when there is no more traffic on B. If there is unlimited traffic in both directions, the lights will alternate with periods of TA and TB. If there is no traffic, G(A) will always hold. I'm omitting some stuff:
And of course things are more complex for intersections of 4-lane streets with left- and right- turn lanes. The field of traffic engineeringWhat's a good formalism for expressing traffic-light algorithms? I use pseudocode above. Is there something better, maybe involving temporal logic or constraint programming? It turns out there's an entire academic field that deals with stuff like this! People write research papers like this and this. UC Berkeley has an Institute of Traffic Studies. Here's a survey of traffic sensor technology as of 2007. I don't have time right now to read a lot of papers and see if the algorithm I sketch above has been studied, or improved on. If you want to do this, please let me know what you find. People have written simulators to study traffic control algorithms. Here's one with a web-based GUI. |