# Case Study: Fuzzy Traffic Light Controller

This part of the report describes the design procedures of a real life application of fuzzy logic: A Smart Traffic Light Controller. The controller is suppose to change the cycle time depending upon the densities of cars behind green and red lights and the current cycle time.

Background
In a conventional traffic light controller, the lights change at constant cycle time, which is clearly not the optimal solution. It would be more feasible to pass more cars at the green interval if there are fewer cars waiting behind the red lights. Obviously, a mathematical model for this decision is enormously difficult to find. However, with fuzzy logic, it is relatively much easier.
Fuzzy Design
First, eight incremental sensors are put in specific positions as seen in the diagram below.

The first sensor behind each traffic light counts the number cars coming to the intersection and the second counts the cars passing the traffic lights. The amount of cars between the traffic lights is determined by the difference of the reading of the two sensors. For example, the number of cars behind traffic light North is s7-s8.
The distance D, chosen to be 200ft., is used to determine the maximum density of cars allowed to wait in a very crowded situation. This is done by adding the number of cars between to paths and dividing it by the total distance. For instance, the number of cars between the East and West street is (s1-s2)+(s5-s6)/400.
Next comes the fuzzy descision process which uses the three step mentioned above(fuzzyification, rule evaluation and defuzzification).
Step 1
As before, firstly the inputs and outputs of the design has to be determined. Assuming red light is shown to both North and South streets and distance D is constant, the inputs of the model consist of :
1) Cycle Time
2)Cars behind red light
3) Cars behind green light
The cars behind the light is the maximum number of cars in the two directions. The corresponding ouput parameter is the probabilty of change of the current cycle time. Once this is done, the input and output parameters are divided into overlapping member fuctions, each function corresponding to different levels. For inputs one and two the levels and their corresponding ranges are zero(0,1), low(0,7), medium(4,11), high(7,18), and chaos(14,20). For input 3 , the levels are ver short(0,14), short(0,34), medium(14,60), long(33,88), very long(65,100), limit(85,100). The levels of output are no(0), probably no(0.25), maybe(0.5), probably yes (o.75), and yes(1.0). Note: For the output, one value(singleton position) is asosciated to each level instead of a range of values. The corresponding graphs for each of these membersip function is drawn in the similar way above.
Step 2
The rules, as before are formulated using a series of if-then statements, combined with AND/OR opearotors. Ex: if cycle time is medium AND Cars Behind Red is low AND Cars Behind Green is medium, then change is Probably Not. With three inputs, each having 5,5,and 6 membership functions, there are a combination of 150 rules. However using the minimum or maximum criterion some rules are combined to a total of 86.
Step 3
This process, also mentioned above converts the fuzzy set output to real crisp value. The method used for this system is center of gravity:

Crisp Output={Sum(Membership Degree*Singleton Position)}/(Membership degree) For example, if the output membership degree, after rule evaluation are:
Change Probability Yes=0, Change Probability Probably Yes=0.6, Change Probability Maybe=0.9, Change Probability Probably No= 0.3, Change Probability No=0.1
then the crisp value will be: Crisp Output=(0.1*0.00) +(0.3*0.25)+(0.9*0.50)+(0.6*0.75)+(0*1.00)/0.1+0.3+0.9+0.6+0 =0.51

Is Fuzzy Controller better ?
Testing of the controller
The fuzzy controller has been tested under seven different kinds of traffic conditions from very heavy traffic to very lean traffic. 35 random chosen car densities were grouped according to different periods of the day representing those traffic conditions.
Performance evaluation
The performace of the controller was compared with that of a conventional controller and a human expert. The criteria used for comparison were number of cars allowed to pass at one time and average waiting time. A performance index which maximises the traffic flow and reduces the average waiting time was developed. A means of calculating the average waiting time was also developed, however, a detailed calculation of this evaluation is beyond the scope of this article. All three traffic controller types were compared and can be summarized with the following graph of performance index in all seven traffic categories.

Performance Index for 7 different traffic catagories

Conclusion
The fuzzy controller passed through 31% more cars, with an average waiting time shorter by 5% than the theoretical minimum of the conventional controller. The performance also measure 72% higher. This was expected. However, in comparison with a human expert the fuzzy controller passed through 14% more cars with 14% shorter waiting time and 36% higher performance index. Result: Machine beats Man!!!!

In conclusion, as Man gets hungry in finding new ways of improving our way of life, new, smarter machines must be created. Fuzzy logic provides a simple and efficient way to meet these demands and the future of it is limitless.