fuzzy logic basics vk
TRANSCRIPT
-
7/31/2019 Fuzzy Logic Basics VK
1/49
5diih ;^VXR 1PbXRb5diih ;^VXR 1PbXRb5diih ;^VXR 1PbXRb5diih ;^VXR 1PbXRb5diih ;^VXR 1PbXRb5diih ;^VXR 1PbXRb5diih ;^VXR 1PbXRb5diih ;^VXR 1PbXRb
Vojislav KECMAN, Department of Mechanical Engineering, The University of Auckland, NZ
Slides accompanying The MIT Press book:: Learning and Soft Computing
-
7/31/2019 Fuzzy Logic Basics VK
2/49
The slides shown here are developed around the basic notion of
Embedding Structured Human Knowledge into workable mathematical models
by Fuzzy Logic
as presented in the book
LEARNING AND SOFT COMPUTINGSupport Vector Machines, Neural Networks and Fuzzy Logic Models
Author: Vojislav KECMAN
The MIT Press, Cambridge, MA, 2001
ISBN 0-262-11255-8
608 pp., 268 illustrations, 47 examples, 155 problems
They are intended to support both the instructors in the development and deliveryof course content and the learners in acquiring the ideas and techniques
presented in the book in a more pleasant way than just reading.
-
7/31/2019 Fuzzy Logic Basics VK
3/49
What is Fuzzy Logic ?What is Fuzzy Logic ?
FL is a Tool for Embedding Human Structured
Knowledge (Experience, Expertise, Heuristic)
Why is it Fuzzy ?Why is it Fuzzy ? Because - human knowledge is fuzzy : expressed in Fuzzy
Linguistic Terms - Young, Old, Big, Cheap are FUZZY words
Temperature is expressed as Cold, Warm or Hot. Noquantitative meaning.
-
7/31/2019 Fuzzy Logic Basics VK
4/49
5diih ;^VXR \Ph QT eXTfTS Pb P5diih ;^VXR \Ph QT eXTfTS Pb P5diih ;^VXR \Ph QT eXTfTS Pb P5diih ;^VXR \Ph QT eXTfTS Pb PQaXSVT ^eTa cWT TgRTbbXeT[h fXSTQaXSVT ^eTa cWT TgRTbbXeT[h fXSTQaXSVT ^eTa cWT TgRTbbXeT[h fXSTQaXSVT ^eTa cWT TgRTbbXeT[h fXST
VP_ QTcfTT] cWT _aTRXbX^] ^UVP_ QTcfTT] cWT _aTRXbX^] ^UVP_ QTcfTT] cWT _aTRXbX^] ^UVP_ QTcfTT] cWT _aTRXbX^] ^U
R[PbbXRP[ RaXb_ [^VXR P]S cWTR[PbbXRP[ RaXb_ [^VXR P]S cWTR[PbbXRP[ RaXb_ [^VXR P]S cWTR[PbbXRP[ RaXb_ [^VXR P]S cWT
X\_aTRXbX^] ^U Q^cW cWT aTP[ f^a[SX\_aTRXbX^] ^U Q^cW cWT aTP[ f^a[SX\_aTRXbX^] ^U Q^cW cWT aTP[ f^a[SX\_aTRXbX^] ^U Q^cW cWT aTP[ f^a[S
P]S Xcb Wd\P] X]cTa_aTcPcX^]P]S Xcb Wd\P] X]cTa_aTcPcX^]P]S Xcb Wd\P] X]cTa_aTcPcX^]P]S Xcb Wd\P] X]cTa_aTcPcX^]?PaP_WaPbX]V ; IPSTW?PaP_WaPbX]V ; IPSTW?PaP_WaPbX]V ; IPSTW?PaP_WaPbX]V ; IPSTW
-
7/31/2019 Fuzzy Logic Basics VK
5/49
FL attempts to model the way of
reasoning that goes in the human brain. Almost all of human experience is stored
in the form of the IF - THEN rules. Human reasoning is pervasively
approximate, non-quantitative, linguistic,and dispositional (meaning, usuallyqualified).
-
7/31/2019 Fuzzy Logic Basics VK
6/49
FL attempts to model the way of
reasoning that goes in the human brain. Almost all of human experience is stored
in the form of the IF - THEN rules. Human reasoning is pervasively
approximate, non-quantitative, linguistic,and dispositional (meaning, usuallyqualified).
Why is that way ?
-
7/31/2019 Fuzzy Logic Basics VK
7/49
The World is Not Binary!Gradual Transitions & Ambiguities at the
Boundaries
Good, Day, Young, Healthy,
YES,
True, Happy, Tall, 0
Bad, Night, Old, Ill
NO
False, Sad, Short, 1
-
7/31/2019 Fuzzy Logic Basics VK
8/49
Criteria: When and Why to Apply FL
-
7/31/2019 Fuzzy Logic Basics VK
9/49
Criteria: When and Why to Apply FL
Human (Structured)Knowledge Available
-
7/31/2019 Fuzzy Logic Basics VK
10/49
Criteria: When and Why to Apply FL
Human (Structured)Knowledge Available
Mathematical Model
Unknown orImpossible to Obtain
-
7/31/2019 Fuzzy Logic Basics VK
11/49
Criteria: When and Why to Apply FL
Human (Structured)Knowledge Available
Mathematical Model
Unknown orImpossible to Obtain
Process SubstantiallyNonlinear
Lack of Precise
Sensor Informations
-
7/31/2019 Fuzzy Logic Basics VK
12/49
Criteria: When and Why to Apply FL
Human (Structured)Knowledge Available
Mathematical Model
Unknown orImpossible to Obtain
Process SubstantiallyNonlinear
Lack of Precise
Sensor Informations
At the HigherLevels of
HierarchicalControl Systems
In GenericDecision MakingProcess
-
7/31/2019 Fuzzy Logic Basics VK
13/49
How to Transfer HumanKnowledge Into the Model?
Knowledge must be structured !
Possible shortcomings:
Knowledge is very subjective category Experts bounce between some extreme poles:
Have problems with structuring the knowledge, or
Too aware in his/hers expertise, or Tend to hide knowledge, or ...
Solution: Find a Good Expert! There are always
some around.
-
7/31/2019 Fuzzy Logic Basics VK
14/49
10B82B10B82B10B82B10B82B
01>DC01>DC01>DC01>DC 2A8B?2A8B?2A8B?2A8B?
0=30=30=30=3 5DIIH5DIIH5DIIH5DIIH
B4CBB4CBB4CBB4CB
-
7/31/2019 Fuzzy Logic Basics VK
15/49
Fuzzy SetsFuzzy SetsCrisp SetsCrisp Sets
Venn Diagrams
-
7/31/2019 Fuzzy Logic Basics VK
16/49
11
0 0
- membership degree, possibility distribution, grade of belonging
Fuzzy SetsFuzzy SetsCrisp SetsCrisp Sets
-
7/31/2019 Fuzzy Logic Basics VK
17/49
Modeling or Approximating A Function:Modeling or Approximating A Function:
Curve or Surface FittingCurve or Surface Fitting
More Different Names in Different Disciplines:
Regression (L or NL), Estimation, Identification, Filtering
-
7/31/2019 Fuzzy Logic Basics VK
18/49
Standard Mathematical Procedure of Curve FittingResults in a More or Less Acceptable Solution
Modeling A FunctionModeling A Function
-
7/31/2019 Fuzzy Logic Basics VK
19/49
Curve Fitting by Using Fuzzy Rules (Patches)
When There Are More Inputs We Try to Approximate
A Surface (2 Inputs) or Hyper-Surface (3 or More Inputs)
Modeling A FunctionModeling A Function
Small Number of Rules - Big Patches or Rough Approximation
-
7/31/2019 Fuzzy Logic Basics VK
20/49
Fuzzy Patches
Modeling A FunctionModeling A Function
More Rules - More Smaller Patches and Better Approximation
Origin of the patches and how do they work?
-
7/31/2019 Fuzzy Logic Basics VK
21/49
x
y
Consider modeling two different functions by fuzzy rules (books Fig 1.3.)
Less rules leads to the approximation accuracy decrease. An increase in a number ofrules increases the precision at the cost of a computation time needed to process morerules. This is the most classical soft computing dilemma that trades off between the
imprecision and uncertainty on one hand and low solution cost, tractability androbustness on the other. The appropriate rules for functions in Fig 1.3 are:
Left graph Right graph
IF xis lowTHEN yis high. IF xis lowTHEN yis high.IF xis mediumTHEN yis low. IF xis mediumTHEN yis medium.IF xis bigTHEN yis high. IF xis bigTHEN yis low.
These rules define three large rectangular patches that cover our functions. They are
shown in the next slide (Fig 1.4 in the book) together with two possible approximators foreach function.
x
y
-
7/31/2019 Fuzzy Logic Basics VK
22/49
x
y y
x
Modeling two different functions by fuzzy rules (books Fig 1.4.)
Figure 1.4 Two different functions (solid lines in both graphs) covered by three patches producedby IF-THEN rules and modeled by two possible approximators(dashedand dotted curves).
COMENTS: Note that humans do not (or only rarely) think in terms of nonlinear functions.
We do not try to draw these functions in our mind. We neither try to see them as
geometrical artifacts. In general, we do not process geometrical figures, curves, surfaces orhypersurfaces while performing some tasks or expressing our knowledge. Even more, ourexpertise or understanding of some functional dependencies is very often not a structuredpiece of knowledge at all. We typically perform very complex tasks without being able toexpress how are we executing them.
The curious reader should try, for example, to explain to his/hers colleague, in theform of IF-THEN rules, how s/he is riding the bike, recognizing numerals or surfing.
-
7/31/2019 Fuzzy Logic Basics VK
23/49
Fuzzy Control of the Distance Between Two CarsGeneral approach in all fuzzy modeling is always the same.
i) Define the variables of relevance, interest or importance:
In engineering we use to call them Input and Output Variables,
ii) Define the subsets intervals:
Small - Medium, or Negative - Positive, or
Left - Right (labels are variables dependant)
iii) Choose the Shapes and the Positions of Fuzzy Subsets i.e.,
Membership Functions i.e., Attributes
iv) Set the Rule Basis i.e., IF - THEN Rules:
v) Perform calculations and (if needed) tune (learn, adjust, adapt) the
positions and the shapes of both the input and the output attributes o
the model.
F C l f h
-
7/31/2019 Fuzzy Logic Basics VK
24/49
D
v
B
Fuzzy Control of the
Distance Between Two CarsINPUTS: D = DISTANCE, v = SPEED
OUTPUT:B = BRAKING FORCE
Lets analyze the rules for some given distance
D and for different velocities v i.e., B = f(v)
-
7/31/2019 Fuzzy Logic Basics VK
25/49
IFtheVelocity is Low, THEN the Braking Force is Small.
Low Medium High
1
10 120 (km/h)
Small Medium Big
1
0 100 (%)
Velocity Braking Force
IF theVelocity is Medium, THEN the Braking Force is Medium.
IF theVelocity is High, THEN the Braking Force is Big.
-
7/31/2019 Fuzzy Logic Basics VK
26/49
Velocity
Braking Force
The Fuzzy PatchesThe Fuzzy Patches
Small MediumHigh10 120
Big
Medium
Low
1100
0(%)
1
-
7/31/2019 Fuzzy Logic Basics VK
27/49
Velocity
Braking Force
The Fuzzy PatchesThe Fuzzy Patches
Small MediumHigh10 120
Big
Medium
Low
1100
0(%)
1
-
7/31/2019 Fuzzy Logic Basics VK
28/49
Velocity
Braking Force
The Fuzzy PatchesThe Fuzzy Patches
Note the overlapping of
fuzzy subsets that leads
to a smooth approximation
of the function between the
Velocity & Braking Force
Small MediumHigh
10 120
Big
Medium
Low
1100
0(%)
1
-
7/31/2019 Fuzzy Logic Basics VK
29/49
Velocity
Braking Force
The Fuzzy Patches Define the FunctionThe Fuzzy Patches Define the Function
Small MediumHigh
10 120
Big
Medium
Low
1100
0(%)
1
Three possible
dependencies
between the v and B.Each of us drives
differently, and we all
drive in different way
each time.
)81&7,21$/ '(3(1'(1&( 2) 7+( 9$5,$%/(6
-
7/31/2019 Fuzzy Logic Basics VK
30/49
)81&7,21$/ '(3(1'(1&( 2) 7+( 9$5,$%/(6
SURFACE O F KN O W LEDGE
020
40
60
80
100
050
100
150
20010
2030
40
50
60
70
80
90
DistanceSpeed
Braking
Force
V.K.Fuzzy Control of the Distance Between Two Cars again
now, however,2 INPUTS: D and v, and 1 OUTPUT B visualization still possible.
For more inputs everything remains same but no longer visualization.
-
7/31/2019 Fuzzy Logic Basics VK
31/49
Second ExampleSecond Example
FuzzyFuzzy
RoomRoom
TemperatureTemperature
ControlControl
-
7/31/2019 Fuzzy Logic Basics VK
32/49
Room TemperatureRoom Temperature Fan SpeedFan Speed
Cold Warm Hot
1
10 30 (oC)
Slow Medium Fast
1
0 100 (%)
-
7/31/2019 Fuzzy Logic Basics VK
33/49
Fan SpeedFan Speed
If Room Temperature is Cold then Fan Speed is Slow
Cold Warm Hot
1
10 30 (oC)
Slow Medium Fast
1
0 100 (%)
Room TemperatureRoom Temperature
-
7/31/2019 Fuzzy Logic Basics VK
34/49
Fan SpeedFan Speed
If Room Temperature is Cold then Fan Speed is Slow
If Room Temperature is Warm then Fan Speed is Medium
Cold Warm Hot
1
10 30 (oC)
Slow Medium Fast
1
0 100 (%)
Room TemperatureRoom Temperature
-
7/31/2019 Fuzzy Logic Basics VK
35/49
Fan SpeedFan Speed
If Room Temperature is Cold then Fan Speed is Slow
If Room Temperature is Warm then Fan Speed is Medium
If Room Temperature is Hot then Fan Speed is Fast
Cold Warm Hot
1
10 30 (oC)
Slow Medium Fast
1
0 100 (%)
Room TemperatureRoom Temperature
-
7/31/2019 Fuzzy Logic Basics VK
36/49
RoomTemperature
The Fuzzy PatchesThe Fuzzy PatchesFan Speed
Cold Warm Hot10 30 (oC)
Fast
Medium
Slow
1100
0
(%)
1
-
7/31/2019 Fuzzy Logic Basics VK
37/49
RoomTemperature
The Fuzzy PatchesThe Fuzzy PatchesFan Speed
Cold Warm Hot10 30 (oC)
Fast
Medium
Slow
1100
0
(%)
1
-
7/31/2019 Fuzzy Logic Basics VK
38/49
RoomTemperature
Fan Speed
The Fuzzy PatchesThe Fuzzy Patches
Note the overlappingof fuzzy subsets again - it leadsto smooth approximationof the function between the
Fan Speed & Temperature
Cold Warm Hot10 30 (oC)
Fast
Medium
Slow
1100
0
(%)
1
-
7/31/2019 Fuzzy Logic Basics VK
39/49
There must be some overlapping of the input
fuzzy subsets (membership or characteristicfunctions) if we want to obtain a smooth model
0 2 4 6 8 10 120
2
4
6
8
10
12
VS S M B VB
VB
B
M
S
VS
I N P U T
OU
T
P
U
T
-
7/31/2019 Fuzzy Logic Basics VK
40/49
There must be some overlapping of the input
fuzzy subsets (membership or characteristicfunctions) if we want to obtain a smooth model
0 2 4 6 8 10 120
2
4
6
8
10
12
VS S M B VB
VB
B
M
S
VS
I N P U T
OU
T
P
U
T
Because,
if there is no
overlapping
one obtains
the stepwisefunction as
shown next!
-
7/31/2019 Fuzzy Logic Basics VK
41/49
There must be some overlapping of the input
fuzzy subsets (membership or characteristicfunctions) if we want to obtain a smooth model
0 2 4 6 8 10 120
2
4
6
8
10
12
VS S M B VB
VB
B
M
S
VS
I N P U T
OU
T
P
U
T
Calculation of the output: Fuzzification, Inference and Defuzzifaction
-
7/31/2019 Fuzzy Logic Basics VK
42/49
Fan SpeedFan Speed
R1: If Room Temperature is Cold Then Fan Speed is Slow
R2: If Room Temperature is Warm Then Fan Speed is Medium
R3: If Room Temperature is Hot Then Fan Speed is Fast
After the fuzzy modeling is done there is an operation phase: Calculate the
Fan Speed when Room Temperature = 22 oC .
NOTE! 22 oC belongs to the Subsets Warm and Hot
Cold Warm Hot
1
10 30 (oC)
Slow Medium Fast
1
0 100 (%)22
Room TemperatureRoom Temperature
Fuzzification and Inference
-
7/31/2019 Fuzzy Logic Basics VK
43/49
Fan SpeedFan Speed
If Room Temperature is Cold Then Fan Speed is Slow
If Room Temperature is Warm Then Fan Speed is Medium
If Room Temperature is Hot Then Fan Speed is Fast
Cold Warm Hot
1
10 30 (oC)
Slow Medium Fast
1
0 100 (%)22
0.6
Room TemperatureRoom Temperature
S
Fuzzification and Inference
-
7/31/2019 Fuzzy Logic Basics VK
44/49
If Room Temperature is Cold then Fan Speed is Slow
If Room Temperature is Warm then Fan Speed is Medium
If Room Temperature is Hot then Fan Speed isFast
Cold Warm Hot
1
10 30 (oC)22
0.6
0.3
Fan SpeedFan Speed
Slow Medium Fast
1
0 100 (%)
Room TemperatureRoom Temperature
S
F S d
Fuzzification and Inference
-
7/31/2019 Fuzzy Logic Basics VK
45/49
If Room Temperature is Cold then Fan Speed is Slow
If Room Temperature is Warm then Fan Speed is Medium
If Room Temperature is Hot then Fan Speed isFast
THE QUESTION NOW IS: WHAT IS THE OUTPUT VALUE?
Cold Warm Hot
1
10 30 (oC)22
0.6
0.3
Fan SpeedFan Speed
Slow Medium Fast
1
0 100 (%)
Room TemperatureRoom Temperature
D f ifi iD f ifi ti
-
7/31/2019 Fuzzy Logic Basics VK
46/49
DefuzzificationDefuzzification
The Result of the Fuzzy Inference is a Fuzzy Subset Composed ofthe Slices of Fan Speed: Medium (green) and Fast (red)
How to Find a Crisp (for the real world application useful) Value?
One out of several different methods SHOWN ABOVE is:
the Centre of Area Formula to Obtain a Crisp Output
60
Fan Speed
1
0 100 (%)
-
7/31/2019 Fuzzy Logic Basics VK
47/49
Example given in program LEARNSC from theExample given in program LEARNSC from thebook:book:
i) Vehicle Turning Problemi) Vehicle Turning Problem
Generic Fuzzy Logic Controller
- Developed in Matlab
- User Friendly
- Multiple Inputs
Many Other Commercial Applications Possible
C fi i f h V hi l T i P bl
-
7/31/2019 Fuzzy Logic Basics VK
48/49
Configuration of the Vehicle Turning ProblemConfiguration of the Vehicle Turning Problem
= Angle of Car (INPUT 1)
d = Distance From Center Line (INPUT 2)
max = /4 :Upper Bound of Steering Angle (OUTPUT)
v = 10.0 m/s
Finish
Start
d
& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6
-
7/31/2019 Fuzzy Logic Basics VK
49/49
& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6& 2 1 & / 8 6 , 2 1 6
Fuzzy Logic Can Be Implemented Wherever There is StructuredHuman Knowledge, Expertise, Heuristics, Experience.
Fuzzy Logic is not needed whenever there is an analytical closed-
form model that, using a reasonable number of equations, can solve
the given problem in a reasonable time, at the reasonable costs and
with higher accuracy.
POSSIBLE PROBLEMS:
Finding good(accountable) expert,
Right choice of the variables,
Increasing the number ofinputs, as well as the number of fuzzy subsets perinput variable, the number of rules increases exponentially (curse of
dimensionality)
Good news is, that there are plenty of real life problems and situations that
can be solved with small number of rules only.