Keywords

1 Introduction

Traffic light optimization aims to improve the level of service offered on the roads, by reprogramming the traffic light controllers. Optimizing the transition phase or the shift between the signal timing plans can result in minimal travel time. Apart from the result to minimize the delay, queue length, the number of stops, and preventing congestion, traffic optimization will also have impact on promoting greater safety and comfort for road users, improving the quality of life and the economy, i.e., the excessive fuel consumption of vehicles.

The goal of smart cities is to provide a possible solution to reduce the issues caused by the urban population growth and fast urbanization. In this environment, pedestrian crossings are one of the most dangerous places in the transport field. Most of the traffic accidents happen there. In urban areas, especially in inner cities, pedestrians crossing the street unquestionably affect the traffic flows [10], which raises the necessity to include pedestrians in the traffic analysis.

Among all the possible strategies already published in the literature, traffic light programming optimization arises as an interesting choice for urban traffic management, since it is an effective, safe, and low-cost solution [3, 4, 12]. The use of open-source software and simulation guarantees the faithful reproduction of the vehicles in the road system to be optimized.

This article is part of an ongoing research project. The preliminary results obtained in the scope of the project concerning traffic light optimization were promising. They were based on the literature review and some experiments to optimize the waiting time in the one-lane-two-ways traffic light problem, and indicated significant improvements in all aspects considered, in terms of programming languages, simulators, and optimization methods [11, 13].

For this second part of the project, a simulation-based optimization strategy for the traffic light challenge is conducted, using offline real data. The main goal is to improve the traffic light management, in the city center of Guimarães (Portugal). The target of this article is a specific intersection of high intensity of traffic and pedestrian activity, that generates traffic queues, especially at certain times of the day and, consequently, originates delays in travel times, increased gas emissions and high economic expenses.

To achieve the goals, it was eligible for this study the Particle Swarm Optimization (PSO) [2, 5, 8], the Python Programming Language, and the Simulation of Urban Mobility (SUMO) [3, 7], that is a portable microscopic road traffic simulation package that offers the possibility to simulate the traffic moving on the road networks. Based on these methodologies, different simulations are performed to define the number of vehicles that cause traffic congestion. Furthermore, the average waiting time is optimized and the obtained results for the traffic light cycle are compared to real data referring to the current cycle time of the traffic lights.

The paper is organized as follows: Sect. 2 describes the case under study, where Sect. 3 defines the data preparation regarding the problem definition in SUMO and Sect. 4 presents the network system configuration. The computational results are presented and analyzed in Sect. 5. Finally, Sect. 6 rounds up the paper with conclusions and future work.

2 Case Study Description

In the context of the project “Integrated and Innovative Solutions for the well-being of people in complex urban centers”, the main objective is the study and design of a platform to be used as a decision support system capable of integrating data from different sources. The city of Guimarães is one of the target cities of the project. It was found that traffic in the center of Guimarães could be controlled in order to improve the well-being of people and the environment, reducing stress levels and the emission of gases [1]. These objectives can be achieved through the proper regulation of traffic lights.

In particular, a critical situation was identified in the city center of Guimarães where a lot of traffic was observed, generating traffic queues, especially at certain times of the day. Figure 1 shows the intersection responsible for the congestion of the traffic. This figure was obtained from the Street View feature of Google Maps where the location of each traffic light is displayed.

Fig. 1.
figure 1

Intersection in the city center of Guimarães.

The intersection involves five one-way streets. Av. Conde de Margaride, which leads to a traffic light at the point “A” of Fig. 1, Alameda Dr Alfredo Pimenta together with Av. São Gonçalo leads to a traffic light at the point “B”, Rua de Gil Vicente leads to a traffic light at “C”. There is a High school located next to point “D”, so there is a crosswalk regulated by a traffic light. At the beginning of Rua Paio Galvão there is a crosswalk (point “E”), also regulated by traffic lights, with vehicles coming from directions “A” and “B”. This street allows access to the city center.

3 Data Preparation

