Any Traffic Engineers Here?

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
Last night I was driving home around 10 p.m. I spent so much time sitting at traffic lights on my five mile drive that I actually had time to develop and solve a closed-form solution for the position of a car with time given some very mild assumptions. I therefore cannot comprehend why I am sitting at these traffic lights knowing that there are engineers who get paid good money just to time lights. Anyway, I'll give my simple model, then you guys can tell me why it's wrong or if I'm on the right track.

The basic idea I had is that a car that is stopped at one light should be able to accelerate to the speed limit at some constant acceleration, then maintain the speed limit until he reaches the end of the road. The driver should not have to stop at any other lights on that road, much less EVERY light on that road (as is generally the case here in St. Louis). The model is for a straight road where no one is turning or doing anything other than driving straight down the road. I know that these things would complicate the model, but I'll worry about that later.

So, without further ado, the assumed form of the acceleration is
a(t)={0, t<t0
{a_1, t0<=t<=t1
{0, t>t1
where a_1 is some specified acceleration (e.g. 1 mi/hr/s), t0 is the time the light changes, and t1 is the time at which the car achieves the speed limit (which turns out to be v_l/a_1, where v_l is the speed limit).

Solving the equations of motion is very straightforward, since they are separable. Generally, they have the form d^2(x)/dt^2=a(t), where x is the position of the front of the car at time t. Thus, the solution has the form
x(t)={0, t<t0
{a_1*t^2/2, t0<=t<=t1
{v_l*t(i)-v_l^2/(2*a_1), t>t1.

This gives a velocity v(t)=dx/dt with the form
v(t)={0, t<t0
{a_1*t, t0<=t<=t1
{v_l, t>t1.

I have also extended this to the case where a line of cars is parked at a light when the light changes, though this took a little longer than I spent sitting at the lights. So am I really missing something, or is it really just that easy to predict light timings on major roads where you can't make any turns (such as the road I took home last night)?
 

herm0016

Diamond Member
Feb 26, 2005
8,516
1,128
126
lights are also used to slow people down.
and can you now scale your solution to the hundreds of lights that depend on each other in a city?
 

Gibsons

Lifer
Aug 14, 2001
12,530
35
91
Without looking too closely, does your solution only work for one direction on a road? Cars need to go in the other direction too... And what about the intersecting streets?

That said there's a particular intersection around here that drives me crazy, seems designed to catch cars from previous lights in all directions.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
The solution just tells you where a car will be a certain time after it starts from a dead stop. The extended version tells you this for every car in a line of traffic sitting at a light by incorporating a dead time based on its place in line. So yes, these could easily tell you how to time every light along the length of a road. You know what distance (x) the next light is from the one this guy started at. The solution tells you how long it will take him to cover said distance. Thus, the light just needs to be green when he gets there. I've plotted the numerical solution of these equations and predicting that the position varies linearly with time is an excellent approximation, since the startup time is very small. Thus, you don't even have to know where on the road he started to know when he'll end up at your light.

No, the model doesn't account for both directions or intersections. My plan was to take the model and expand it into a simulation of a grid of streets to optimize how it would perform. I just need a basic model to govern how the cars move in the simulation before I implement the whole thing. I'm sure this is done routinely in traffic engineering circles, but I don't really feel like reading their literature, nor do I feel that it's even necessary. When choosing the optimal light timings for a complex system, there are (or at least, should be) some decent heuristics available that would help. Problem is, every city I go to has absolutely terribly timed lights nowadays. If solutions were available, I would think large cities would take advantage of them to relieve congestion, decrease pollution, and decrease gas consumption. I'm just not seeing that.
 

dkozloski

Diamond Member
Oct 9, 1999
3,005
0
76
The traffic lights here use radar and optical recognition systems to modify light timing in accordance with existing traffic. In addition, emergency vehicles can control the lights to speed their mission. It works well. Trying to control lights with timing and no feedback on results seems pointless.
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
Originally posted by: dkozloski
The traffic lights here use radar and optical recognition systems to modify light timing in accordance with existing traffic. In addition, emergency vehicles can control the lights to speed their mission. It works well. Trying to control lights with timing and no feedback on results seems pointless.

agreed. The more input those lights can acquire, the better they will move traffic along. Though many people hate them, round-abouts are probably the best no-input solution.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
I am all for using image analysis and other methods to improve traffic flow. I don't think you guys grasp the scope of the problem here in St. Louis: I am just about the only car on the road traveling home from my fiancee's place every evening between 10-11 p.m. I take an interstate to a parkway, which is a completely linear road that you can't turn off of (i.e. the lights on it are to let people on, not off). I am generally stopped by three of the five lights on this road, regardless of how fast or slow I go. In such simple cases where traffic flow is minimal, my model gives the simplest possible way to time lights that allow people to drive continuously if they abide by the speed limit. I don't think I'm asking too much here, but this city can't seem to figure it out.
 

citan x

Member
Oct 6, 2005
139
1
81
I have that same problem here with some streets. The problem is that during the day, after peak rush hours, I can make it with only one or two lights. However, at night all I get is red light after red light. I think that is done to stop people from speeding like crazy at night. It drives me nuts.
 

dkozloski

Diamond Member
Oct 9, 1999
3,005
0
76
A late night drive here gives you green light after green light as the RADAR senses your approach to the light. Off in the distance you can see the lights cycle as the cross traffic is accommodated. Technology is a wonderful thing.
During busier hours you see the lights change quickly as the last car in the left turn lane clears the intersection or the last of the cross traffic passes. Rush hour traffic cycles smoothly as well as timing is combined with actual traffic.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
I wish I could complain about the lights here in Austin, but for the most part it's the screwed up highways that cause the most headaches. We have one highway where each and every entrance/exit ramp is different from all of the others, some of them have a merge lane, some of them don't, and some of the ones without merge lanes have no yield sign so people force a merge into a moving highway from a standstill which then causes the entire highway to backup.

There's even a point where the road goes from 3 lanes to 4 lanes, then 1/4 mile later 2 of those lanes exit. 1/4 mile after that 2 lanes from entrance ramps merge back onto the highway so we're back to 4 lanes..... but the amount of cars exiting is nowhere near the amount of cars entering the highway so traffic has to stop because there is simply not enough room for all the cars.

Terrible road design seems to be a much bigger offender then poorly timed lights.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
Since no one is dying to donate their eyes to my research, I've wasted my time writing a traffic simulator. Only took a couple hours to get it to where I can run a genetic algorithm to optimize the light timings for two-way traffic on a single street. It accounts for intersections by forcing 50% red light time at each intersection, which should be very conservative for major roadways (which generally get the majority of the green light time at a given intersection). It also accounts for the gaps between cars and makes people slow down rationally at stop lights rather than jamming on the brakes. :p The most important part of the algorithm is how you model the acceleration of each car at each time step. In MATLAB, I did it like this:

DesiredGap=CarLength*(v/10);%heuristic for safe following distance
Error=gap-DesiredGap;
braking=0;%dummy variable
k=2;%factor for braking intensity

if d/v<tau && v>0%too close to light going too fast
a=a-k*a_c*d/abs(v*tau);
braking=1;
end
if gap<DesiredGap && v>0%following too closely
a=a-k*a_c*(Error+StoppedGap+1)^4;%stop accelerating
braking=1;
end

if braking==0 %if not slowing down for any reason,
if t<t_d%still in dead time
a=0;
elseif v>=v_l%cruising speed achieved
a=0;
else%acceleration phase
a=a_c;%constant accelerations
end
end

And yeah, sorry that the tabs don't work, but we don't have the ability to post code in HT for some reason. :(

edit: I doubt anyone cares, because I'm pretty sure I'm the biggest dork in this forum, but I'll be happy to send the code for the whole program to anyone who wants it. It makes some pretty figures. :p
 

wanderer27

Platinum Member
Aug 6, 2005
2,173
15
81
Originally posted by: Crusty
I wish I could complain about the lights here in Austin, but for the most part it's the screwed up highways that cause the most headaches. We have one highway where each and every entrance/exit ramp is different from all of the others, some of them have a merge lane, some of them don't, and some of the ones without merge lanes have no yield sign so people force a merge into a moving highway from a standstill which then causes the entire highway to backup.

There's even a point where the road goes from 3 lanes to 4 lanes, then 1/4 mile later 2 of those lanes exit. 1/4 mile after that 2 lanes from entrance ramps merge back onto the highway so we're back to 4 lanes..... but the amount of cars exiting is nowhere near the amount of cars entering the highway so traffic has to stop because there is simply not enough room for all the cars.

Terrible road design seems to be a much bigger offender then poorly timed lights.

Yeah, I hated frickin' I-35 going through town, and I know what you're talking about with the double-decker two lanes - sheesh what a mess.

What really flipped me out was some of the exit/entrance ramps where you have to cross on-coming traffic. Texas is the only place I've ever seen that before.

 

Nathelion

Senior member
Jan 30, 2006
697
1
0
I feel with you CycloWizard. There are places where the lights just aren't laid out in any logical manner whatsoever. What really gets me though is that in Peoria, IL there are several thoroughfares where you can get all green lights - but only if you go 5 mph OVER the speed limit. It cracks me up, every time.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
Originally posted by: Nathelion
I feel with you CycloWizard. There are places where the lights just aren't laid out in any logical manner whatsoever. What really gets me though is that in Peoria, IL there are several thoroughfares where you can get all green lights - but only if you go 5 mph OVER the speed limit. It cracks me up, every time.
Yeah, on this particular road I used to be able to hit all the lights if I went 15 over. Now I've tried 15 over all the way down to 20 under (speed limit is 40), and I get stuck no matter what. All of these little side streets have very long lights for some reason, while the main road has very short lights. Maybe they just gave the wrong lights the longer times. Or maybe they just fail.
 

dkozloski

Diamond Member
Oct 9, 1999
3,005
0
76
Before they went to adaptive traffic lights in this area, the traffic engineers were catching flak from all sides from people that thought they had a better idea on how to time the lights. Ideas were welcomed and tried. Most of the ideas centered around the guy in question being able to get to and from work without a red light and of course everybody failed in one way or another. Adaptive lights are the only way to go because it changes to match the actual traffic. In fact, I thought they discarded the idea of strictly timing lights years ago. We've had adaptive lights for at least 25 or 30 years.
 

jersiq

Senior member
May 18, 2005
887
1
0
I think the thing you are missing most from your analysis, are the previous timings in relation to accident rates.
It might seem easy to make the fastest path for you to go from x1 to x2, but that might not have been proven to be the safest.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
Originally posted by: jersiq
I think the thing you are missing most from your analysis, are the previous timings in relation to accident rates.
It might seem easy to make the fastest path for you to go from x1 to x2, but that might not have been proven to be the safest.
I did account for this in the simulation. If there were collisions, the light timings were heavily penalized. :p I also forced the optimal light timings to meet certain acceleration constraints such that the cars wouldn't have to slam on their brakes or rapidly accelerate to avoid collisions or stop at the lights. Of course, maybe the problem is that the local drivers don't seem to mind ramming people and/or pedestrians and/or bikers. I didn't account for that mentality in the simulation. :p