Module-2
Module-2
A7710-Soft Computing
Fuzzy logic
A7710-Soft Computing
What is Fuzzy logic?
Yes or No
Crisp answer
True or False
Banana Yes
Orange
Crisp
A fruit
Apple
No
Grapes
Is the fruit
citrus?
May be
May not be
Partially
etc
Score
99
Extremely honest
• Mr. A
• Ms. B
Very honest 75
• Mrs. C
Fuzzy
• Mr. D 55
Honest at times
• Mrs. E
Extremely dishonest 35
Is the person
honest?
Fuzzy element(s)
Fuzzy set(s)
I
N
P Fuzzy rule(s)
U
T
Fuzzy implication(s)
(Inferences)
O
U
T
Fuzzy system P
U
T
Universe of discourse U
1 EX = Marks ≥ 90
2 A = 80 ≤ Marks < 90
B = 70 ≤ Marks < 80
C = 60 ≤ Marks < 70
5 D = 50 ≤ Marks < 60
6 P = 35 ≤ Marks < 50
7 F = Marks < 35
F P D C B A EX
1
0
35 50 60 70 80 90 100
F P D C B A EX
1
0
35 50 60 70 80 90 100
High Temperature
Low Pressure
Color of Apple
Sweetness of Orange
Weight of Mango
Note:
µA(x) map each element of X onto a membership grade (or
membership value) between 0 and 1 (both inclusive).
Question:
How (and who) decides µA(x) for a Fuzzy set A in X ?
A = City of comfort
A ={(0,0.1),(1,0.30),(2,0.78)……(10,0.1)}
1.0
0.8
0.6 Note : X = discrete value
µ
0.4
0.2
How you measure happiness ??
0 2 4 6 8 10
A = “Happy family”
1.0
B (x) = 1
x −50
4
0.8
1+
0.6 10
0.4
0.2
0 50 100
B
Age (X)
Note : x = real value
B = “Middle aged” = R+
Core: The core of a fuzzy set A is the set of all points x in X such that
µA (x) = 1
1.0
µ
0.5
1.0
Aα = { x | µA (x) ≥ α }
Aα ’ = { x | µA (x) > α }
Note :
• A is convex if all its α- level sets are convex.
• Convexity (Aα) =⇒ Aα is composed of a single line segment only.
Membership function is Non-convex
convex Membership function
1.0 1.0
Bandwidth :
For a normal and convex fuzzy set, the bandwidth (or width) is defined
as the distance the two unique crossover points:
Bandwidth(A) = | x1 - x2 |
where µA(x1) = µA(x2) = 0.5
Symmetry :
Example: India will win the T20 tournament with a chance 60% means
that out of 100 matches, India own 60 matches.
Forecasting : When you take the information from the past job and
apply it to new job.
1.0 1.0
0.8 0.8
µA
µB
0.6 0.6
0.4 0.4
0.2 0.2
0 2 4 6 8 10 0 10 20 30 40 50 60
µ
µ
x x x
x x
0 if x ≤ a
x−a if a ≤ x ≤ b
triangle(x ; a, b ,c ) = b−a
(1)
c−x
c−b
if b ≤ x ≤ c
0 if c ≤ x
1.0
a b c
1 if x ≤ a
x−a if a ≤ x ≤ b
b−a
trapeziod(x; a,b,c,d) = 1 if b ≤ x ≤ c (2)
d−x
d−c if c ≤ x ≤ d
0 if d ≤ x
1.0
a b c d
A6560-Soft Computing
Soft Computing Applications
Fuzzy MFs: Gaussian
gaussian(x;c,σ) =e —2( ) 2.
1 x−c
σ
c
0.1
0.1c 0.9c
b
Slope at x =
2a
b
Slope at y = −
b 2a
x y
c-a c c+a
1
Example: µ(x)= 1+x 2 ;
a = b = 1 and c = 0;
1.0
-1 0 1
Changing a Changing b
Changing a
Changing a and b
1.0
Slope = a
0.5
Excellent = Marks ≤ 90
Very good = 75 ≤ Marks ≤ 90
Good = 60 ≤ Marks ≤ 75
Average = 50 ≤ Marks ≤ 60
Poor = 35 ≤ Marks ≤ 50
Bad= Marks ≤ 35
1
.8
.6
.4
.2
0
10 20 30 40 50 60 70 80 90
marks
You can decide a standard fuzzy MF for each of the fuzzy garde.
Operations on Fuzzy Sets
Union (A ∪B):
Example:
A = {(x 1, 0.5), (x2, 0.1), (x3, 0.4)} and
B = {(x 1, 0.2), (x2, 0.3), (x3, 0.5)};
C = A ∪B = { (x1, 0.5), (x2, 0.3), (x3, 0.5)}
µA µA
µB µB
µ µAUB
a p x b q c a p x b q c
Intersection (A ∩B):
Example:
A = {(x 1, 0.5), (x2, 0.1), (x3, 0.4)} and
B = {(x 1, 0.2), (x2, 0.3), (x3, 0.5)};
C = A ∩B = { (x1, 0.2), (x2, 0.1), (x3, 0.4)}
µA
µB
µ
µAᴖB
a p x b q c a p x b q c
Complement (AC ):
Example:
A = {(x 1, 0.5), (x2, 0.1), (x3, 0.4)}
C = AC = {(x 1, 0.5), (x2, 0.9), (x3, 0.6)}
µA µA
1.0 µA’
p x q p x q
Sum (A + B):
Difference (A − B = A ∩BC ):
Equality (A = B):
µA (x) = µB (x)
Example 3:
A(x) = {(x 1, 0.2), (x2, 0.3), (x3, 0.5), (x4, 0.6)}
B(y) = {(y 1, 0.8), (y2, 0.6), (y3, 0.3)}
y1 y2 y3
x1 0.2 0.2 0.2
0.3 0.3 0.3
A × B = min{ µA (x), µB (y)} =
x2
x3 0 .5 0.5 0.3
x4 0.6 0.6 0.3
Commutativity :
A∪B = B∪A
A∩B = B∩A
Associativity :
A ∪(B ∪C) = (A ∪B) ∪C
A ∩(B ∩C) = (A ∩B) ∩C
Distributivity :
A ∪(B ∩C) = (A ∪B) ∩(A ∪C)
A ∩(B ∪C) = (A ∩B) ∪(A ∩C)
De Morgan’s law :
(A ∩B) c = Ac ∪Bc
(A ∪B) c = Ac ∩Bc
Let A and B are two fuzzy sets defined over a universe of discourse X
with membership functions µA(x ) and µB (x ), respectively. Two MFs
µA(x) and µB (x ) are shown graphically.
µA(x)
µB µA
µ
b1 a1 a2 b4 a3 a4
x
µB µA
b1 a1 a2 b4 a3 a4
x
AB ( )x
AB ( )x
a2 b4
b1 a1 a2 a3 a4
x
x
The plots of union µA¯(x ) of the fuzzy set A is shown in the following.
( )x
A ( )x
A
a b a b
x x
Consider the following two fuzzy sets A and B defined over a universe
of discourse [0,5] of real numbers with their membership functions
µA (x) = x
1+x and µB (x) = 2−x
i. A , B
ii. A ∪B
iii. A ∩B
iv.(A ∪ B) c [Hint: Use De’ Morgan law]
µA µB
1.0
0.5
µ
-15 -10 -5 0 5 10 15 20 25 30 35 40 45
50
x
3 Extreme climate
4 Pleasant climate
Note: Note that ”Not cold climate” /= ”Hot climate” and vice-versa.
0.
AB
5
µ
- -
15 10 -5 0 5 10 15 20 25 30 35 40 45 50
5 15 25 5 25
x
x x
Dilation:
Ak = [µA (x)]k ; k < 1
Example : Age = { Young, Middle-aged, Old }
Thus, corresponding to Young, we have : Not young, Very young, Not
very young and so on.
Similarly, with Old we can have : old, very old, very very old, extremely
old etc.
Thus, Extremely old = (((old) 2 ) 2 ) 2 and so on
Or, More or less old = A0.5 = (old) 0.5
Soft Computing Applications
Linguistic variables and values
Very Old
Very young
0 30 60 100
X = Age
µmiddle−aged = bell(x,30,60,50)
Not young = µyoung (x) = 1 − µyoung (x)
Young but not too young = µyoung (x) ∩µyoung (x)
Soft Computing Applications
Questions??
A7710-Soft Computing
Fuzzy Relations
Crisp relations
Note :
(1) A × B /= B × A
(2) |A × B| = |A| × |B|
(3)A × B provides a mapping from a ∈ A to b ∈ B.
3 5 7
1 0 0 0
2 1 0 0
R=
3 0 0 0
4 0 1 0
Intersection:
Complement:
R(x,y) = 1 − R(x,y)
Example:
Suppose, R(x, y) and S(x, y) are the two relations define over two
crisp sets x ∈ A and y ∈ B
0 1 0 0 1 0 0 0
0 0 1 0 0 1 0 0
R= and S = ;
0 0 0 1 0 0 1 0
0 0 0 0 0 0 0 1
Find the following:
1 R ∪S
2 R ∩S
3 R
Max-Min Composition
Given the two relation matrices R and S, the max-min composition is
defined as T = R ◦S ;
Suppose
A is a fuzzy set on the universe of discourse X with µA(x)|x ∈ X
B is a fuzzy set on the universe of discourse Y with µB (y )|y ∈ Y
Then R = A × B ⊂ X × Y ; where R has its membership function given
by µR (x,y) = µA×B (x,y) = min{ µA (x),µB (y)}
Example :
A = {(a 1, 0.2), (a2, 0.7), (a3, 0.4)}and B = {(b 1 , 0.5), (b2, 0.6)}
b1 b2
a1 0.2 0.2
R =A× B = a2 0.5 0.6
a3 0.4 0.4
Intersection:
µR (a,b) = 1 − µR (a,b)
Composition
T = R ◦S
µR◦S = maxy∈Y { min(µR (x,y),µS (y,z))}
(Binary) fuzzy relations are fuzzy sets A × B which map each element
in A × B to a membership grade between 0 and 1 (both inclusive).
Note that a membership function of a binary fuzzy relation can be
depicted with a 3D plot.
(x, y)
Important: Binary fuzzy relations are fuzzy sets with two dimensional
MFs and so on.
Hint:
The basic assumption upon which crisp logic is based - that every
proposition is either TRUE or FALSE.
a b ∧ ∨ ¬a =⇒ =
0 0 0 0 1 1 1
1 1 1
0 2 0 2 1 1 2
0 1 0 1 1 1 0
1 1 1 1 1
2 0 0 2 2 2 2
1 1 1 1 1 1
2 2 2 2 2 2 1
1 1 1 1
2 1 2 1 2 1 2
1 0 0 1 1 0 0
1 1 1 1
1 2 2 1 1 2 2
1 1 1 1 1 1 1
Example 1:
P : Ram is honest
Intelligent: {(x 1, 0.3), (x2, 0.4), (x3, 0.1), (x4, 0.6), (x5, 0.9)}
We define a fuzzy proposition as follows:
P : x is intelligent
The canonical form of fuzzy proposition of this type, P is
expressed by the sentence P : v is F .
Predicate in terms of fuzzy set.
P : v is F ; where v is an element that takes values v from some
universal set V and F is a fuzzy set on V that represents a fuzzy
predicate.
In other words, given, a particular element v , this element belongs
to F with membership grade µF (v ).
Debasis Samanta (IIT Kharagpur) Soft Computing Applications 15.01.2016 27 / 64
Graphical interpretation of fuzzy proposition
F ( )v
P: v is F
T(P)
T(P) = µF(v) for a v ε V
v V
If x is A then y is B
P = { 1,2,3,4} and T ={ 10, 15, 20, 25, 30, 35, 40, 45, 50 }
Let the linguistic variable High temperature and Low pressure are
given as
THIGH =
{(20, 0.2), (25, 0.4), (30, 0.6), (35, 0.6), (40, 0.7), (45, 0.8), (50, 0.8)}
PLOW = (1,0.8),(2,0.8),(3,0.6),(4,0.4)
A entails B
T-norm operator
The most frequently used T-norm operators are:
Minimum : Tmin (a,b) = min(a,b) = a ∧b
Algebric product : Tap (a,b) = ab
Bounded product : Tbp (a,b) = 0 ∨ (a + b − 1)
a if b=1
Drastic product : Tdp = b if a=1
0 if a,b < 1
Here, a = µA(x ) and b = µB (y ). T∗ is called the function of T-norm operator.
Min operator:
∫
Rm = A × B = X ×Y
µA(x) ∧µB (y )| (x,y) or f min (a,b) = a ∧b
[Mamdani rule]
Propositional calculus :
R : A → B = Ā ∪ (A ∩ B)
Rmm = (A × B) ∪ (Ā × Y )
1 2 3 4
a 1 1 1 1
0.2 0.2 0.2 0.2
Ā × Y =
b
c 0.4 0.4 0.4 0.4
d 0 0 0 0
Therefore,
1 2 3 4
a 1 1 1 1
0.2 0.8 0.8 0.2
Rmm = (A × B) ∪ (Ā × Y ) =
b
c 0.4 0.6 0.6 0.4
d 0.2 1.0 0.8 0
X = { a,b,c,d}
Y = { 1,2,3,4}
Let, A = { (a,0.0),(b,0.8),(c,0.6),(d,1.0)}
B = { (1,0.2),(2,1.0),(3,0.8),(4,0.0)}
Determine the implication relation :
If x is A then y is B
1 2 3 4
a 0 0 0 0
b 0.2 0.8 0.8 0
Here, A × B =
c 0.2 0.6 0.6 0
d 0.2 1.0 0.8 0
1 2 3 4
a 1 1 1 1
0.2 0.2 0.2 0.2
and Ā × Y =
b
c 0.4 0.4 0.4 0.4
d 0 0 0 0
1 2 3 4
a 1 1 1 1
Rmm = (A × B) ∪ (Ā × Y ) =
b 0.2 0. 0.8 0.2
c 8
d 0.4 0. 0.6 0.4
6
This R represents If x is A then y is B 0.2 1. 0.8 0
0
IF x is A THEN y is B ELSE y is C.
The relation R is equivalent to
R = (A × B) ∪ (Ā × C)
X = { a,b,c,d}
Y = { 1,2,3,4}
A = { (a,0.0),(b,0.8),(c,0.6),(d,1.0)}
B = { (1,0.2),(2,1.0),(3,0.8),(4,0.0)}
C = { (1,0),(2,0.4),(3,1.0),(4,0.8)}
Determine the implication relation :
If x is A then y is B else y is C
1 2 3 4
a 0 0 0 0
b 0.2 0.8 0.8 0
Here, A × B =
c 0.2 0.6 0.6 0
d 0.2 1.0 0.8 0
1 2 3 4
b
a 00 0.2
0.4 0.2
1.0 0.2
0.8
and Ā × C =
c 0 0.4 0.4 0.4
d 0 0 0 0
1 2 3 4
a 0 0.4 1.0 0.8
b 0.2 0.8 0.8 0.2
R=
c 0.2 0.6 0.6 0.4
d 0.2 1.0 0.8 0
{
If x is A then y is B else y is C
{ {
Given
1 C ∨D
2 ∼ H =⇒ (A∧ ∼ B)
3 C ∨D =⇒∼ H
4 (A∧ ∼ B) =⇒ (R ∨S)
Similar concept is also followed in fuzzy logic to infer a fuzzy rule from
a set of given fuzzy rules (also called fuzzy rule base).
′ ′
Here, A,B,A and B are fuzzy sets.
′ ′
To compute the membership function A and B the max-min
′ ′
composition of fuzzy sets B and A ,respectively with R(x, y)
(which is the known implication relation) is to be used.
Thus,
′ ′
B = A ◦R(x,y) µB (y) = max[min(µA′ (x),µR (x,y))]
′ ′
A = B ◦R(x,y) µA (x) = max[min(µB′ (y),µR (x,y))]
P : If x is A then y is B
If x is A Then y is B
′
x is A
————————————–
′
y is B
′ ′
We are to find B = A ◦R(x, y) where R(x, y) = max{A × B, A × Y }
y1 y2 y1 y2
x1 0.5 0.4 x1 0.5 0.5
A× B = x2 1 0.4 and A × Y = x2 0 0
x3 0.6 0.4 x3 0.4 0.4
y1 y2
x1 0.5 0.5
R(x,y) = (A × B) ∪ (A × y) = x2 1 0.4
x3 0.6 0.4
′
Now, A = { (x1,0.6),(x2 ,0.9),(x3,0.7)}
′ ′
Therefore, B = A ◦R(x,y) =
0.5 0.5
0.6 0.9 0.7 ◦ 1 0.4 = 0.9 0.5
0.6 0.4
′ ′
Thus we derive that y is B where B = {(y 1, 0.9), (y2, 0.5)}
P: If x is A Then y is B
′
Q: y is B
— — — — — — — — — — — — — —
′
x is A
Given that :
Let,
X = {30, 40, 50, 60, 70, 80, 90, 100} be the set of temperatures.
Y = {10, 20, 30, 40, 50, 60} be the set of rotations per minute.
H = { (70,1),(80,1),(90,0.3)}
VH = { (90,0.9),(100,1)}
S = { (30,0.8),(40,1.0),(50,0.6)}
QS = { (10,1),(20,0.8)}
R = (H × S) ∪ (H × Y )
A7710-Soft Computing
Defuzzification
What is defuzzification?
Example 1:
Suppose, THIGH denotes a fuzzy set representing temperature is
High.
THIGH is given as follows.
THIGH = (15,0.1), (20, 0.4), (25,0.45), (30,0.55), (35,0.65),
(40,0.7), (45,0.85),(50,0.9)
What is the crisp value that implies for the high temperature?
(x)
R1: If x is A then y is C
R2: If x is B then y is D
A pictorial representation of the above rule base is shown in the
following figures.
C
1.0 1.0
A B
x’
D
x y
What is the crisp value that can be inferred from the above rules given
′
an input say x ?
Debasis Samanta (IIT Kharagpur) Soft Computing Applications 17.01.2016 5 / 55
Why defuzzification?
Example:
Here, may be input THIGH is fuzzy, but action rotate should be based
on the crisp value of RFIRST .
1 Lambda-cut method
3 Maxima methods
4 Centroid methods
A1 = { (x1,0.9),(x2,0.5),(x3,0.2),(x4,0.3)}
Then A0.6 = {(x 1, 1), (x2, 0), (x3, 0), (x4, 0)} = {x 1 }
and
A2 = { (x1,0.1),(x2,0.5),(x3,0.8),(x4,0.7)}
µ(x) x1 x2 x3 x4 x5
P 0.1 0.2 0.7 0.5 0.4
Q 0.9 0.6 0.3 0.2 0.8
The Lambda-cut method for a fuzzy set can also be extended to fuzzy
relation also.
Example: For a fuzzy relation R
1 0.2 0.3
R = 0.5 0.9 0.6
0.4 0.8 0.7
We are to find λ-cut relations for the following values of
λ = 0,0.2,0.9,0.5
1 1 1 1 1 1
R0 = 1 1 1 and R0.2 = 1 1 1 and
1 1 1 1 1 1
1 0 0 1 0 0
R0.9 = 0 1 0 and R0.5 = 1 1 1
0 0 0 0 1 1
If A and B are two fuzzy sets, defined with the same universe of
discourse, then
1 (A ∪B) λ = Aλ ∪Bλ
2 (A ∩B) λ = Aλ ∩Bλ
If R and S are two fuzzy relations, defined with the same fuzzy sets
over the same universe of discourses, then
5 (R ∪S) λ = Rλ ∪Sλ
6 (R ∩S) λ = Rλ ∩Sλ
7 (R) λ /= R λ
Lambda-cut method converts a fuzzy set (or a fuzzy relation) into crisp
set (or relation).
The output of a fuzzy system can be a single fuzzy set or union of two
or more fuzzy sets.
1 R1: If x is A1 then y is C1
2 R2: If x is A2 then y is C2
C2
1.0 1.0
A C1
B
0 1 2 3 4 5 6 0 1 2 3 4 5 6 7 8
x y
x1 x2 x3
1.0 1.0
A C
B
0 1 2 3 4 5 6 0 1 2 3 4 5 6 7 8
x1 y
x
Fuzzy output for x = x1
1.0 1.0
A
C
B
0 1 2 3 4 5 6 0 1 2 3 4 5 6 7 8
x = x2 y
x
Fuzzy output for x = x2
1.0 1.0
A
B C
0 1 2 3 4 5 6 0 1 2 3 4 5 6 7 8
y
x = x3
x
Fuzzy output for x = x3
Centroid methods
1 Center of gravity method (CoG)
2 Center of sum method (CoS)
3 Center of area method (CoA)
Centroid methods
1 Center of gravity method (CoG)
2 Center of sum method (CoS)
3 Center of area method (CoA)
c
Note:
1. Here, x ∗ is the height of the output fuzzy set C.
2. This method is applicable when height is unique.
Debasis Samanta (IIT Kharagpur) Soft Computing Applications 17.01.2016 28 / 55
Maxima method : FoM
c
c
Σ
(xi )
x∗ = xi ∈M
|M|
where, M = {x i |µ(xi ) = h(C)} where h(C) is the height of the fuzzy set
C
c
x∗ = a+b
2
Note:
Thus, MoM is also synonymous to middle of maxima.
MoM is also general method of Height.
Debasis Samanta (IIT Kharagpur) Soft Computing Applications 17.01.2016 33 / 55
Defuzzification Technique
Centroid Methods
Cenroid methods
Following defuzzification methods are known to calculate crisp output.
Maxima Methods
1 Height method
2 First of maxima (FoM)
3 Last of maxima (LoM)
4 Mean of maxima(MoM)
Centroid methods
1 Center of gravity method (CoG)
2 Center of sum method (CoS)
3 Center of area method (CoA)
3 Graphically,
Center of gravity
c
x*
x
Note:
1 x ∗ is the x-coordinate of center of gravity.
∫
2 µC (x)dx denotes the area of the region bounded by the curve
µC .
A4
A3
A2
A1 A5
A6
x1 x2 x3 x4 x5 x6
x
2 Let Ai and xi denotes the area and c.g. of the i-th portion.
3 Then x ∗ according to CoG is
Σn
x∗ = i=1 xi .(Ai )
Σ n
i=1 Ai
where n is the number of smaller geometrical components.
Debasis Samanta (IIT Kharagpur) Soft Computing Applications 17.01.2016 38 / 55
CoG: An example of integral method of calculation
c2
1.0 1.0
c1
0.7 0.7
c
c 0.5
1
2
0.5
0 1 2 3 4 5 0 1 2 3 4 5 6
x x
C = C1 C 2
d e
1.0
b c
0.7
c
0.5
A1 A2 A3 A4 A5
f
a
0 1 2 2.7 3 4 5 6
For A1 : y − 0 = 0.7 (x
2
− 0), or y = 0.35x
For A2 : y = 0.7
For A3 : y − 0 = 1− 0 (x
3− 2
− 2), or y = x − 2
For, A4 : y = 1
For, A5 : y − 1 = 0− 1 (x
6− 4
− 4), or y = −0.5x + 3
,
x.µ (x)dx
Thus, x ∗ = , c = N
µc (x)dx D
∫ ∫ ∫3 ∫
N = 02 0.35x 2dx + 22.7 0.7x 2dx + 2.7 (x 2 − 2x)dx + 34 xdx +
∫6
4
(−0.5x 2 + 3x)dx
= 10.98
∫2 ∫ 2.7 ∫3 ∫4 ∫6
D= 0
0.35xdx + 2
0.7xdx + 2.7
(x −2)dx + 3
dx + 4
(−0.5x +3)dx
= 3.445
Thus, x ∗ = 10.98
3.445
= 3.187
Σn
x∗ = i=1 xi .Aci
Σn
i=1 Aci
Here, Aci denotes the area of the region bounded by the fuzzy set Ci
and xi is the geometric center of the area Aci .
Graphically,
c2
c3
c1
A2 A3
A1
5
x1 x2 x3
Note:
2 In CoS, we use the center of area and hence, its name instead of
center of gravity as in CoG.
Consider the three output fuzzy sets as shown in the following plots:
c 1 1.0
c 2
0.5 0.5
c3 0.5
0.3
0.25 0.25 0.25
0 1 2 3 4 5 6 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
x x x
c 1.0
c
1
0.5
2
0.5
c 3 0.5
0.3
0.25 0.25 0.25
0 1 2 3 4 5 6 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
x x x
Note:
The crisp value of C = C1 ∪C2 ∪C3 using CoG method can be found
to be calculated as x ∗ = 4.9
Debasis Samanta (IIT Kharagpur) Soft Computing Applications 17.01.2016 45 / 55
Centroid method: Certer of largest area
If the fuzzy set has two subregions, then the center of gravity of the
subregion with the largest area can be used to calculate the
defuzzified value.
, ′
µ (x).x dx
Mathematically, x ∗ = , cm ;
µcm (x)dx
′
Here, Cm is the region with largest area, x is the center of gravity of
C m.
Graphically,
C1 C3
C2
Cm = C3 x'
Centroid methods
1 Center of gravity method (CoG)
2 Center of sum method (CoS)
3 Center of area method (CoA)
where, C1, C2, ...Cn are the output fuzzy sets and (xi ) is the value
where middle of the fuzzy set Ci is observed.
Graphically,
k1 C3
k2 C1
C2
k3
x1 x2 x3
Find the crisp value of the following using all defuzzified methods.
C2
1.0
C1
0.5
1 2 3 4 5 6
Find the crisp value of the following using all defuzzified methods.
C2
1.0
C3
0.75
C1
0.5
1 2 3 4 5 6 7 8 9 10
1.0
0.5
narrow wide
1.0
0.5
0.4
5 6 7 8 9 10
If a road with its degree of membership value is 0.4 then what will
be its width (in crisp) measure.
1.0 1.0
1.0 1.0
0.5 0.5
0.5 0.5
0.3
0 1 2 3 4 5 6 7 8 9 10 x 0 1 2 3 4 5 6 7 8 9 10 x 0 1 2 3 4 5 6 7 8 9 10
x
A7710-Soft Computing
Applications of Fuzzy Logic
Fuzzy Controller
Defuzzification actions
module Input
Output
Fuzzification
module Conditions
4 a defuzzification module.
1 Mamdani approach
O2
O3
D
O1 O4
R S
D 1.0
VN NR FR VF 1.0
0.0
1.04
0.1 0.8 1.5 2.2
Distance D in mt
LT AL AA AR RT
LT AL AA AR RT
1.0 1.0
0.0 0.0
-90 -45 0 45 90 -90 -45 0 45 90
Once the fuzzy sets of all parameters are worked out, our next step in
FLC design is to decide fuzzy rule base of the FLC.
The rule base for the FLC of mobile robot is shown in the form of a
table below.
LT AL AA AR RT
VN AA AR AL AL AA
NR AA AA RT AA AA
FR AA AA AR AA AA
VF AA AA AA AA AA
Note that this rule base defines 20 rules for all possible instances.
These rules are simple rules and take in the following forms.
For this input, we are to decide the deviation δof the robot as
output.
From the given fuzzy sets and input parameters’ values, we say
that the distance D = 1.04m may be called as either NR (near) or
FR (far).
NR FR AA AR
1.0 1.0
0.0 0.0
0.1 0.8 1.5 2.2 0 45
-45 y
x
1.04 30
NR FR AA AR
1.0 1.0
0.0 0.0
0.1 0.8 1.5 2.2 45
-45 0
y
x
1.04 30
Thus, x
1
= 1.5− 1.04 ,
1.5−0.8
that is, x = 0.6571
y
x
1
2
There are many rules in the rule base and all rules may not be
applicable.
For the given x = 1.04 and θ= 30o , only following four rules out of 20
rules are firable.
The strength (also called α values) of the firable rules are calculated as
follows.
α(R1) = min(µNR (x ), µ AA(y )) = min(0.6571, 0.3333) = 0.3333
α(R2) = min(µNR (x ), µAR (y )) = min(0.6571, 0.6667) = 0.6571
In practice, all rules which are above certain threshold value of rule
strngth are selected for the output computation.
Suppose, s1∗and s2∗are the inputs for fuzzy variables s1 and s2. µA1,
µA2, µ B1, µ B2, µ C1 and µ C2 are the membership values for different
fuzzy sets.
A2 B2 C 2 C
Combine output
s1* s2*
Note:
1.0
R1 :
0.3333
0.0
0.8 1.5 0 45 45 90
NR AR
1.0 AA
R2 :
0.6571
0.0
0.8 1.5 0 45 -45 0 45
AA AR
1.0
R3 :
0.3333
0.0
0 45 90
0.8 1.5 0 45
1.0 AR AA
R4 :
0.3333
0.0
-45 0 45
0.8 1.5 0 45
D=1.04 Ɵ= 30
AA AR RT
-45 0 45 90
The fuzzy output needs to be defuzzified and its crisp value has to be
determined for the output to take decision.
v= 12.5×71+25×45+25.56×0+25.56×0 = 19.59
12.5+39.79+25+25.56
39.7/0
AA AR RT
1.0
0.5 A3
.6571 0.34 A2
A4 0.3333
A1
-45 0 45 90
25/45 12.5 / 71
25.56 / 0
Consider two inputs I1 and I2. These two inputs have the following
linguistic states :
Note:
I1 I 2
L M H NR FR VF
1.0 1.0
c)For the input set, following four rules can be fired out of all 9 rules.
R1: I1 is L and I2 is FR
R2: I1 is L and I2 is VF
R3: I1 is M and I2 is FR
R4: I1 is M and I2 is VF
d)Now, the weights for each of the above rules can be determined as
follows.
R1: w 1 = µ L × µ FR = 0.8 × 0.8 = 0.6
R2: w 2 = µ L × µ VF = 0.8 × 0.2 = 0.16
R3: w 3 = µ M × µ FR = 0.2 × 0.8 = 0.16
R4: w 4 = µ M × µ VF = 0.2 × 0.2 = 0.6
e)The functional consequent values for each rules can be calculated
as below.
y 1 = I1 + 2I2 = 6.0 + 2 × 2.2 = 10.4
y 2 = I1 + 3I2 = 6.0 + 3 × 2.2 = 12.6
y 3 = 2I1 + 2I2 = 2 × 6.0 + 2 × 2.2 = 16.4
y 4 = 2I1 + 3I2 = 2 × 6.0 + 3 × 2.2 = 18.6