
Abstract
Fuzzy Rules
Fuzzy Control
1)Fuzzification(Using membership functions to graphically describe a situation)
Step 1
An application of these rules is shown using specific values for angle and angular
velocities. The values are seen in the following graphs.
This part of the article 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
The first sensor behind each traffic light counts the number cars coming to the intersection
and the latter 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.
Crisp Output={Sum(Membership Degree*Singleton Position)}/(Membership degree)
For example, if the output membership degree, after rule evaluation are:
Is Fuzzy Controller better ?
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.
The Smart Air Conditioner: automatically adjusts the flow of air
according to the surrounding temperature. The Smart TV: adjusts its contrast and colour
modes for every new frame. The Smart Washing Machine: adds more detergent when
there is more dirt. All with the push of a button. Great!!! We are witnessing
a miracle in technology. Too good to be true. But enough!!! How do such miracles
occur? How complicated is the math ? HOW DOES IT WORK!!!!
This article describes the procedures required in designing fuzzy logic machines starting
with the basics, fuzzy rules, moving on to the fuzzy controller and finally
considering a case study where a real life useful application of fuzzy
logic is applied.
Human beings make descisions based on rules. Even though, we may not be aware
of it, all the descisions we make are based on computer like
if-then statements. If the weather is fine, then we may decide to go out.
If the forecast says the weather will be bad today, but fine tommorow, then
we make a descision not to go today, and postpone it till tommorow. Rules associate ideas and relate one event to another.
Fuzzy machines, which always tend to mimick the behaviour of man, work the same
way. Only this time the descision and the means of choosing that descison are
replaced by fuzzy sets and the rules are replaced by fuzzy rules. Fuzzy rules
also operate using a series of if-then statements. For instance,
X then A, if y then b, where A and B are all sets of X and Y.
Fuzzy rules define fuzzy patches, which is the key idea in fuzzy logic.
A machine is made smarter using a concept
designed by Bart Kosko called the Fuzzy Approximation Theorem(FAT). The FAT theorem
generally states a finite number of patches can cover a curve as seen in
the figure below. If the patches
are large, then the rules are sloppy. If the patches are small then the rules are fine.

Fuzzy control, which directly uses fuzzy rules is the most important application in fuzzy theory.
Using a procedure originated by Ebrahim Mamdani in the late 70s, three steps are taken
to create a fuzzy controlled machine:
2)Rule evaluation(Application of fuzzy rules)
3)Defuzzification(Obtaining the crisp results)
As a simple example on how fuzzy controls are constructed, consider
the following classic situation:
the inverted pendulum. Here, the problem is to balance a
pole on a mobile platform that can move in only two directions, to the
left or to the right. The angle between the platform and the pendulum
and the angular velocity of this angle are chosen as the inputs of the system.
The speed of the platform hence, is chosen as the corresponding output.
First of all, the different levels of output (high speed, low speed etc.) of the platform
is defined by specifying the membership functions for the fuzzy_sets. The graph of the function shown below

Similary, the different angles between the platform and the pendulum and...

the angular velocities of
specific angles are also defined 
Step 2
The next step is to define the fuzzy rules. The fuzzy rules are mearly a series of if-then statements
as mentioned above. These statements are usually derived by an expert to
achieve optimum results. Some examples of these rules are:
i) If angle is zero and angular velocity is zero then speed is also zero.
ii) If angle is zero and angular velocity is low then the speed shall be low.
The full set of rules is summarised in the table below.
Speed
Angle ------------
negative high
negative low
zero
positive low
positive high
v negative high
------------ -----------
negative high
--------- --------- -----
e negative low --------- ---------
negative low zero --------
l zero negative high negative low
zero positive low positive high
o positive low --------- zero low ----------- ---------
c --------- high ----------
--------- ----------


As seen in the figure above the result patch yielded by the rule "if angle is zero and angular velocity
is zero, the speed is zero", is a bit tricky since there are two variables relating
to one point. The actual
value belongs to the fuzzy set zero to a degree of 0.75 for "angle" and 0.4 for
"angular velocity". Hence, since this is an AND operation, the minimum criterion is
used , and the fuzzy set zero of the variable "speed" is cut at 0.4 and the patches
are shaded up to that area. This is illustrated in the figure below.

The following figures show the result patches yielded by the rule "if angle is zero and angular velocity
is negative low, the speed is negative low", "if angle is positive low and angular velocity
is zero, then speed is positive low" and "if angle is positive low and angular velocity
is negative low, the speed is zero".

The four results are overlaps and is reduced to the following figure

Step 3: The result of the fuzzy controller so far is a fuzzy set (of speed). To
choose an appropriate representative value as the final output(crisp values), defuzzification must be done.
This can be done in many ways, but the most common method used is the
center of gravity of the set as shown below.
Case Study: Fuzzy Traffic Light Controller

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 disatnce 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 ar 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:
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
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.
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!!!!
© Shahariz Abdul Aziz ISE2 1996
References
Author: Bart Kosko
Author: Dr. Devinder Kaur, Elisa Konga, Esa Konga, University of Toledo
Author: M. Jamishi et al
Author: K. Nakamura
Author: H. J. Zimmerman
Please e-mail suggestions to Shahariz bin Abdul Aziz
<sbaa@doc.ic.ac.uk>
.