Why Aren’t All Our Traffic Lights Already Under AI Control?

Some Ideas For AI Traffic Control

David Grace
TECH, GUNS, HEALTH INS, TAXES, EDUCATION
10 min readMay 28, 2019

--

Image by Pat McKane from Pixabay

By David Grace (www.DavidGraceAuthor.com)

Why Do We Have Green Lights For Empty Streets?

As I was sitting at a red light a few days ago, irritated that the cross-street with the green light was absolutely empty, I asked myself, for at least the hundredth time:

Why aren’t all these intersections AI-controlled instead of relying on pre-set mechanical systems that show green lights for empty streets while traffic on the cross-street waits at a red?

A Robot Traffic Cop Is Not Good Enough

At first I imagined that each signal might be replaced by a robotic traffic cop who evaluated the number of cars waiting in each direction and made an informed decision about who would go and who would wait.

The problem with that idea is that letting traffic flow in a particular direction in intersection A might have a negative impact on the traffic at intersection B a couple of blocks away. Even if it didn’t, it certainly wouldn’t improve the traffic flow at intersection B.

Instead of an independent traffic cop at each intersection, what we really need is an all-seeing, all-knowing, genius, Mega Traffic Cop overseeing every intersection in the city in a way that would optimize traffic flow across the entire grid.

Stripped down to its basics, optimizing traffic isn’t that much different from optimizing data flowing through a network. Haven’t we already solved that problem?

How Hard Could AI Traffic Control Be?

Given the AI and ML tools we have today, I asked myself, “How hard could building an AI traffic-management system be?

The answer is, “I don’t know, but it’s interesting to think about.”

Initially, I thought that optimizing traffic flow with AI shouldn’t be super difficult. But, maybe I’m completely wrong. Or, maybe it’s already being done and I just don’t know about it.

Here are some thoughts on how it might be done. I would appreciate informed feedback on this topic.

The Infrastructure

Initially, each intersection with a traffic signal would need a camera pointed in each direction of travel so that the number of vehicles approaching the signal up to some distance, perhaps 200 yards, could be watched and counted.

The camera and the traffic signal’s lights would need to be connected to the AI system.

Training

Either using drones, tethered balloons, or some other aerial system you would want to record the traffic in a small city 24/7 for at least two weeks. I’m thinking someplace like Topeka, Kansas with a population of about 125,000 should be about right.

You would need to include the traffic for the entire length of each street and highway, not just at the locations controlled by a signal, because the AI will need enough data to be able to suggest locations where new signals would improve traffic flow.

Processing The Video

This traffic video would need to be “parsed” by software that would convert the streets into a two-dimensional grid with various-sized colored rectangles in each frame representing passenger vehicles, small trucks, buses, and large trucks.

Intersections would show red lines parallel to the blocked location whose lengths would be proportional to the time the light was red, the line getting shorter in each frame until the light changed, at which point it would become a green line proportional to the time it was green, again getting shorter until it became red again.

Left turn lights would be shown by similar red and green curved arrows, again getting shorter as their time counted down frame-by-frame.

This simplified data picture would be the input for the AI program.

Boundary Rules

You would need to assign boundary rules for any modifications the AI might want to make to the signal settings.

For example, no vehicle first in line at a red light would be forced to wait longer than some maximum period, perhaps two minutes, before being given a green light.

Assuming no pedestrians, no vehicle at the head of the line at a red light would be given less than a minimum period of time to get through the intersection, perhaps ten seconds.

Of course, if the system were smart enough it would just watch the vehicle and change the light once it reached the other side.

No signal would turn green for any direction of travel if there were no vehicles waiting or moving toward the signal within some maximum distance from the signal, perhaps forty feet.

Goals

The system would be trained to operate the signals to maximize certain parameters.

Before we set the parameters, we need to understand the difference between “mean” and “median.”

Mean/Average

“Mean” means “average.”

If we have ten vehicles and in one hour three of them travel 100 miles each, and each of the other seven travel 10 miles, 9 miles, 8 miles and so on, then the total distance traveled would be 349 miles and the average or “mean” distance traveled by each of the ten cars would be 34.9 miles that is to say, 34.9 mph.

Median

Median means the middle value where half the participants have scores above that value and half have scores below that value.

If we made a list of the miles traveled by our ten cars in that hour, the median value would be 8.5 miles in that five vehicles would have traveled 9 or more miles and five would have traveled 8 or fewer miles.

Notice the substantial difference between the mean value of 34.9 miles/hour and the median value of 8.5 miles/hour .

If our system was designed to maximize the average miles traveled/unit of time (MPH) it might optimize the system to allow a few cars to go very fast while forcing many vehicles to travel very slowly. We don’t want our goal to be an increase in the average distance traveled over any particular period of time.

We want to lower the travel time for as many vehicles as possible, so we want our AI to maximize the median distance traveled per period of time, which might be one minute.

We will want our AI to adjust the signals, subject to the maximum and minimum rules, to maximize the median distance traveled during each one-minute time block.

Varying The Time Period Over Which The Data Is Evaluated

Increasing the median distance traveled per minute is all well and good, but what if the strategy that achieves a higher median value in minute 1,000 leads to a lower median value in minute 1,030 than would be the case using a different algorithm?

Put differently, what if setting the signals a certain way improves the traffic right now, but has an unintended consequence of ultimately worsening the traffic flow half an hour from now?

Because the program will need to deal with rush-hour traffic that lasts for several hours, we may learn that using a straight minute-by-minute calculation will not be the most efficient way to improve traffic during extreme situations that extend for an hour or more, e.g. the crush of cars before and after a concert or a ball game.

We may be more successful by using a rolling-average median-distance-traveled number.

