Fuzzy
Fuzzy
Automobile and other vehicle subsystems, such as ABS and cruise control
(e.g. Tokyo monorail)
Air conditioners
The Massive engine used in the Lord of the Rings films, which helped show
huge scale armies create random, yet orderly movements
Cameras
Digital image processing, such as edge detection
Rice cookers
Dishwashers
Elevartors
Washing machines and other home appliances
Video game artificial intelligence
Massage boards and chat rooms
Fuzzy logic has also been incorporated into some microcontrollers and
microprocessors, for instance Freescale 68HC12.
Specific Fuzzified Applications
Elevators Cranes
Vacuum Cleaners Electric Razors
Hair Dryers Camcorders
Air Control in Soft Television Sets
Drink Production Showers
Noise Detection
on Compact Disks
In the city of Sendai in Japan, a 16-station subway system is
controlled by a fuzzy computer (Seiji Yasunobu and Soji
Miyamoto of Hitachi) the ride is so smooth, riders do not
need to hold straps
Nissan fuzzy automatic transmission, fuzzy anti-skid braking
system
CSK, Hitachi Hand-writing Recognition
Sony - Hand-printed character recognition
Ricoh, Hitachi Voice recognition
Tokyos stock market has had at least one stock-trading
portfolio based on Fuzzy Logic that outperformed the Nikkei
exchange average
Intel Corporation's Embedded Microcomputer Division Fuzzy Logic
Operation
http://www.intel.com/design/mcs96/designex/2351.htm
Conventional model
if temperature > X, run fan
else, stop fan
Fuzzy System -
if temperature = hot, run fan at full speed
if temperature = warm, run fan at moderate speed
if temperature = comfortable, maintain fan speed
if temperature = cool, slow fan
if temperature = cold, stop fan
TRADITIONAL
REPRESENTATION OF LOGIC
bool speed;
get the speed
if ( speed == 0) {
// speed is slow
}
else {
// speed is fast
}
Better (Fuzzy Representation)
Slowest
For every problem
must represent in [ 0.0 0.25 ]
terms of fuzzy sets.
Slow
What are fuzzy sets? [ 0.25 0.50 ]
Fast
[ 0.50 0.75 ]
Fastest
[ 0.75 1.00 ]
Representing Fuzzy Sets
float speed;
get the speed
if ((speed >= 0.0)&&(speed < 0.25)) {
// speed is slowest
}
else if ((speed >= 0.25)&&(speed < 0.5))
{
// speed is slow
}
else if ((speed >= 0.5)&&(speed < 0.75))
{
// speed is fast
}
else // speed >= 0.75 && speed < 1.0
{
// speed is fastest
}
Range of logical values in Boolean and fuzzy logic
Degree of Membership
Name Height, cm Crisp Fuzzy
Chris 208 1 1.00
Mark 205 1 1.00
John 198 1 0.98
Tom 181 1 0.82
David 179 0 0.78
Mike 172 0 0.24
Bob 167 0 0.15
Steven 158 0 0.06
Bill 155 0 0.01
Peter 152 0 0.00
Crisp and fuzzy sets of tall men
Degree of Crisp Sets
Membership
1.0
0.8
Tall Men
0.6
0.4
0.2
0.0
150 160 170 180 190 200 210
Height, cm
Degree of Fuzzy Sets
Membership
1.0
0.8
0.6
0.4
0.2
0.0
150 160 170 180 190 200 210
Height, cm
A fuzzy set is a set with fuzzy boundaries
Let X be the universe of discourse and its elements be
denoted as x. In the classical set theory, crisp set A of X is
defined as function fA(x) called the characteristic function
of A
1, if x A
f A ( x)
0, if x A
This set maps universe X to a set of two elements. For any
element x of universe X, characteristic function fA(x) is equal to 1
if x is an element of set A, and is equal to 0 if x is not an element
of A.
In the fuzzy theory, fuzzy set A of universe X is defined by
function A(x) called the membership function of set A
A(x): X [0, 1], where:
A(x) = 1 if x is totally in A;
A(x) = 0 if x is not in A;
0.4
0.2 Tall
0.0
150 160 170 180 190 200 210
Representation of crisp and fuzzy subsets
(x)
X Fuzzy Subset A
1
0
Crisp Subset A Fuzziness Fuzziness x
hot, too-hot}.
Different Types of Membership
Functions.
There are different forms of membership functions such as triangular,
trapezoidal, Gaussian, or singleton. The most common types of
membership functions are triangular, trapezoidal, and Gaussian
shapes.
Singleton
triangle
Trapezoid
al
Sigmoidal
Trapezoidal Membership Functions
LeftTrapezoid
Left_Slope = 0
Right_Slope = 1 / (A - B)
CASE 1: X < a
Membership Value = 1
CASE 2: X >= b
Membership Value = 0
CASE 3: a < x < b
Membership Value = Right_Slope * (X - b)
RightTrapezoid
Left_Slope = 1 / (B - A)
Right_Slope = 0
CASE 1: X <= a
Membership Value = 0
CASE 2: X >= b
Membership Value = 1
CASE 3: a < x < b
Membership Value = Left_Slope * (X - a)
Regular Trapezoid
Left_Slope = 1 / (B - A)
Right_Slope = 1 / (C - D)
CASE 1: X <= a Or X >= d
Membership Value = 0
CASE 2: X >= b And X <= c
Membership Value = 1
CASE 3: X >= a And X <= b
Membership Value = Left_Slope * (X - a)
CASE 4: (X >= c) And (X <= d)
Membership Value = Right_Slope * (X - d)
Membership functions: S-function
The S-function can be used to define fuzzy sets
S(x, a, b, c) =
0 for x a
2(x-a/c-a)2 for a x b
1 2(x-c/c-a)2 for b x c
1 for x c
Membership functions: Function
(x, a, b) =
S(x, b-a, b-a/2, b) for x b
1 S(x, b, b+a/2, a+b) for x b
Membership functions: S-function
The S-function can be used to define fuzzy sets
Membership functions: Function
Simple membership functions
Piecewise linear: triangular etc.
Easier to represent as e ep ese t and calculate
saves computation
Membership Functions
0
10 30 50 70 90 110
Temp. (F)
Membership Functions
How cool is 36 ?
0
10 30 50 70 90 110
Temp. (F)
Membership Functions
How cool is 36 F ?
It is 30% Cool and 70% Freezing
0.3
0
10 30 50 70 90 110
Temp. (F)
Linguistic Hedges
Modifying the meaning of a fuzzy set using hedges
such as very, more or less, slightly, etc.
Fuzzy sets with the hedge very
Degree of
Membership
1.0
Short Short
Tall
0.8
0.6 Average
0.4
Very Short Very
VeryTall
Tall
Tall
0.2
0.0
150 160 170 180 190 200 210
Height, cm
Representation of hedges in fuzzy logic
Representation of hedges in fuzzy logic
(continued)
Operations of fuzzy sets
The classical set theory developed in the late 19th century by
Georg Cantor describes how crisp sets can interact. These
interactions are called operations.
Cantors sets
Complement
Crisp Sets: Who does not belong to the set?
Fuzzy Sets: How much do elements not belong to the set?
A(x) = 1 A(x)
Containment
Crisp Sets: Which sets belong to which other sets?
Fuzzy Sets: Which sets belong to other sets?
The union of two crisp sets consists of every element that falls
into either set. For example, the union of tall men and fat
men contains all men who are tall OR fat.
In fuzzy sets, the union is the reverse of the intersection. That
is, the union is the largest membership value of the
element in either set.
The fuzzy operation for forming the union of two fuzzy sets A
and B on universe X can be given as:
With logic inference we normally have more than one rule. In fact, the number of
rules can be rather large. We know several methods for fuzzy reasoning
Inference
Input Fuzzifier Defuzzifier Output
Engine
Defuzzifier
Fuzzy
Knowledge base
Defuzzifier
Fuzzy
Knowledge base
Inference
Input Fuzzifier Defuzzifier Output
Engine
Defuzzifier
Fuzzy
Knowledge base
A ( z ) zdz
zCOA Z
,
Z
A ( z )dz
zdz
zBOA zMOM Z
,
A ( z )dz A ( z )dz,
Z
dz
zBOA
where Z {z; A ( z ) *}
A Simple FLS to Control an Air
Conditioner.
Fuzzification
IF a AND b THEN c
IF a AND b THEN c
IF k AND b THEN d
IF a AND g THEN c
IF a AND b THEN f
Fuzzy Disjunction
AB = max(A, B)
AB = C "Quality C is the disjunction of Quality A
and B"
A B
1 1
0.75
0.375
0 0
(AB = C) (C = 0.75)
Fuzzy Conjunction
AB = min(A, B)
AB = C "Quality C is the conjunction of Quality A
and B"
A B
1 1
0.75
0.375
0 0
(AB = C) (C = 0.375)
Example: Fuzzy Conjunction
Calculate AB given that A is .4 and B is 20
A B
1 1
0 0
.1 .2 .3 .4 .5 .6 .7 .8 .9 1 5 10 15 20 25 30 35 40
Example: Fuzzy Conjunction
Calculate AB given that A is .4 and B is 20
A B
1 1
0 0
.1 .2 .3 .4 .5 .6 .7 .8 .9 1 5 10 15 20 25 30 35 40
A B
1 1
0.7
0 0
.1 .2 .3 .4 .5 .6 .7 .8 .9 1 5 10 15 20 25 30 35 40
A B
1 1
0.9
0.7
0 0
.1 .2 .3 .4 .5 .6 .7 .8 .9 1 5 10 15 20 25 30 35 40
A B
1 1
0.9
0.7
0 0
.1 .2 .3 .4 .5 .6 .7 .8 .9 1 5 10 15 20 25 30 35 40
Disjunction of Conjunctions
Inputs: Temperature
0
10 30 50 70 90 110
Temp. (F)
Inputs: Temperature, Cloud Cover
Temp: {Freezing, Cool, Warm, Hot}
0
10 30 50 70 90 110
Temp. (F)
0
0 20 40 60 80 100
Cloud Cover (%)
Output: Speed
Slow Fast
1
0
0 25 50 75 100
Speed (mph)
Rules
0
10 30 50 70 90 110
Temp. (F)
0
0 20 40 60 80 100
Cloud Cover (%)
...Calculating...
If it's Sunny and Warm, drive Fast
Sunny(Cover)Warm(Temp)Fast(Speed)
0.8 0.7 = 0.7
Fast = 0.7
Slow Fast
1
0
0 25 50 75 100
Speed (mph)
Find centroids: Location where membership is 100%
Defuzzification: Constructing the Output
0
0 25 50 75 100
Speed (mph)
Slow Fast
1
0
0 25 50 75 100
Speed (mph)
Slow Fast
1
0
0 25 50 75 100
Speed (mph)
100
s t If Hot
90 Bla then
Blast
80 Fa
st If Warm
then
70 Fast
60
Med If Just Right
ium then
50 Medium
40 IF Cool
Sl
ow then
30 Slow
if Cold
20
then Stop
10
St
o p
1
m
t
l
Ho
o
ar
Co
W
Co
Rig t
ht
Jus
ld
45 50 55 60 65 70 75 80 85 90
Mapping Inputs to Outputs
Defuzzification
After the inference step, the overall result is a fuzzy value. This result
should be defuzzified to obtain a final crisp output. This is the purpose
of the defuzzifier component of a FLS. Defuzzification is performed
according to the membership function of the output variable. For
instance, assume that we have the result in Figure 5 at the end of the
inference. In this figure, the shaded areas all belong to the fuzzy
result. The purpose is to obtain a crisp value, represented with a dot
in the figure, from this fuzzy result
Average maximum
First maximum
Last maximum
u udu Center of gravity
u0 U
u du
U
Defuzzification algorithms
Temperature controller
Having the value of the temperature in the room we
switch on or switch off the fan.
Fuzzy controller
Inference rules
1.if driver young and car power high then risk high
2.if driver young and car power average then risk high
3.if driver medium and car power high then risk average
4.if driver medium and car power average then risk low
Age of the driver Car power
1,2
1,2
1
1
young 0,8 small
0,8
medium 0,6 average
0,6
old high
0,4 0,4
0,2 0,2
0 0
20 30 40 50 60 20 70 120 170 220
0,2
0
0 5 10 15 20 25 30 35 40
Age of a driver
1,2
0,8 young
medium
0,6 old
0,4
0,2
0
20 30 40 50 60
Car power
Car power
1,2
0,8 small
average
0,6
high
0,4
0,2
0
20 70 120 170 220
Insurance company risk low
average
high
assurance risk
1,2
0,8
low
average
0,6
high
0,4
0,2
0
0 5 10 15 20 25 30 35 40
Fuzzy inference rules (mamdami)
1.if driver young and car power high then risk high
2.if driver young and car power average then risk high
3.if driver medium and car power high then risk average
4.if driver medium and car power average then risk low
1.if driver young and car power high then risk high
2.if driver young and car power average then risk high
3.if driver medium and car power high then risk average
4.if driver medium and car power average then risk low
1.if driver young and car power high then risk high
2.if driver young and car power average then risk high
3.if driver medium and car power high then risk average
4.if driver medium and car power average then risk low
2 rules with the
same decision but
different values.
So we have to
choose one decision
by calculation MAX
value
We find rules to activate
We find rules to activate
defuzzification
Center of gravity
Mean of maximum
First maximum
Last maximum
Fuzzy inference rules (mamdami)