Traffic Intersection


The objective of this simulation was to compare traffic flow and waiting times using optimized fixed traffic light timings against intelligent traffic lights using cameras to process the position and speed of the cars present in each side of the intersection. Each side of the intersection has five lanes: two of them will allow cars to turn left, and three will allow cars to go straight. These five lanes are controlled by traffic lights. Moreover, there is an independent lane with no traffic light that will allow cars to turn right.


This model was implemented in AnyLogic using the road traffic library. Figure 1 shows the east road structure for the simulation. There are five lanes that go towards the intersection and one lane that allows cars to turn right. There are also three lanes that go away from the intersection coming from the west or from the north and an additional lane for cars coming from the south. Every side of the intersection works in the exact same way.

Figure 1 – East Road Structure

Additionally, in figure 3 there is a front lane area which defines the cars that are in the first row when the light is red, a 50 meters line that defines how far the camera is able to see and a 100 meters line that is used to analyze accumulation of cars.

Base Scenario

To be able to accurately compare fixed traffic lights with intelligent traffic lights using cameras, it is important to optimize traffic light durations. To do this an Optimization experiment was performed in AnyLogic. The duration of the four green lights are defined as the parameters to change with an objective function equal to the number of cars processed. The duration of the green lights was set to be between 10 and 80 seconds with one-second intervals and setting car arrivals to be fixed to avoid stochastic challenges. The optimal durations of the green lights after the optimization with a total of 7164 processed cars in an hour were:

  • North: 15 seconds
  • West: 10 seconds
  • South: 16 seconds
  • East: 16 seconds

CCTV Scenario – intelligent algorithm

The challenge on this project was to find an algorithm to improve traffic flow. The idea was to find the best way to use cameras effectively and make the right decision in order to improve traffic flow. Several ideas were tested, such as:

  • Using virtual loops to count how much time passes in each line between one car and another. If 2.6 seconds passed in at least three lanes without cars passing through the virtual loops, the traffic light would turn red
  • If there are no cars in the front lane area, the traffic light wouldn’t turn green

Nevertheless, the algorithm that gave the best results is shown in figure 2.

Figure 2 – Intelligent Algorithm

This algorithm has two parameters that need to be optimized in order to be successful. The first one is the maximum number of cars that need to be waiting after the 50meters mark in order to turn the light from green to red and the second is the minimum number of cars to be waiting to turn the light from red to green. Through an optimization experiment, the best values were 13 and 17 seconds respectively.


This study has shown that in this intersection in particular, with a high flow of cars and intense traffic it is possible to use cameras with only 50 meters reach to improve not only the flow of cars but also to decrease waiting times. The algorithm used in this study is very simple and uses basic information to make decisions. The improvement using this algorithm is only of 1.7% of the traffic flow, so the economic implication of having this technology in place should be considered compared to the benefit of having a 1.7% increase in traffic flow.

Project Features

  • Industry: Traffic
  • Model: Discrete Events, Road Traffic Library
  • Duration: 1 month