OpenStreetMap (OSM) is an open source platform formally managed by the OpenStreetMap Foundation that is developed by the contribution of a community of volunteer mappers that constantly update data regarding road network and points of interest all around the globe [9]. The open source traffic simulator SUMO [7] allows to simulate several traffic management topics. Like any other simulation software, it allows the assessment of infrastructure and policy changes before implementation.

In order to obtain the intersection area, presented in Fig. 1, the OpenStreetMap website through the OSM Web Wizard was used. OSM Web Wizard its a python script provided by SUMO that allows the selection of any network on the map and automatically converts it into SUMO. Additional parameters can be set in order to also extract vehicle routes, as well as the number of vehicles that will run during the simulation. After the conversion, it was noticed that the SUMO network did not correspond to the real network, namely, the number of lanes, the possible directions of each lane, the priority between different lanes and the traffic light cycle time, as shown in Fig. 2.

Fig. 2.
figure 2

SUMO network converted from OpenStreetMap: before corrections.

The information about all aspects of the intersection were gathered on-site. Concerning to fix the issues identified data corrections were made. The information regarding the number of lanes, possible directions of each lane and the removal of the option to make a U-turn, were added directly to the OSM platform. Additionally, slight adjustments were made to the positioning of the streets, over the OSM satellite image, to ensure that the streets had the correct length. After the overall correction of the network on OSM, the network files are directly edited, through the graphical network editor provided by SUMO (netedit), so that the model resembles reality.

In the network file, the real traffic light cycle was coded based on measurements carried out on-site. Thus, the cycle times of traffic lights at the intersection are shown in Table 1. The five traffic lights operate in a sequential order of 8 stages, which change according to the duration time and color of the traffic light. In the table, the first column, denoted by “Stage”, refers to the sequential phase of the traffic lights, and the second column shows the time, in seconds, for each stage and the following columns refer to the traffic light color at each point “A” to “E” of Fig. 1.

Table 1. Current stages of the traffic lights in the network under study.

The current fixed cycle, in a total time of 80 s, comprises 8 different stages. At each stage, a distinct set of light colors is present for each traffic light. The cycle starts at Stage 1, where the traffic light at point “A” is green, as well as the traffic lights at points “D” and “E”, and proceeds sequentially until Stage 8. After that, the cycle starts again from Stage 1. Note that Stages 2, 5 and 7 refer to stages with fixed times, due to a mandatory yellow light between the transition of the green to red light with the duration of three seconds. Stages 3 and 8 correspond to a red light at the entry points of the intersection (“A”, “B” and “C”) and a green light on the exit points (“D” and “E”) with a duration of three seconds. The purpose of this stage is to prevent the entry of vehicles and, at the same time, clear the intersection.

Using the editor, the crosswalks were added at points “D” and “E”, as well as the corresponding traffic lights to stop the vehicles. The priority rules between vehicles were also corrected to be in accordance with the Portuguese road code.

The current network system after making all the corrections above described, can be seen in Fig. 3.

Fig. 3.
figure 3

SUMO network converted from OpenStreetMap: after corrections.

4 Network System Configuration

In order to determine the number of vehicles that congest the system network, a simulation of the real scenario was implemented in SUMO. The simulation involved the setting of some parameters in the OSM Web Wizard, namely the “Through Traffic Factor” and the “Count”. The “Through Traffic Factor” defines how many times it is more likely for an edge at the boundary of the simulation area being chosen compared to an edge entirely located inside the simulation area. Thus, in all experiments this parameter value was set to 100 to ensure that each vehicle route starts and ends at the boundary of the system network. The “Count” parameter defines how many vehicles are generated per hour per kilometer. This parameter directly influences the number of vehicles in the system, providing the routes of each vehicle (starting point and final destination), and the time each vehicle enters the simulation.

Hence, several simulations were performed, with different “Count” values to find the number of vehicles that cause congestion in the system, by observing the “Depart Value” (an output value from SUMO) of the vehicles. That is, when the “Depart Value” in one of the cars is greater than zero, it means that there is congestion in the system. Therefore, starting the “Count” value at 10 and increasing it from 10 to 10, simulations were carried out with a duration time of 3600 s seconds of traffic until the “Depart Value” in one of the cars was greater than zero. For each of the simulations, the relationship between the average waiting time and the number of cars in the system was gathered. The waiting time corresponds to the time that each vehicle is stopped due to external factors like traffic lights and queues. Figure 5 shows the evolution of the average waiting time (in seconds) over the increasing number of vehicles in the network system.

