# Efficient Intersection Management Based on an Adaptive Fuzzy-Logic Traffic Signal
## 4 Proposed Adaptive Traffic Signal Controller Based on Fuzzy Logic
### Adaptive Mechanism Description  
Reconfiguring a traffic signal at every cycle would be infeasible and inefficient. A short-time traffic monitoring would lead the system to be susceptible to magnifying specific conditions of the dynamics among vehicles, such as sudden delays, underestimating or overestimating the current traffic condition. Conversely, extremely long-time traffic monitoring periods could hide some fluctuations, reducing the reaction capacity of the system. To solve this problem, the proposed controller uses a mechanism that performs the traffic signal reconfiguration every \(\tau\) cycles, where \(3\leq\tau\leq 10\). As a result, the FIS computesthe cycle length \(cl\) by using the flow rates monitored during the time period bounded by \(\tau\), allowing the inference to take into account the effects of the previous configuration.  
For the adaptive mechanism, the traffic signal configuration is defined as a tuple \(TL=(P,D)\), where \(P=\{p_{1},p_{2},\ldots,p_{n}\}\) is a set of phases' descriptors and the set \(D=\{d_{1},d_{2},\ldots,d_{n}\}\) contains the duration assigned to each phase. Each \(p_{i}\in P\) specifies the combinations of movements allowed/disallowed during a time \(d_{i}\) (i.e., green, red, yellow). The combinations of movements and sequence of phases are assumed to be fixed, since both the performance and the safety of a traffic signal can be compromised by the ordinary expectations of local users.  
To achieve a fair traffic signal configuration for the incoming vehicle streams, the computed \(cl\) is proportionally split into the \(p_{n}\) phases according to the flow rates. Such a distribution is derived from the effective green time given by Equation (3). In this sense, the arrival flow rate of each stream \(s_{i}\), retrieved from the on-road sensors, is assumed as the critical flow ratio, and the phase duration \(d_{i}\) is computed by:  
\[d_{i}=\frac{s_{i}}{\sum\limits_{k=1}^{n}s_{k}}cl+y, \tag{6}\]  
where \(s_{k}\in S\) and \(y\) is a predefined value for the duration of yellow interval.  
The mechanism also includes a security rule implemented to avoid the appearance of too short cycles. This rule consists of the establishment of an average preset cycle in the case of atypical values measurements, which are retrieved by the on-road sensors. The aim of this rule is to restrict phases with duration tending to zero. As a result, a minimum phase duration is defined based on a safe pedestrian crossing time when there is no presence of vehicular flow at one of the incoming streams.  
The adaptive mechanism is shown in Algorithm 2.  
```
0:\(TL=(P,D)\)
0: Phases configuration
1:while true do
2:for all traffic streams \(s_{i}\in S\)do
3:\(s_{i}=\textsc{Sensors.retrieveFlowRate}(i)\)
4:endfor
5:ifTrafficLight.CycleRemainingTime() = 0 then
6:\(num\_cycles+=1\)
7:endif
8:if\(num\_cycles==\tau\)then
9:\(num\_cycles=0\)
10:\(cl=\textsc{FuzzyInference}(S)\)
1:*cycle length distribution
11:for each phase \(p_{i}\in P\)do
12:\(d_{i}=\frac{s_{i}}{\sum\limits_{k=1}^{n}s_{k}}cl+y\)
1:*complementary security rule
13:if\(d_{i}<\textsc{min\_phase\_duration}\)then
14:\(d_{i}=\textsc{min\_phase\_duration}\)
15:endif
16:endfor
17:TrafficLight.setNewProgram(\(P,D\))
18:endif
19:endwhile
```  
**Algorithm 2** Adaptive mechanism module.