For example, to calculate a five minute rolling average, at minute five you add up the median distance traveled for minutes one through five, divide by five, and place that number in the number one position in a list. Then you add up the median distance traveled for minutes two through six, average them, and put that number in row two of your list. And so on.

After fifteen minutes, you start over and you do the same thing for minutes one through fifteen and put the average into row one for the fifteen-minute list. Then at thirty minutes, you do it again for minutes one through thirty.

Initially, the AI would optimize its control decisions based on the just the minute-by-minute median distance, but at the end of the day it would compare the six numbers:

  • The median distance just for each single minute
  • The median distance for the rolling average for minutes 1 through 5
  • The median distance for the rolling average for minutes 1 through 15
  • The median distance for the rolling average for minutes 1 through 30
  • The median distance for the rolling average for minutes 1 through 60
  • The median distance for the rolling average for minutes 1 through 180

Now, the simulation would start again and the program would make another run using the same historical traffic data but with the goal of maximizing the median distance per minute based on the rolling average for minutes 1 through 5.

Then it would run the scenario again using a rolling average for minutes 1 through 15. And so on.

Eventually, the program would have accrued the necessary data to determine if it should make its adjustments based on a minute-by-minute evaluation or on some rolling average over a longer period of time.

What we want to achieve is an increase in the median distance traveled during rush hour as well during less stressed situations. The goal would be to pick the averaging parameter that would yield the highest median distance/unit of time over the course of 24 hours.

Compressing The Dynamic Range

It’s all well and good to increase the median distance traveled/unit of time, but we have to pay attention to the boundary conditions.

If the median distance is equivalent to an average speed of 24 mph and the average speed of the bottom 5% of vehicles is 3 mph and the top 5% of vehicles is 60 mph, what could we do to raise the bottom 5%?

If we accomplished that, what effect would that have on the median distance traveled by all the other vehicles?

In short, if optimizing the center of the normal curve severely penalizes drivers at the bottom and greatly benefits drivers at the top, we may want to modify the system in some way to improve traffic for the bottom 5% even if that degrades performance for the top 5%.

Traffic Districts

When UPS is sets up its drivers’ routes, it doesn’t try deal with all the delivery locations in the entire city. That’s just too difficult.

Instead, its software breaks up the city into various zones and optimizes a package delivery route for the far smaller number of deliveries within each zone. Then it optimizes truck routes transitioning from one zone to an adjacent zone.

Instead of viewing the entire city as one, big, traffic-management environment, we may want our AI to break up the city into traffic districts, for example, city center, the suburbs, the areas around the sports stadium, the airport, and the commercial sector.

The AI would initially maximize median distance traveled/unit of time within each district, then coordinate traffic flows between adjacent districts to equalize large imbalances in median distance traveled within each of those various districts.

Additional Controls

Think about a city criss crossed by freeways and expressways or perhaps encircled by a freeway such as D.C.’s beltway.

Those freeways don’t have any traffic signals so they would be outside our control system, but traffic jams on the freeways may spill over onto the surface streets. If that happens, adjusting the traffic signals won’t necessarily be effective in improving surface-street traffic.

Our model should be widened to

  • Include traffic flows on all roads including those like freeways with no signals, and
  • Being able to detect the need for additional signals both on surface streets as well as on the freeway on-ramps and off-ramps

New Signals

If we do this really well we should be able to make the system smart enough to detect gaps in the existing traffic-control system and recommend the addition of new signals.

For example, the AI should be able to “notice” that traffic is regularly blocked at a certain uncontrolled location, immediately followed by a vehicle leaving the blocked direction of travel and entering the adjacent cross street.

That would mean that people are regularly blocking through traffic while they wait for an opening in oncoming traffic so that they can turn left.

If the AI was smart enough to notice this, it could model the traffic flow as if a left-turn light existed there, and if it determines that new light would improve travel times, the system would add a recommendation for a new left-turn signal there to a To-Do list.

The same scenario would apply to removing signals that could be lost without materially, negatively affecting the traffic flow.

What About Pedestrians?

Everything we’ve talked about relates to vehicles, but we also have to deal with pedestrians. While a car can traverse an intersection in ten seconds, a pedestrian may need thirty seconds.

Suppose one human and one vehicle are stopped at a red light and the human has neglected to push the “I want to cross the street” button.

The AI sees the lone vehicle waiting at the red and it turns on the light green only for long enough for the car to get to the other side. The pedestrian starts to cross the street as well, but he only gets a third of the way when the cross-street light suddenly turns green. Oppps!

Our AI is going to have to be smart enough to identify humans crossing the street on a green light and to maintain that green light until they’ve made it to the other side. It also needs to be smart enough to deal with a problem, such as if the human decides to sit down in the middle of the road and blocks traffic by keeping the cross-street light permanently red.

This Is A Complicated Problem

I’m sure there are many, many things I haven’t thought of that the system would need to deal with, but at least I would start here.

I suspect that a pretty good AI traffic-management system could improve traffic flows and decrease travel times by an average of at least 25% and it would be far cheaper than increasing the number of lanes by 25%, if that were even possible.

SF and LA traffic is such a mess that I don’t understand why this hasn’t happened already.

AI & ML People, what do you think?

— David Grace (www.DavidGraceAuthor.com)

To see a searchable list of all David Grace’s columns in chronological order, CLICK HERE

To see a list of David Grace’s columns sorted by topic/subject matter, CLICK HERE.

--

--

David Grace
TECH, GUNS, HEALTH INS, TAXES, EDUCATION

Graduate of Stanford University & U.C. Berkeley Law School. Author of 16 novels and over 400 Medium columns on Economics, Politics, Law, Humor & Satire.