Fig. 4.
figure 4

Evolution of the average waiting time (in seconds) as the number of vehicles in the network system increases.

It can be seen that when the number of vehicles is greater than 1200 the average value of the waiting time increases considerably. When the parameter “Count” was set to 310, corresponding to a number of vehicles of 1440, a congestion on the traffic was verified and the average value of the waiting time was 68.69 s.

Another situation of the current network system was simulated in order to study the impact that crosswalks can have on traffic flow. This version consists of removing the traffic lights from the crosswalks at points “D” and “E”. When the network system does not include crosswalks, the color of traffic lights at points “D” and “E” in Table 1 is represented by a green light for all stages. Figure 5 shows the evolution of the average waiting time (in seconds) relatively to the increase in the number of vehicles, when the crosswalks (and corresponding traffic lights) were not included in the network system.

Fig. 5.
figure 5

Evolution of the average waiting time (in seconds) as the number of vehicles in the network system increases, without configuring the crosswalks.

A similar performance of the average waiting time was obtained for a traffic congestion with the same number of vehicles (1440 vehicles), when compared to the results presented in Fig. 4. However, in this version (without configuring crosswalks) the average waiting time reduced to 56.05 s, as expected.

5 Computational Results

5.1 Implementation Details

The strategy herein described intends to optimize the average waiting time of the system with 1440 vehicles, which corresponds to congested traffic, in order to obtain the optimal traffic light cycle times for the network. The simulation-based optimization strategy is developed as a two-step routine: the optimization algorithm and the simulation process. It consists of an interaction between the PSO algorithm, a global optimization algorithm that searches for optimal, or near-optimal, solutions of the traffic light cycle times, and the SUMO software to evaluate the solutions found by the PSO [11]. Figure 6 graphically shows this interaction. Each time PSO finds a traffic light cycle configuration, SUMO proceeds to test it and returns the average waiting time of each vehicle to find new configurations. Each time PSO finds a new traffic light cycle configuration, SUMO proceeds to test it and returns the average waiting time of each vehicle. In this way, after evaluating the solutions, PSO can compute new configurations. This cycle is repeated until the stopping criteria is reached.

Fig. 6.
figure 6

Interaction between the PSO and SUMO.

In order to use the PSO algorithm, a set of predefined parameters should be set. The parameters that influence the behaviour of each particle, namely the inertia weight, cognitive and social constants were set to 0.729, 1.49445 and 1.49445, respectively, as suggested in [11]. The number of PSO particles was set to 20 and the maximum number of iterations was set to 50. Due to the stochastic nature of the PSO algorithm, 30 independent runs were performed.

Regarding the network system presented in Fig. 3, the python code was updated to embrace the new variables and the new network SUMO file. Some other small changes have also been made to the model before running the simulation-based optimization strategy. According to the Portuguese standards for application on urban streets, the recommended green light phase time for a pedestrian to cross the road (equivalent to the red light phase to stop the vehicles) must be calculated considering a walking velocity of 0.4 m/s [6]. In this case, since each crosswalk is approximately 6 m long, the total time for Stage 6 plus Stage 7 should be 15 s. Furthermore, since Stage 6 and Stage 7 are directly connected to the crosswalk traffic light, as can be seen in Table 1, the minimum duration of Stage 6 should be 12 s. Thus, the bounds of the values on the variables representing the time, in seconds, for the Stages 1, 4 and 6 are [0, 80], [0, 80] and [12, 80], respectively.

The results were obtained using a PC running Windows 10 operating system equipped with AMD Ryzen 7 4800H CPU @ 2.90 GHz, 16 GB RAM.

5.2 Results and Discussion

