While I was studying my industrial electronics and automatics engineer degree, I had to program a cross street traffic lights for a simulation. The task was not particularly difficult (I was just programming a couple of traffic lights for an intersection), but it made me realize how difficult must be to control not just one intersection, but all of them in a big city like Valencia (or worse, Madrid).
Just in the same way in a warehouse you have to take into account the holding costs, in a intersection of streets, if the red-green light periods of the traffic lights are too long, retentions will be created, and if they are too short, only a few cars, the ones in first line, will cross, due to the delay in the reaction time of the drivers. So a proper lenght has to be found, and it depends on the traffic flux, which is also dependent on the area, hour and day, so a constant revision of the periods is needed.
By the way, we don’t have to forget the yellow light. Sometimes are not needed, if there is no “dilemma zone“, but when needed, if it is too short, some drivers will cross in red and it may cause accidents (although it also increases ticket revenue if you put a camera).
A propper traffic light system is not a joke, the Los Angeles synchronized whole-city-traffic light system “increases travel speeds by 16 percent and reduce travel time by 12 percent. And because of reduced idling time, the city says it will save 1 million metric tons of carbon from entering the atmosphere”.
In case you wanna know a bit more about how all this works, here there is a video of the Los Angeles Department of Transportation Automated Traffic Surveillance and Control Center.
Hope next time you see a traffic light, you look at it with different eyes.