A Look At Traffic Lights
December 18, 2014

We have all had that moment where we pull up to an intersection, the traffic light is red, yet we look around and we see that no one is coming (why are we just sitting here?) or only one car crossing the intersection - yet we have bought all traffic to a standstill along a major arterial road for 30 seconds for the benefit of very few.

I am a computer programmer, not a traffic engineer - and if I were to think about optimizing the flow of traffic, traffic lights intuitively appear to have two large cons - they completely stop traffic (often waiting on a timer regardless of how much traffic is coming from the other direction), and while doing so, they act as synchronization points for traffic to cluster together; creating the illusion of congestion. I am not the only person to have this hunch, and I decided to make a computer simulation to test this out. You can run it in your web browser via this link. There are a few options you can play with - like the timing of the traffic lights and the block size. The traffic moves at a top speed of 1 unit per second (that is about 35 miles per hour at the scale it draws the street and cars.)

Here is a starting state with 20 cars evenly spaced 5 units apart;

From street level, there are other cars on the street, but you would not call it congestion;

If we let it run for a while (we can speed up the simulation), we can see that the cars start to cluster up;

Here is what the clustering looks like from the street level;

I could visibilty watch the cars braking and clustering together, but I needed some kind of metric to measure the performance of traffic lights. Thanks to a tweet by @MRC_SLC, I added the ability to measure the impact the traffic lights and congestion have on travel times by comparing the average distance the cars have travelled with how far they could have travelled on a free flowing road. You can see these statistics in the bottom right corner;

In the above example, the cars spent an average of 19.3% of their time braking rather than accelerating, which caused us to cover 19.2% less distance than if the traffic were free flowing. Adjusting the traffic light cycle to spend 10 seconds on red and 10 seconds on green makes this clustering more dramatic:

Ths distance lost due to braking grows to about 25.2%. Watching videos is more fun than static pictures, so I made a recording showing the cars evenly spaced out, eventually clustering together;

I noticed that as I increased the distance between blocks, the amount of time spent braking decreases, and when I increase the time it takes for the traffic lights to cycle, the amount of time spent braking increases. Synchronizing the traffic lights (so that they turn red and green at the same time) appears to have no significant effect on the result. By comparing the time it takes to travel between intersections (which the simulator makes it easy to do because the cars travel 1 unit in 1 second) and the time it takes for the traffic lights to cycle, we can come up with a ratio. I ran the simulator for 10 minutes at maximum speed with 20 cars for different values of this ratio and plotted out the travel distance lost due to congestion and braking;

From that, we can determine the effect that traffic lights have on our travel times;

You can download the numbers in this Excel spreadshet.

I have come up with a few conclusions concerning traffic lights - shorter traffic light cycles are better as it reduces clustering and the impact on travel times, and the less traffic lights the better - space them apart and only use them when absolutely necessary to have minimal effect on traffic. For roads that focus on getting people from A to B efficiently, it makes sense to use them sparingly to keep traffic as free flowing as possible. For streets that are trying to create pleasant environment for people, you might be better off with simple stop signs and shared spaces. The presence of many traffic lights may be an indicator of a stroad that fails as both a street and a road.