Fuzzy Logic (PDFDrive)
Fuzzy Logic (PDFDrive)
Sergei Astapov
Self Introduction
Room: U02-305
E-mail: [email protected]
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Lecture Overview
Outline
Why Go Fuzzy?
Outline
In fuzzy set theory classical sets are referred to as crisp sets and
the values as crisp values.
X is usually referred to as the universe of discourse. It represents
the range of values the fuzzy variables may take.
Universes of discourse may be either discrete or continuous.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Fuzzy sets usually carry names appealing in our daily linguistic usage
The universe is called a linguistic variable and its sets are called
linguistic values
The universe of discourse X is partitioned into several fuzzy sets,
with MFs covering X in a more or less uniform manner
Example 1
Consider the universe X of linguistic variable “temperature”. The
universe may be defined differently, depending on the application. We
may set it from the lowest to the highest temperature a typical human
being can live in, e.g. [−50, 50] ◦ C.
We partition the universe into 6 fuzzy sets: “freezing”, “cold”, “chilly”,
“cool”, “warm”, “hot”. These sets are characterized by MFs
µf reezing (x), µcold (x), µchilly (x), µcool (x), µwarm (x), µhot (x).
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Definition 2 (Support)
The support of a fuzzy set A is the set of all points x ∈ X, such that
µA (x) > 0:
support(A) = {x | µA (x) > 0} . (2)
Definition 3 (Core)
The core of a fuzzy set A is the set of all points x ∈ X, such that
µA (x) = 1:
core(A) = {x | µA (x) = 1} . (3)
Definition 5 (Normality)
A fuzzy set A is normal if its core is nonempty, i.e. we can always
find a point x ∈ X, such that µA (x) = 1.
Definition 7 (Symmetry)
A fuzzy set A is symmetric if its MF is symmetric around a
certain point x = c, namely, µA (c + x) = µA (c − x), ∀x ∈ X.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
symmetric μ(x)
freezing cold chilly 1 cool warm hot
0.5
core
Outline
Containment
μ(x)
1 B
A
x
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Complement
μ(x) μ(x)
1 1
A NOT A
x x
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Union
Definition 11 (Union or disjunction)
The union of two fuzzy sets A and B is a fuzzy set C, written as
C = A ∪ B or C = A OR B, the MF of which is related to those
of A and B by
μ(x) μ(x)
1 1
A B
A OR B
x x
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Intersection
Definition 12 (Intersection or conjunction)
The intersection of two fuzzy sets A and B is a fuzzy set C,
written as C = A ∩ B or C = A AND B, the MF of which is
related to those of A and B by
μ(x) μ(x)
1 1
A B
A AND B
x x
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Outline
Preface
Straight-Line MF:Triangular MF
The parameters a and c locate the “feet” of the triangle and b — its
peak.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
The parameters a and d locate the “feet” of the trapezoid and b and c —
its “shoulders”.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
MATLAB MF Examples
1 1
Membership Grades
Membership Grades
0.8 0,8
0.6 0,6
0.4 0,4
0.2 0,2
0 0
0 20 40 60 80 100 0 20 40 60 80 100
1 1
Membership Grades
Membership Grades
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 20 40 60 80 100 0 20 40 60 80 100
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
−10 −5 0 5 10 −10 −5 0 5 10
1 1
0,8 0.8
0,6 0.6
0,4 0.4
0,2 0.2
0 0
−10 −5 0 5 10 −10 −5 0 5 10
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
1 1
Membership Grades
Membership Grades
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
−5 0 5 10 15 −5 0 5 10 15
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
1 1
y1
0.8 0.8
0.6 y2 0.6
0.4 0.4
0.2 0.2
0 0
−10 −5 0 5 10 −10 −5 0 5 10
1 1
0.8 0.8
y1 y3
0.6 0.6
0.4 0.4
0.2 0.2
0 0
−10 −5 0 5 10 −10 −5 0 5 10
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
FL c−x
(
α , x ≤ c,
LR (x; α, β, c) = x−c (18)
FR β , x ≥ c,
Example 2
3
Let FL (x) = max (0, 1 − x2 ), FR = e−|x| . Then applying (18)
p
(a) (b)
1 1
Membership Grades
Membership Grades
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 20 40 60 80 100 0 20 40 60 80 100
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
i c1 < x ≤ c2 ,
gaussian2 (x; c1 , σ1 , c2 , σ2 ) = 1, h (19)
exp − 1 x−c2 , c ≤ x,
2 σ2 2
where c1 , σ1 are the parameters of the left-most curve and c2 , σ2 are the
parameters of the right-most curve.
Outline
IF x is A THEN y is B, (20)
where the function f is called the fuzzy implication function, that transforms
the membership degrees of x in A and y in B into those of (x, y) in A → B.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Bj = Bjl : l = 1, 2, . . . , Mi .
Linguistic Operators
Outline
Defuzzification
Fuzzification
x2 Inference y2
mechanism
...
...
xn Rule-base yn
Defuzzification
Reference input Inputs Outputs
Fuzzification
Inference
r(t) mechanism u(t) y(t)
Process
Rule-base
e(t) θ
r(t) — reference θ angle
x u(t) — force (N)
y(t) — θ angle (rad)
F e(t) = r(t) − y(t)
r(t)
Σ Fuzzy logic u(t) Inverted y(t)
+ -
d controller pendulum
dt
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Outline
Design steps
Choose controller inputs and outputs (linguistic variables)
Assign linguistic values to every variable
Derive control rules for every possible scenario
Choose proper MF for every linguistic value
Specify the parameters of the inference mechanism
Test, observe behavior, tune
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Fuzzy Rules
F F F
Fuzzy Rule-Base
force change-in-error
-2 -1 0 1 2
-2 2 2 2 1 0
-1 2 2 1 0 -1
error 0 2 1 0 -1 -2
1 1 0 -1 -2 -2
2 0 -1 -2 -2 -2
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Membership Functions
Fuzzification
Outline
The firing strength of a rule is the degree of certainty that the rule premise
holds for the given inputs. Its calculation depends on the linguistic operators
used in the structure of a premise.
For any linguistic variables x1 and x2 the typical operators are the following:
Fuzzy complement (NOT):
Defined in (6) as µÂk (x1 ) = 1 − µÂk (x1 )
1 1
Example 3
The premise
IF x1 is Â21 AND x2 is Â12 AND x3 is NOT Â53 OR x4 is Â34
yields the firing strength
µpremise
h (x1 , x2 , x3 , x4 ) = i
max min µÂ2 (x1 ) , µÂ1 (x2 ) , 1 − µÂ5 (x3 ) , µÂ3 (x4 ) .
1 2 3 4
Also there exists an option to use a “rule certainty” weight. This way, for
the i-th rule, the firing strength is multiplied by the weight wi , which
specifies how certain we are in this specific rule compared to other rules.
Keep in mind that there are more alternatives to AND and OR
operations, you can also specify your custom ones.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Example 4
Consider a FIS with 3 inputs and 10 MFs per input. The number of rules
is then at most 103 = 1000. With the universes partitioned by so many
rules, the number of “on” rules at any given time will be quite small. If
for example 10 rules are on, then mark those rules and perform later
steps with 10 sets of parameters, instead of using the whole rule-base and
performing 100 times more computations, mainly with zeros.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
neglarge negsmall zero possmall poslarge neglarge negsmall zero possmall poslarge
-π/2 -π/4 0 π/4 π/2 e(t) (rad) -30 -20 -10 0 10 20 30 u(t) (N)
e(t) = -9π/20
-π/4 -π/8 0 π/8 π/4 de(t)/dt (rad/s) -30 -20 -10 0 10 20 30 u(t) (N)
de(t)/dt = 9π/80
Apply implication (min)
Apply aggregation (max)
From the fuzzification stage we have established that we have four fuzzy values:
µneglarge
\ (e) = 0.75; µnegsmall
\ (e) = 0.25; µzero d (ė) = 0.125;
µpossmall
\ (ė) = 0.875. Thus the rules that are on are:
Compute the firing strengths of the four rules using min for the AND operator:
µpremise(1) (e, ė) = min(µneglarge
\ (e), µzero d (ė)) = min(0.75, 0.125) = 0.125;
µpremise(2) (e, ė) = min(µneglarge
\ (e), µpossmall
\ (ė)) = min(0.75, 0.875) = 0.75;
µpremise(3) (e, ė) = min(µnegsmall
\ (e), µ d (ė)) = min(0.25, 0.125) = 0.125;
zero
µpremise(4) (e, ė) = min(µnegsmall
\ (e), µpossmall
\ (ė)) = min(0.25, 0.875) = 0.25.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Implied fuzzy sets are derived from the rule premises using min as:
µposlarge(1)
\ (u) = min µpremise(1) (e, ė) , µposlarge (u) =
= min(0.125, 1) = 0.125;
µpossmall(2)
\ (u) = min µpremise(2) (e, ė) , µpossmall (u) =
= min(0.75, 1) = 0.75;
µpossmall(3)
\ (u) = min µpremise(3) (e, ė) , µpossmall (u) =
= min(0.125, 1) = 0.125;
µzero(4)
d (u) = min µpremise(4) (e, ė) , µzero (u) = min(0.25, 1) = 0.25.
The overall implied fuzzy set is obtained by fuzzy aggregation using max as:
µoverall
\ (u) =
max µposlarge(1)
\ (u) , µpossmall(2)
\ (u) , µpossmall(3)
\ (u) , µzero(4)
d (u) .
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Outline
Defuzzification
The result of fuzzy inference is the implied fuzzy set (or sets). For
the systems, where a crisp value is required from the FIS, the
operation called defuzzification is applied to the implied sets.
A number of defuzzification strategies exist, and it is not hard to
invent more, suiting your specific application.
Each provides a means to choose a crisp output yjcrisp based on
either the implied fuzzy sets or the overall implied fuzzy set.
Reviewed defuzzification methods:
Center of gravity (COG)
Center-average
Maximum criterion: mean of maximum (MOM), smallest of
maximum (SOM), largest of maximum (LOM)
Center of area (COA)
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
where R is the number or rules, bji is the center of area of the MF of Bjp
associated with the implied fuzzy set B̂ji for the i-th rule and
ˆ
µB̂ i (yj ) dyj
j
Yj
Definition 23 (Center-average)
In Center-average defuzzification the output yjcrisp is computed using
the centers of each of the output MFs and the maximum certainty of
each of the implied fuzzy sets:
PR j n o
b
i=1 i sup yj µ i
B̂j (yj )
yjcrisp = P n o , (23)
R
i=1 supyj µB̂ i (yj )
j
where supyj denotes the supremum (i.e. the least upper bound) of the
implied fuzzy set µB̂ i (yj ).
j
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Notice though, that the fuzzy system must be defined such that
R
X n o
sup µB̂ i (yj ) 6= 0
yj j
i=1
If using normal MFs for output fuzzy sets, then for many inference
strategies we have
n o
sup µB̂ i (yj ) = µpremise(i) (x1 , x2 , . . . , xn ) ,
yj j
where R
P
i=1 µpremise(i) (x1 , x2 , . . . , xn ) 6= 0, ∀xi must be ensured.
The shape of the output MFs does not matter, as bounds of
supremum subsets can be defined using singletons.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
MOM, SOM and LOM differ in the strategy of choosing the crisp
value from this subset.
supremum
MOM
SOM
LOM
h i
Notice that if µB̂ ∗ (yj ) = 1 lies in a single interval yjleft , yjright ⊆ Yj ,
j
then yjcrisp = yjleft + yjright /2.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Defuzzification: Example
For our symmetrical triangular MFs the area and center of area of the
implied fuzzy sets are easily calculated. If a symmetric triangle has a
height 1 and base width w :
The area ofa triangle
with the top “chopped off” at height h is
h2
equal to w h − 2
The area of a triangle with height h is equal to 12 wh
Here w is the support length of B̂ji and h is µpremise(i) (x1 , x2 , . . . , xn ).
h h
0 w 10 20 0 w 10 20
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
U µpl(1)
b (u)du+ U µpcs(2) (u)du+ U µpcs(3) (u)du+ U µzb(4) (u)du
(20)(1.1719)+(10)(4.6875)+(10)(1.1719)+(0)(2.1875) 82.032
= 1.1719+4.6875+1.1719+2.1875 = 9.2188 = 8.90
U µpl(1)
b (u)du+ U µpcs(2) (u)du+ U µpcs(3) (u)du+ U µzb(4) (u)du
(20)(0.625)+(10)(3.75)+(10)(0.625)+(0)(1.25) 56.25
= 0.625+3.75+0.625+1.25 = 6.25 = 9.0
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
ucrisp =
n o
bpl supu µpl(1) (u) +bps supu {µpcs(2) (u)}+bps supu {µpcs(3) (u)}+bz supu {µzb(4) (u)}
=
b
n o
supu µpl(1)
b (u) +supu {µpcs(2) (u)}+supu {µpcs(3) (u)}+supu {µzb(4) (u)}
(20)(0.125)+(10)(0.75)+(10)(0.125)+(0)(0.25) 11.25
= 0.125+0.75+0.125+0.25 = 1.25 = 9.0
15
10
5
force
−5
−10
−15
0.6
0.4 1.5
0.2 1
0 0.5
−0.2 0
−0.4 −0.5
−0.6 −1
−1.5
errorDot
error
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
0.1
Angle (rad)
0
Theta
−0.1
ThetaDot
−0.2
0 2 4 6 8 10 12 14 16 18 20
0.5
0
Position (m)
−0.5
Position
−1
PositionDot
−1.5
0 2 4 6 8 10 12 14 16 18 20
20
10
Force (N)
0
−10 Control influence
−20 Interference
0 2 4 6 8 10 12 14 16 18 20
Time (s)
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Outline
Outline
Takagi-Sugeno FIS
zi = an x1 + an−1 x2 + · · · + a1 xn + a0 ,
where
PR the fuzzy system is defined so that
i=1 µpremise(i) (x1 , x2 , . . . , xn ) 6= 0, ∀xi .
Thus the Sugeno FIS can be used as a general mapper for a wide
variety of applications.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
20
15
10
0
out
−5
−10
−15
−20
0.5 0.3
0.2
0 0.1
0
−0.5 −0.1
−0.2
−1
in2
in1
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
1
Act. position
0
−1
−2
0 2 4 6 8 10 12 14 16 18 20
0.4
Theta
0.2
Angle (rad)
−0.2
−0.4
0 2 4 6 8 10 12 14 16 18 20
10
Control influence
5
Force (N)
−5
−10
0 2 4 6 8 10 12 14 16 18 20
Time (s)
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Outline
FIS Tuning
As was mentioned, the testing and tuning is the last step of FIS
development. If testing fails, the FIS has to be tuned or even redesigned.
r(t)
Σ g1
+ Fuzzy logic u(t) y(t)
- h Process
d g2 controller
dt
External FIS tuning is performed via input and output scaling gains. The
gain values may be either constant or functions of some sort, e.g. bell or
Gaussian functions.
Internal tuning is performed by reviewing the membership functions and
the rule-base. Trying out different inference and defuzzification
operations is also a good practice.
The MATLAB FIS editor is a good tool for debugging. There you can
observe the reaction of your rule firing strengths, input-output curves,
etc. to the changes you make.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Outline
0 5 10 15 20 25 30 35 40
4.5
3.5
2.5
1.5
Set value
0.5 Upper limit
Lower limit
Liquid level: PID
0 Liquid level: Fuzzy PID
0 5 10 15 20 25 30 35 40
Time (s)
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Outline
Fuzzy Predictor
where θ̂k+1 is the predicted value of the time series, θ̂k is the last known
predicted value, θ̃k is the last observed value and α ∈ [0, 1] is the weight
parameter.
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Specify the FIS input as error ek = θ̂k − θ̃k , then develop rules, e.g.
For the majority of applications it is assumed that the noise has fixed
variance and a normal distribution
What to do, if noise is time variant and has varying distribution?
One solution is the to develop a fuzzy system, which will estimate noise
parameters and tune the controller, filter, etc. online
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Outline
ANFIS Architecture
The first-order Sugeno system r-th rule takes the form
IF x1 is Ak1 AND x2 is Al2 AND . . . AND xn is Apn
THEN fr = pn,r x1 + pn−1,r x2 + · · · + p1,r xn + p0,r
Lets take a system with two inputs x1 , x2 , one output y, and two rules:
Rule1 : IF x1 is A11 AND x2 is A12 THEN f1 = p2,1 x1 + p1,1 x2 + p0,1
Rule2 : IF x1 is A12 AND x2 is A22 THEN f2 = p2,2 x1 + p1,2 x2 + p0,2
Layer 1: Every i∗ -th node is an adaptive node with a function
Besides product, other operations for the linguistic AND may be used.
Layer 3: Every i∗ -th node is a fixed node, which computes the ratio of
the i∗ -th firing strength to the sum of all R rules firing strengths:
w i∗
O3,i∗ = wi∗ = PR , i∗ = 1, 2.
r=1 wr
Layer 5: The single node is a fixed node, which computes the overall
output as a summation of all incoming values:
R PR
X wr fr
O5,1 = y = wr fr = Pr=1
R
.
r=1 r=1 wr
ANFIS Training
During the forward pass node outputs go forward until layer 4 and
the consequent parameters are identified by the least-squares method
In the backward pass the error signals (i.e. reference minus layer 4
output) propagate backward and the premise parameters are
updated by gradient descent
Outline
Reference model,
fuzzy expert system
Adaptation
mechanism
Controller
parameters
Adaptive mapper:
Fuzzy expert system ANFIS or other
Process
Controller parameters System
designer identification
Controller
parameters
Outline
Fuzzy clustering and fuzzy classification differ from conventional crisp clustering
and classification approaches in that:
Outline
M. Athans, Crisp Control Is Always Better Than Fuzzy Feedback Control, EUFIT ’99 debate with prof. L.A. Zadeh
Concepts of Fuzzy Logic Fuzzy Inference Systems Applications
Useful Literature