2. Materials and Methods
We have set up a traffic system with simulation that models two adjacent intersections equipped with traffic lights, each controlled by a separate fuzzy logic controller. The two intersections are positioned side by side, simulating a scenario where two neighboring junctions are present along a road network. At each intersection, we employ a fuzzy logic controller to manage traffic flow. These controllers consider inputs such as the number of vehicles in red and green lanes and the maximum waiting time in red lanes. The goal is to optimize traffic flow and reduce congestion by controlling the timing of traffic light changes.
Figure 1.
An illustration of 2 interconnected traffic light intersections during a FIS-Sumo controlled simulation.
Figure 1.
An illustration of 2 interconnected traffic light intersections during a FIS-Sumo controlled simulation.
One unique aspect of our simulation is that the traffic lights at both intersections switch synchronously. This switching ensures coordination between the intersections, allowing for a smooth flow of traffic along the main horizontal road. Furthermore, priority is given to the road, which is the main thoroughfare, ensuring that it has an advantage over side roads. This prioritization is achieved by setting longer green phases for the main road, allowing for uninterrupted traffic flow along this crucial route. By implementing two fuzzy logic controllers working synchronously, and coordinating the traffic lights between adjacent intersections, our simulation aims to replicate real-world traffic management strategies and evaluate their effectiveness in improving traffic flow and reducing congestion.
The simulation models two adjacent intersections equipped with traffic lights, each controlled by a separate fuzzy logic controller. The two intersections are positioned side by side, simulating a scenario where two neighboring junctions are present along a road network. At each intersection, we employ a fuzzy logic controller to manage traffic flow. These controllers consider inputs such as the number of vehicles in red and green lanes and the maximum waiting time in red lanes. The goal is to optimize traffic flow and reduce congestion by controlling the timing of traffic light changes.
Figure 2.
An illustration of 2 interconnected intersections with 2 lanes in each direction implemented in SUMO.
Figure 2.
An illustration of 2 interconnected intersections with 2 lanes in each direction implemented in SUMO.
One unique aspect of our simulation is that the traffic lights at both intersections switch synchronously. This switching ensures coordination between the intersections, allowing for a smooth flow of traffic along the main horizontal road. This prioritization is achieved by setting longer green phases for the horizontal road, allowing for uninterrupted traffic flow along this crucial route.
In our research, the Simulation of Urban Mobility (SUMO) version 1.9.2 was utilized. SUMO is an open-source, highly portable, and microscopic traffic simulation package designed to handle large road networks. The simulation involves two intersections, each with two lanes in either direction, connected horizontally, as shown in the
Figure 1. Traffic is generated to enter the simulation road network at all six lane entries, as shown in a snapshot of the setup in SUMO.
Traffic Control Interface (Traci) was used to integrate SUMO with the fuzzy logic controller. Traci facilitates communication between SUMO and the Python-based fuzzy controller, which is implemented using SciKit Fuzzy and NumPy libraries. This interface allows the simulation to send real-time traffic data to the fuzzy controller, such as the number of cars and their waiting times.
Fuzzy logic controller uses three inputs: the number of vehicles in the red lanes, the number of vehicles in the green lanes, and the maximum waiting time of vehicles in the red lanes. These inputs are processed by the fuzzy controller to evaluate the current traffic conditions. Fuzzy controller's outputs determine whether the traffic lights at either intersection should be toggled. By adjusting the traffic light timings based on real-time data, the system aims to improve traffic flow and reduce waiting times at the intersections.
Simulation runs for a specified duration of 1000 steps. During this period, vehicles are generated at a rate of [vehicles per hour] and introduced into the network at predefined locations such as A, B, etc. The types of vehicles, including their size and speed, are varied to reflect realistic traffic conditions, with speeds set to [Vehicle Speed Range] and sizes categorized as [Vehicle Size Categories]. The probability of vehicles changing lanes or turning at intersections is defined as [Probability Values].
To ensure robust statistical analysis, each simulation is repeated 10 times under identical conditions. The data collected from these repetitions are then analyzed to evaluate the performance of the fuzzy logic controller.
In a standard SUMO simulation, default settings govern the behavior and characteristics of vehicles within the simulated environment. The default vehicle type, typically referred to as "passenger" or "passenger car," embodies the archetype of a typical car found on city streets. With a length averaging between 4 to 5 meters and a width of around 2 meters, these vehicles reflect the dimensions of everyday passenger cars. Their speed parameters, often set within a range of 10 to 20 meters per second (36 to 73 km/hour), mirror the typical velocities encountered in urban traffic. Additionally, the default behavior includes the probability of lane changing, capturing the dynamic nature of traffic flow, and a standard turning behavior at intersections, enabling vehicles to navigate left, right, or straight-ahead based on the road network layout and traffic signals [
12]. The default setting for lane changing behavior is typically governed by the lane change model specified in the simulation configuration. By default, SUMO uses the "LC2013" lane change model, which is based on the Intelligent Driver Model (IDM) and the MOBIL lane change model. These default settings provide a foundational framework for simulating realistic traffic scenarios within SUMO, facilitating nuanced analysis and experimentation in urban mobility research and planning.
To ensure robust statistical analysis, each simulation is repeated 10 times under identical conditions. The data collected from these repetitions is then analyzed to evaluate the performance of the controller.
The fuzzy logic controller was implemented using SciKit Fuzzy (skfuzzy). The fuzzy logic controller accepts three inputs: the number of vehicles on the red lanes (no_vehicle_red_lane), the number of vehicles on the green lanes (no_vehicle_green_lane), and the maximum waiting time of vehicles on the red lanes (waiting_time_red_lane).
We defined the number of vehicles using an array of integers from 0 to 22. Then we used three types of membership functions to define the memberships. Values from 0 to 8 were defined as "Low" using a z-shaped membership function (zmf). Values from 2 to 18 were defined as "Moderate" using a triangular membership function (trimf). Values from 12 to 20 were defined as "High" using an s-shaped membership function (smf).
Figure 3.
Memberships functions representing the number of vehicles in the Red/Green Lane.
Figure 3.
Memberships functions representing the number of vehicles in the Red/Green Lane.
Waiting time was defined using an array of integers from 0 to 80. From our network, we found that the maximum waiting time of vehicles before the traffic light switches falls within the range of 0 to 80. We used three types of membership functions to define the memberships. Waiting times from 0 to 30 were defined as "negligible" using a z-shaped membership function (zmf). Waiting times from 10 to 70 were defined as "Medium" using a triangular membership function (trimf). Waiting times from 50 to 80 were defined as "Alot" using an s-shaped membership function (smf).
Figure 4.
An illustration of fuzzy memberships functions representing the Waiting Time of vehicles in red lane.
Figure 4.
An illustration of fuzzy memberships functions representing the Waiting Time of vehicles in red lane.
The output of the fuzzy logic controller is a value between 0 and 1, implemented by passing an array containing 0 and 1 as the consequent. If the output is 0, then the traffic light is “okay”; if it is 1, then it needs switching. The output is defined using two membership functions: "okay" with a z-shaped membership function (zmf) from 0 to 0.5, and "need-switching" with an s-shaped membership function (smf) from 0.5 to 1.
Figure 5.
An illustration of fuzzy memberships functions representing the Traffic Light Signal membership function.
Figure 5.
An illustration of fuzzy memberships functions representing the Traffic Light Signal membership function.
These sets of antecedents and consequents were grouped into fuzzy rules used to create the control system. The control system was then simulated and used to compute outputs based on the three inputs. The output of the fuzzy logic controller is a value from 0 to 1. The output zero indicates that the traffic controller is okay, and the value one means that the controller needs switching. When running the simulation, the output usually falls between 0.3 and 0.7, so we set a bar at 0.5. If the output is below 0.5, the traffic light will not be changed; otherwise, it would be switched.
Based on the evaluation of the fuzzy logic controller implemented in the provided code, it can be inferred that a more intelligent traffic light control system holds the potential to enhance throughput at intersections and diminish overall traffic congestion. Typically, prioritizing certain vehicles entails imposing additional waiting time on others, termed as "unprioritized" vehicles. However, in this project, no such delay was observed for unprioritized vehicles. Consequently, the average waiting time for unprioritized vehicles decreased, reduction in their average waiting time. Furthermore, there was a notable increase in the average number of moving vehicles within the intersection, accompanied by a reduction in the number of vehicles halted by traffic signals.
Algorithm 1. FLC Control algorithm Pseudocode
| Algorithm 1: Interaction Between Simulator and Fuzzy Controller |
Input: T, τ, λ, ν_range, σ_categories, p_lane_change, p_turn Output: Traffic flow and waiting time statistics Initialize simulator Initialize fuzzy controller Define road network and entry points Generate vehicles at rate λ for t = 0 to T do if t mod τ == 0 then lanes_currently_moving, lanes_stopped_by_light ← getLaneLists(lanes_in_D1B2, lanes_in_G2H1, trafficLightID) vehicles_in_red_lanes ← getVehiclesIn Lane(lanes_stopped_by_light) vehicles_in_green_lanes ← getVehiclesInLane(lanes_cur rently_mov ing) N_r ← len(vehicles_in_red_lanes) N_g ← len(vehicles_in_green_lanes) W_max ← getMaxWaitingTime(vehicles_in_red_lanes) output ← fuzzyControllerFunction(N_r, N_g, W_max) if output ≥ θ then toggleTrafficLights(trafficLightID) end if end for closeSimulator() |
The Algorithm 1 pseudocode outlines the interaction between a traffic simulation system and a fuzzy logic controller to manage traffic flow at intersections. Initially, the simulator and fuzzy controller are initialized, and the road network and entry points are defined. Vehicles are generated at a specified rate to enter the network. The main simulation loop runs from time t=0 to t=T. At every interval τ, the simulator updates the number of vehicles on red and green lanes (Nr and Ng) and the maximum waiting time on the red lanes (Wmax). These parameters are passed to the fuzzy controller, which processes them and returns an output. If the output exceeds a predefined threshold θ, the traffic lights are toggled. The simulator then proceeds to the next simulation step, and data is collected for analysis. After completing the simulation, the system closes, the collected data, and the results are outputted.
Figure 6.
Control Flow Chart.
Figure 6.
Control Flow Chart.
The flow chart given in the
Figure 5 outlines the process for a fuzzy logic-based traffic control simulation. The simulation begins with initialization, setting the step count to zero. The system continuously checks the traffic light state, collecting data on vehicles in both green (moving) and red (stopped) lanes. Depending on the traffic light ID, it determines which lanes are moving or stopped. The core of the simulation runs in a loop until 1000 steps are reached, during which the system applies a Fuzzy Inference System (FIS) to control the traffic lights based on the real-time vehicle data. Every
n step, the traffic lights may be toggled according to fuzzy logic rules. This dynamic approach aims to optimize traffic flow by adjusting signals based on current conditions, thereby reducing vehicle waiting times. The simulation concludes once the step count reaches nmax, effectively ending the process. This flow chart demonstrates a structured methodology for enhancing traffic management using fuzzy logic. Fuzzy logic controller (FLC) was implemented in Python using the scikit-fuzzy library, a powerful tool for fuzzy logic systems. This implementation involved several key steps. Firstly, the input and output variables were defined, including linguistic terms and their associated membership functions. For example, input variables such as 'no_vehicle_red_lane' and 'waiting_time_red_lane' were defined with terms like 'Low', 'Moderate', and 'High', each with appropriate membership functions. Next, fuzzy rules were established to govern the system's behavior, specifying how inputs should be mapped to outputs. These rules were constructed based on expert knowledge of traffic flow dynamics. Once the rules were defined, a control system was created to simulate the FLC's behavior using the Control System class provided by scikit-fuzzy. Finally, the controller was integrated into the larger traffic simulation environment, interacting with the SUMO traffic simulator via the TraCI interface. This implementation allows for real-time traffic control decisions based on fuzzy logic principles, offering an effective and adaptive solution for managing complex traffic scenarios.