Post on 18-Mar-2020
transcript
Fuzzy Logic
Dr. Chi-Tai, ChengUniversity of Manitoba
Outline
• What is Fuzzy Logic?
• History and applications of Fuzzy Logic
• Fuzzy Control– Fuzzification
– Fuzz Inference Mechanism
– Fuzzy Knowledge Base
– Defuzzification
• Hand calculation of Fuzzy Control
• Fuzzy Control Paper Otte and Baltes
What is Fuzzy Logic?
• Traditional logic system: (Crisp set)– Item does or doesn’t belong to a group
(1, 0)• Human• Sports
Not Human
Human Hockey Basketball
What is Fuzzy Logic?
• Fuzzy logic system:– Degree of a set [1, 0]
• Cold/Hot• Rich/Poor• Teenager/ ...
What is Fuzzy Logic?
Traditional logic system
Characteristic function
1
0
1
0
Fuzzy logic systemMembership function
What is Fuzzy Logic?
• Example: • Input: Angle of Shot, Distance of Shot• Output: Chance of Success
Small Normal Big
Close Normal Good Chance
Good Chance
Normal No Chance Normal Good Chance
Far No Chance No Chance Normal
History and applications of Fuzzy Control
• Fuzzy logic was first proposed by Lotfi A. Zadeh of the University of California at Berkeley in a 1965 paper.
• Mid-1980, “ inverted pendulum” experiment.
History and applications of Fuzzy Control
History and applications of Fuzzy Control
ZE PS PBNB
NS
History and applications of Fuzzy Control
• When can we use Fuzzy Control?
History and applications of Fuzzy Control
• Fuzzy and Probability
History and applications of Fuzzy Control
• Continuous values [0, 1]• Big and complicated problems• Not explicitly defined mathematical
problems• Human reasoning - linguistic
variables
Jacky’s Assignment
Fuzzy set
μA : X [ 0,1 ] , memebership function of A
A={ x , μ A x ∣x∈X }, fuzzy set
μA x ∈[ 0,1 ] , degree of membership1
0
A : Teenager
13 1911 21
Fuzzy set
• Support set
• Core
• Crossover point
• Height 0
13 1911 21
Supp A={x∣μ A x 0,∀ x∈X }
Core A={x∣μ A x =1,∀ x∈X }
μ x =0 .5
Height A =maxx∈ X
μA x
1A : Teenager
α-cut sets
• α-cut setsX : Universal set , A = F X , α∈[ 0, 1 ]Aα={x∣μ A x ≥α ,∀ x∈X }
0
1
χ Aα x ={1 if x∈Aα μA x ≥α
0 if x∉Aα μA x α
α= 0 . 5
Membership function
• Discrete membership function• Continuous membership function
– Triangular shape– Trapezoid– S function– Z function– Pi function– Bell shape
Discrete membership function
Triangular shape
μA x ={0 for x≤a1
x−a1
a−a1
for a1¿ x≤a
b1− xb1−a
for a≤x≤b1
0 for b1 ¿ x0
1
a1 a b1
Trapezoid
μA x ={0 for x≤a1
x−a1
a−a1
for a1 ¿ x≤a
1 for a≤x≤bb1−xb1−b
for b≤ x≤b1
0 for b1 ¿ x 0
1
a1 a b b1
S function
• monotonical increasing
S x ;α , β , γ ={0 for x≤α
2x−α
γ−α2 for α≤x≤β
1−2 x−γ
γ−α2 for β≤ x≤γ
1 for γ≤ x
Z function
Z x ;α , β , γ ={1 for x≤α
1−2x−α
γ−α2 for α≤ x≤β
2 x−γ
γ−α2 for β≤x≤γ
0 for γ≤ x
Pi function
Π x ; β , γ ={ S x ;γ−β , γ−β
2, γ for x≤γ
1−S x ;γ , γβ
2, γβ for x≥γ
Bell shape
μA x =1
1∣x−c
a∣2b
c
1
Relation
• Binary relational matrix• Example: Standard weight
60 70 80 90
150 1 0 0 0
160 0 1 0 0
170 0 0 1 0
180 0 0 0 1
60 70 80 90
150 1 0.6 0.2 0
160 0.6 1 0.6 0.2
170 0.2 0.6 1 0.6
180 0 0.2 0.6 1
Traditional logic Fuzzy logic
Traditional Logic Operator
• Brothers & Classmates
Brother Classmates
A={Albert, Bill, Carl, David }B={Eason , Foster , Grand }
Eason
Foster
Grand
Albert 0 1 0
Bill 0 0 1
Carl 0 0 0
David 1 0 0
Eason
Foster
Grand
Albert 0 1 1
Bill 0 1 0
Carl 1 0 1
David 1 1 0
Traditional Logic Operator - Union
• Relationship for who are brothers OR classmates (Union) => max(A, B)
Eason
Foster
Grand
Albert 0 1 0Bill 0 0 1Carl 0 0 0David 1 0 0
Eason
Foster
Grand
Albert
0 1 1Bill 0 1 0Carl 1 0 1David 1 1 0
∪ =
Eason Foster Grand
Albert 0 1 1
Bill 0 1 1
Carl 1 0 1
David 1 1 0
Traditional Logic Operator - Intersection
• Relationship for who are brothers AND classmates (Intersection) => min(A, B)
Eason
Foster
Grand
Albert 0 1 0Bill 0 0 1Carl 0 0 0David 1 0 0
Eason
Foster
Grand
Albert
0 1 1Bill 0 1 0Carl 1 0 1David 1 1 0
∩ =
Eason Foster Grand
Albert 0 1 0
Bill 0 0 0
Carl 0 0 0
David 1 0 0
Fuzzy Logic Operator
• B Taller & Heavier than A
Taller Heavier
A={Albert, Bill, Carl, David }B={Eason , Foster , Grand }
Eason
Foster
Grand
Albert
0.8 0 0.9
Bill 1 0.8 1
Carl 0.1 0 0.7
David
0.7 0 0.8
Eason
Foster
Grand
Albert
0.4 0.9 0.3
Bill 0 0.4 0
Carl 0.9 0.5 0.8
David
0.6 0.7 0.5
Fuzzy Logic Operator - Union
• Relationship for B are taller OR heavier (Union) => max(A, B)
Eason
Foster
Grand
Albert 0.8
0 0.9
Bill 1 0.8
1
Carl 0.1
0 0.7
David 0.7
0 0.8
Eason
Foster
Grand
Albert 0.
40.9
0.3
Bill 0 0.4
0
Carl 0.9
0.5
0.8
David 0.
60.7
0.5
¿ =
Eason Foster Grand
Albert 0.8 0.9 0.9
Bill 1 0.8 1
Carl 0.9 0.5 0.8
David 0.7 0.7 0.8
Fuzzy Logic Operator - Intersection
• Relationship for B are taller AND heavier (Union) => min(A, B)
Eason
Foster
Grand
Albert 0.8
0 0.9
Bill 1 0.8
1
Carl 0.1
0 0.7
David 0.7
0 0.8
Eason
Foster
Grand
Albert 0.
40.9
0.3
Bill 0 0.4
0
Carl 0.9
0.5
0.8
David 0.
60.7
0.5
=
Eason Foster Grand
Albert 0.4 0 0.3
Bill 0 0.4 0
Carl 0.1 0 0.7
David 0.6 0 0.5
¿
Composition operationComposition operation
• Example
A={Harry, Ister, Jerry }B={Kalman, Luffy, Mickey}C={Hockey, Lab}
Harry
Ister Jerry
Kalman
0.8 0 0.3
Luffy 0.6 0.9 0.9
Mickey
0 0.2 1
Hockey
Lab
Harry 0.9 0
Ister 0.2 0.4
Jerry 0.7 0.9
Composition operationComposition operation
• Where will we meet Kalman, Luffy and Mickey tomorrow?
Harry
Ister Jerry
Kalman
0.8 0 0.3
Luffy 0.6 0.9 0.9
Mickey
0 0.2 1
Hockey
Lab
Harry 0.9 0
Ister 0.2 0.4
Jerry 0.7 0.9
Hockey
Lab
Kalman
0.8 0.3
Luffy 0.7 0.9
Mickey 0.7 0.9
Fuzzy Control
Fuzzy Inference Mechanism
Fuzzification Defuzzification
Fuzzy Knowledge Base
Controlled system
Crisp
Process Output Actual Control
CrispFuzzyTerms
FuzzyTerms
Fuzzy Control
• Fuzzification• Fuzzy Knowledge Base• Fuzzy Inference Mechanism• Defuzzification
Fuzzification
• Fuzzification transforms crisp values into grades of membership for linguistic terms of fuzzy sets.– Example: Shooting Success Rate : input
1->Angle
Fuzzy Knowledge Base
• Use linguistic variables to build the IF-THEN rules in Fuzzy Knowledge Base.
• Example: Shooting Success Rate
KnowledgeBase
Distance
Close Normal Far
Angle
Small NormalNo
Chance
NoChanc
e
Normal
GoodChance
NormalNorma
l
BigGood
ChanceGood
Chance
GoodChanc
e
Fuzzy Inference Mechanism
• Combines the fuzzy terms obtained from the fuzzification with the rule base and data base
• Min-Max
R1 :IF X1 is A 11 AND X2 is A 21 THEN Y is B1
R2 :IF X1 is A12 AND X 2 is A22 THEN Y is B2
X 1
X 1 X 2
X 2
Y
Y
Y
x1 is A11
x1 is A12
x 2 is A21
x 2 is A22
y is B1
y is B2
B*
Defuzzification – Crisp Value
• Weighted Average Defuzzification
u∗¿∑
i
mi⋅w i
∑i
w i
Defuzzification – Fuzzy Set
• Center of Gravity DefuzzificationDiscrete Continuous
u∗¿
∑i
μ x i ⋅x i
∑i
μ x i u∗¿
∫x
μ x ⋅xdx
∫x
μ x dx
xμ∗¿¿
xμ∗¿¿
Defuzzification
0.80.50.4
1 2 3 Output
1
1×0 . 52×0 . 83×0 . 40 .50 . 80 . 4
=1 . 94
Defuzzification
0.80.50.4
1 2 3 Output
1
1×0 . 52×0 . 83×0 . 40 .50 . 80 . 4
=1 . 94
Center of Gravity Defuzzification
∑ x -CoG ⋅μ x =0
∑ x−∑CoG ⋅μ x =0
∑ x⋅μ x −∑ CoG⋅μ x =0
∑ x⋅μ x −CoG∑ μ x =0
∑ x⋅μ x =CoG∑ μ x
CoG=∑ x⋅μ x
∑ μ x
Example
KnowledgeBase
Distance
Close Normal Far
Angle
Small NormalNo
Chance
NoChanc
e
Normal
GoodChance
NormalNorma
l
BigGood
ChanceGood
Chance
GoodChanc
e
NormalGoodChanc
e
NoChanc
e
0.5 10
Input 1: Shooting Angle
Input 2: Shooting Distance
Output:Shooting Success Rate
• Use Shooting Angle and Shooting Distance to calculate the Shooting Success Rate for Ice Hockey
Example
Input 1: Shooting Angle
• Input 1: Shooting Angle
Example
Input 2: Shooting Distance
• Input 2: Shooting Distance
Example
• Knowledge Base
KnowledgeBase
Distance
Close Normal Far
Angle
Small Normal NoChance
NoChanc
e
Normal
GoodChance Normal Norma
l
Big GoodChance
GoodChance
GoodChanc
e
Knowledge Base
If Angle is Small and Distance is Close then output = NormalIf Angle is Small and Distance is Normal then output = No ChanceIf Angle is Small and Distance is Far then output = No ChanceIf Angle is Normaland Distance is Close then output = Good ChanceIf Angle is Normal and Distance is Normal then output = NormalIf Angle is Normal and Distance is Far then output = NormalIf Angle is Big and Distance is Close then output = Good ChanceIf Angle is Big and Distance is Normal then output = Good ChanceIf Angle is Big and Distance is Far then output = Good Chance
Example
• Angle = 20, Distance = 90. Output is ?
• Angle = 20, Distance = 81. Output is ?
– (Use Weighted Average Defuzzification)
Angle = 20, Distance = 90
If Angle is Small and Distance is Close then output = NormalIf Angle is Small and Distance is Normal then output = No ChanceIf Angle is Small and Distance is Far then output = No ChanceIf Angle is Normaland Distance is Close then output = Good ChanceIf Angle is Normal and Distance is Normal then output = NormalIf Angle is Normal and Distance is Far then output = NormalIf Angle is Big and Distance is Close then output = Good ChanceIf Angle is Big and Distance is Normal then output = Good ChanceIf Angle is Big and Distance is Far then output = Good Chance
Angle = 20, Distance = 90
Angle “20” is 20% degrees of Small Set and 80% degrees of Normal Set
Distance “90” is 100% degrees of Normal Set
Angle = 20, Distance = 90
output=0 .2×00 .8×0 .5
0 .20 . 8=0 .4
Angle = 20, Distance = 81
output=0 . 2×00 .1×0 .50 . 9×0 . 50 .1×1
0 . 20 .10 . 90 .1=0 . 458
Quiz
• Angle = 15, Distance = 99
A Fuzzy Logic Controller for Car-like Mobile Robots
• Input:– curvature, position error and orientation
error
• Output:– speed and direction
Input - Curvature
Input - Position error
Input - Orientation error
Output - Speed
Output - Direction
Rules
• straightLine & zeroDisp & zeroAngle– Fast & straight
• straightLine & zeroDisp & posHighAngle– Medium speed & sharpLeft
• leftCircle & posLowDisp &negLowAngle– Medium speed & lowLeft
Reference
• http://www4.cs.umanitoba.ca/~jacky/Teaching/Courses/COMP_4180-IntelligentMobileRobotics/current/index.php
• Dr. Ching-Chang Wong, 2010 Fuzzy Control class, TKU, Taiwan.
• http://en.wikipedia.org/wiki/Fuzzy_control_system