fuzzy logic basics
TRANSCRIPT
-
8/2/2019 Fuzzy Logic Basics
1/13
Fuzzy Logic
Andrew Kusiak
Intelligent Systems Laboratory
2139 Seamans Center
The University of Iowa
Iowa City, IA 52242 1527
The University of Iowa Intelligent Systems Laboratory
(Based on the material provided by Professor V. Kecman)
http://www.icaen.uiowa.edu/~ankusiak
What is Fuzzy Logic?
Fuzzy logic is a tool for embedding
human knowledge
(experience, expertise, heuristics)
The University of Iowa Intelligent Systems Laboratory
Human knowledge is fuzzy: expressed
Why Fuzzy Logic ?
, . ., ,
old, large, cheap.
Temperature is expressed as cold,
The University of Iowa Intelligent Systems Laboratory
warm or hot.
No quantitative meaning.
Fuzzy Logic
between the excessively wide gap between
theprecision of classical crisp logic andthe imprecision of both the real world and
its human interpretation
The University of Iowa Intelligent Systems Laboratory
Paraphrasing L. Zadeh
-
8/2/2019 Fuzzy Logic Basics
2/13
Fuzzy Logic
Fuzzy logic attempts to model the way ofreason ng o t e uman ra n.
Almost all human experience can be expressed inthe form of the IF - THEN rules.
The University of Iowa Intelligent Systems Laboratory
uman reason ng s pervas ve y approx mate,non-quantitative, linguistic, and dispositional(meaning, usually qualified).
The World is Not Binary!Gradual transitions and ambiguities at the boundaries
Bad, Night, Old, Ill
False, Sad, Short, , 1
The University of Iowa Intelligent Systems Laboratory
Good, Day, Young, Healthy,YES,
True, Happy, Tall, , 0
When and Why to Apply FL?
Human knowledge is available
Mathematical model is unknown orimpossible to obtain
The University of Iowa Intelligent Systems Laboratory
Lack of precise sensor information
When and Why to Apply FL?
At higher levels of hierarchical
control systems
The University of Iowa Intelligent Systems Laboratory
In decision making processes
-
8/2/2019 Fuzzy Logic Basics
3/13
How to Transfer Human Knowledge
Into the Model ?
.
Possible shortcomings:
Knowledge is subjective
Experts may bounce between extreme pointsof view:
The University of Iowa Intelligent Systems Laboratory
, Too aware in his/her expertise, or
Tend to hide knowledge, or ...
Solution: Find a good expert.
Fuzzy Sets vs Crisp Sets
The University of Iowa Intelligent Systems Laboratory
Venn Diagrams
Fuzzy SetsCrisp Sets
Fuzzy Sets vs Crisp Sets
11
The University of Iowa Intelligent Systems Laboratory
0 0
- membership degree, possibility distribution,
grade of belonging
Modeling or Approximating a Function:
Curve or Surface Fitting
The University of Iowa Intelligent Systems Laboratory
Terms used in other disciplines:
regression (L or NL), estimation, identification, filtering
-
8/2/2019 Fuzzy Logic Basics
4/13
Standard mathematical approach of curve fitting
more or less satisfactor fit
Modeling a Function
The University of Iowa Intelligent Systems Laboratory
Curve fitting by using fuzzy rules (patches)
Surface approximation for 2 inputs or
a h er-surface (3 or more in uts
Modeling a Function
The University of Iowa Intelligent Systems Laboratory
Small number of rules - Large patches or rough approximation
Modeling a Function
The University of Iowa Intelligent Systems Laboratory
More rules - more smaller patches and better approximation
What is the origin of the patches and how do they work?
Consider modeling two different functions by
Example 1
fuzzy rules
y y
The University of Iowa Intelligent Systems Laboratory
x x
-
8/2/2019 Fuzzy Logic Basics
5/13
Example 1 Lesser number of rules decreases the
approximation accuracy. An increase in a numberof rules, increases the precision at the cost of acomputation time needed to process these rules.
This is the most classical soft computing dilemma- A trade-off between the imprecision anduncertainty on one hand and low solution cost,
The University of Iowa Intelligent Systems Laboratory
.
The appropriate rules for the two functions are:
Example 1y y
IFx is low THENy is high. IFx is low THENy is high.
x x
The University of Iowa Intelligent Systems Laboratory
IFx is medium THENy is low. IFx is medium THENy is
medium.
IFx is large THENy is high. IFx is large THENy is low.
Example 1
that cover the functions. They are shown in the
next slide together with two possible
approximators for each function.
The University of Iowa Intelligent Systems Laboratory
y y
Modeling two different functions by fuzzy rules
Example 2
x x
The University of Iowa Intelligent Systems Laboratory
The two original functions (solid lines in both graphs) covered by
three patches produced by IF-THEN rules and modeled by two
possible approximators (dashedand dotted curves).
-
8/2/2019 Fuzzy Logic Basics
6/13
Example 2 Humans do not (or only rarely) think in terms ofnonlinear functions.
Humans do not draw these functions in theirmind.
We neither try to see them as geometricalartifacts.
The University of Iowa Intelligent Systems Laboratory
In general, we do not process geometrical figures,curves, surfaces or hypersurfaces whileperforming tasks or expressing our knowledge.
Example 2
,
some functional dependencies is often not a
structured piece of knowledge at all.
We typically perform complex tasks without being
The University of Iowa Intelligent Systems Laboratory
a e o express ow ey are execu e .
Example 2
Explain to your colleague in the form of IF-THEN rules how to ride a bike.
The University of Iowa Intelligent Systems Laboratory
Car Example
e s eps n uzzy mo e ng are a ways e same.
i) Define the variables of relevance, interest or importance:
In engineering we call them input and output variables
ii) Define the subsets intervals:
The University of Iowa Intelligent Systems Laboratory
Small - medium, or negative - positive, or
Left - right (labels of dependent variables)
-
8/2/2019 Fuzzy Logic Basics
7/13
Car Example
iii) Choose the shapes and the positions of fuzzysubsets, i.e.,
Membership functions, i.e., attributes
iv) Set the rule form, i.e., IF - THEN Rules
The University of Iowa Intelligent Systems Laboratory
v) Perform computation and (if needed) tune (learn,adjust, adapt) the positions and the shapes of boththe input and the output attributes of the model
Car Example
DB
: = , v =
OUTPUT:B = BRAKING FORCE
The University of Iowa Intelligent Systems Laboratory
v
Car Example
DB
v
The University of Iowa Intelligent Systems Laboratory
Analyze the rules for a given distance D and for
different velocity v, i.e., B = f(v)
Low Medium High Small Medium High
Velocity Braking Force
Car Example
10 120 (km/h) 0 100 (%)
The University of Iowa Intelligent Systems Laboratory
IF the Velocity is Low, THEN the Braking Force is Small
IF the Velocity is Medium, THEN the Braking Force is Medium
IF the Velocity is High, THEN the Braking Force is High
,
-
8/2/2019 Fuzzy Logic Basics
8/13
Braking Force
High
1100
Car Example
e uzzy
patch
Medium
Low
0(%)
1
The University of Iowa Intelligent Systems Laboratory
Velocity
Small MediumHigh
10 120
Braking Force
High
1100
Car Example
The fuzzy
patches
Medium
Low
0(%)
1
The University of Iowa Intelligent Systems Laboratory
Velocity
Small MediumHigh10 120
Braking Force
The fuzzy patches
1100
Car Example
High
Medium
Low
0(%)
1
The University of Iowa Intelligent Systems Laboratory
VelocityNote the overlapping
fuzzy subsets smooth
approximation
of the function between the
Velocity and Braking ForceSmall Medium High
10 120
Braking Force
The Fuzzy Patches Define the FunctionThe Fuzzy Patches Define the Function
High
1100
Three possible
de endencies
Medium
Low
0(%)
between the Velocity
and Breaking force.
Each of us drives
differently
rExa
mpl
The University of Iowa Intelligent Systems Laboratory
Velocity
Small Medium High10 120
C
-
8/2/2019 Fuzzy Logic Basics
9/13
FUNCTIONAL DEPENDENCE OF THE VARIABLES
SURFACE OF KNOWLEDGEFuzzy Control of the Distance Between Two CarsVisualization of 2 INPUTS: D and v, and 1 OUTPUT B is possible.
For more inputs everything remains the same but visualization is not possible.
50
60
70
80
90
BrakingForce
The University of Iowa Intelligent Systems Laboratory020
40
60
80
100
0
50
100
150
200
10
20
30
40
DistanceSpeed
Example:
Room Temperature Control
Cold Warm Hot
1
Slow Medium Fast
1
The University of Iowa Intelligent Systems Laboratory
10 30 (oC) 0 100 (%)
Fan SpeedRoom Temperature
Example:
Room Temperature Control
Cold Warm Hot
1
Slow Medium Fast
1
The University of Iowa Intelligent Systems Laboratory
If Room Temperature is Cold, then Fan Speed is Slow
10 30 (oC) 0 100 (%)
Fan SpeedRoom Temperature
Example:
Room Temperature Control
Cold Warm Hot
1
Slow Medium Fast
1
The University of Iowa Intelligent Systems Laboratory
If Room Temperature is Cold, then Fan Speed is Slow
If Room Temperature is Warm, then Fan Speed is Medium
10 30 (oC) 0 100 (%)
-
8/2/2019 Fuzzy Logic Basics
10/13
Fan SpeedCold Warm Hot Slow Medium Fast
Room Temperature
Example:
Room Temperature Control
1 1
The University of Iowa Intelligent Systems Laboratory
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
10 30 (oC) 0 100 (%)
Fan Speed
Fast
1100
Example:
Room Temperature Control
e uzzy
patchesMedium
Slow
0(%)
The University of Iowa Intelligent Systems Laboratory
Room
Temperature
Cold Warm Hot10 30 (oC)
Fan Speed
Fast
1100
Example:
Room Temperature Control
The fuzzy
patchesMedium
Slow
0(%)
The University of Iowa Intelligent Systems Laboratory
Room
Temperature
Cold Warm Hot10 30 (oC)
1
Fan Speed
Fast
1100
Example:
Room Temperature Control
patches
Note the overlapping
Medium
Slow
0(%)
1
The University of Iowa Intelligent Systems Laboratory
Room
Temperature
of fuzzy subsets smoothes
approximation
of the function between the
Fan Speed and Temperature
Cold Warm Hot10 30 (oC)
-
8/2/2019 Fuzzy Logic Basics
11/13
There must be some overlapping of the input fuzzy subsets
(membership or characteristic functions) if we want to obtain
a smooth model
Example:
Room Temperature Control
O
U
T
P6
8
10
12
VL
L
M
If there was no
overlapping.
one would
obtain the
ste wise
The University of Iowa Intelligent Systems LaboratoryI N P U T
U
T
0 2 4 6 8 10 1 20
2
4
VS S M L VL
S
VS
function as
shown next
There must be some overlapping of the input fuzzy subsets
(membership or characteristic functions) if we want to obtain
a smooth model
Example:
Room Temperature Control
6
8
10
12
VB
B
M
O
U
T
P
The University of Iowa Intelligent Systems Laboratory
0 2 4 6 8 10 1 20
2
4
VS S M B VB
S
VS
I N P U T
UT
Fan Speed
Cold Warm Hot Slow Medium Fast
Room Temperature
Output Computation: Fuzzification, Inference and
Defuzzifaction
1 1
The University of Iowa Intelligent Systems Laboratory
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
10 30 (oC) 0 100 (%)22
Example:
Room Temperature Control
operational phase:
Compute the fan speed when the room
temperature = 22 oC
The University of Iowa Intelligent Systems Laboratory
: e ongs to t e su sets arm an
Hot
-
8/2/2019 Fuzzy Logic Basics
12/13
Fan Speed
Cold Warm Hot Slow Medium Fast
Room Temperature
Fuzzification and Inference
1
10 30 (oC)
1
0 100 (%)
0.6
The University of Iowa Intelligent Systems Laboratory
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
Fan SpeedRoom Temperature
Cold Warm Hot Slow Medium Fast
Fuzzification and Inference
1
10 30 (oC)
0.6
0.3
1
0 100 (%)
The University of Iowa Intelligent Systems Laboratory
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
Fan SpeedRoom TemperatureCold Warm Hot
1
Slow Medium Fast
1
Fuzzification and Inference
(%)10 30 (oC)22
0.6
0.3
0 100
The University of Iowa Intelligent Systems Laboratory
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
WHAT IS THE OUTPUT VALUE?
DefuzzificationFan Speed
1
The result of the fuzzy inference is a fuzzy subset composed of
the slices of fan speed: Medium (blue) and Fast (red)
600 100 (%)
The University of Iowa Intelligent Systems Laboratory
How to find a crisp (useful in the real world application) value?
One of several methods used to obtain a crisp output value is
the center of area formula
-
8/2/2019 Fuzzy Logic Basics
13/13
Example: Vehicle TurningProblem
Generic fuzzy logic controller
- Developed in Matlab
- User friendly
- Multi le in uts
The University of Iowa Intelligent Systems Laboratory
Many other commercial applications are possible
Configuration of the Vehicle Turning Problem
= Car angle (INPUT 1)
d = Distance from center line (INPUT 2)
Finish
max = /4: Upper bound of steering angle (OUTPUT)
v = 10.0 m/s
The University of Iowa Intelligent Systems Laboratory
Start
Conclusions
Fuzzy logic can be implemented wherever there is
structure uman now e ge, expert se, eur st cs,
experience.
Fuzzy logic is not needed whenever there is an
analytical closed-form model that, using a
The University of Iowa Intelligent Systems Laboratory
reasonable number of equations, can solve a
problem in a reasonable time, at the reasonable
costs and with higher accuracy.
Conclusions
Finding good (dependable) expert
Right choice of the variables
Increasing the number ofinputs, as well as the number offuzzy subsets per input variable, the number of rulesincreases exponentially (curse of dimensionality)
The University of Iowa Intelligent Systems Laboratory
Good news is that there are plenty of real life problems andsituations that can be solved with small number of rulesonly