The simulation-based optimization process obtained, on average, an average waiting time of 15.16 s, with a standard deviation of 0.11. The average execution time was 2119.99 s (about 35 min). The results of the best solution are presented in Table 2, where the first column shows the stage indicating the phase of the traffic lights, and the second column shows the obtained time, in seconds, for each stage. The last columns refer to the traffic light color at each point “A” to “E”. The best solution obtained a time of 27.63 s for Stage 1, 22.70 s for Stage 4 and 12 s for Stage 6, with an average value of the waiting time of 14.99 s. Thus there is a reduction of 78.2% against an average waiting time value of 68.69 s in the real scenario (see Sect. 4).

Table 2. Optimized traffic light times for the network under study.

To better analyze the traffic evolution during the simulation, a comparison of the number of vehicles in the system is made between the best optimized run and the real scenario. In Fig. 7, at 1500 s of the simulation, the real scenario starts to accumulate traffic inside the network until 3600 s, the moment where vehicles stop entering the simulation. On the other hand, the optimized scenario ensures an excellent traffic flow that never generates problematic traffic queues.

Fig. 7.
figure 7

Number of vehicles in the system along the simulation time of 3600 s, in the optimized scenario and in the real scenario.

In order to analyze the impact that crosswalks can have on traffic flow, the version without configuring the crosswalks was also studied. Note that when the network system does not include crosswalks, the color of traffic lights at points “D” and “E” are green light for all stages.

Among the 30 runs, on average, the average waiting time was 8.02 s with a standard deviation of 0.12. The standard deviation values obtained with and without the configuration of the crosswalks show that the model used can produce consistent results. The running time among the 30 runs took on average 2000.41 s (about 35 min). The best solution obtained the traffic light time of 14.30 s for Stage 1, 9.66 s for Stage 4 and 0 s for Stage 6. Note that when the crosswalks are not included, the Stage 6 should not exist, since it corresponds to the green traffic light at point “C”. The best solution for the version without configuring the crosswalks reached an average waiting time of 7.72 s. When comparing this result with the average waiting time at the same situation in the real scenario (average waiting time of 56.05 s) a reduction of 86.2% was observed (see Sect. 4).

Figure 8 shows the number of vehicles in the system along the simulation time of 3600 s. A similar result can be observed, where about 1500 s of the simulation, the real scenario starts to have traffic congestion.

Fig. 8.
figure 8

Number of vehicles in the system along the simulation time of 3600 s, in the optimized scenario and in the real scenario, without configuring the crosswalks.

6 Conclusions

Urban mobility is an emerging challenge that drives contemporary cities towards smart solutions. In this context, traffic light optimization allows an interesting strategy for urban traffic management, while improving the level of service offered on the roads by reprogramming the traffic light controllers. Optimizing the transition phase or the shift between the signal timing plans can result in reduced travel time. Apart from the result of preventing traffic congestion, traffic light optimization will also have the impact of promoting greater safety for road users, and the environment, i.e., reducing the gases and fuel consumption of vehicles.

This research presented a real case study of traffic light simulation-based optimization strategy in the city center of Guimarães (Portugal). A specific intersection of high traffic intensity and pedestrian activity was studied, which generates traffic queues, especially during specific hours of the day. In order to be able to simulate vehicle traffic scenarios in a real way, the data referring to the current cycle time of the traffic lights were collected directly at street level, and methodologies such as PSO, Python, and SUMO were used.

The computational results showed it is possible to reduce the average waiting time from 68.69s (real) to 14.99s, meaning a reduction of 78.2%. In addition, the average waiting time can be decreased from 56.05s to 7.72s, if the traffic lights are removed from the crosswalks - 86.2% of improvement was observed.

When comparing the results of the simulations in the two situations, on average, in the optimized scenario with crosswalks the number of vehicles at each instant is 30, while in the scenario without crosswalks the average number of cars is insignificantly lower. Therefore, it is clear that the crosswalks are not the cause of congested traffic in that area. By better managing the traffic light cycle time, it is possible to obtain a situation where the number of cars in the system remains constant, generating a traffic flow without queue accumulation and without congestion. This confirms that traffic light optimization is an effective, safe, and low-cost management solution. The future work of this project will be based on the Online Traffic Optimization in a city, surrounding a larger area of traffic.