Download Fuzzy Control

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Inquiry wikipedia , lookup

History of the function concept wikipedia , lookup

Statistical inference wikipedia , lookup

Natural deduction wikipedia , lookup

Fuzzy concept wikipedia , lookup

Fuzzy logic wikipedia , lookup

Transcript
Introduction to Fuzzy Control
Lecture 10.1
Appendix E
Fuzzy Control
• Fuzzy Sets
• Design of a Fuzzy Controller
– Fuzzification of inputs: get_inputs()
– Fuzzy Inference
– Centroid Defuzzification
Fuzzy Logic
" So far as the laws of mathematics refer to reality, they are not certain,
And so far as they are certain, they do not refer to reality."
Albert Einstein
Geometrie und Erfahrung
Normal “Crisp” logic
where everything must be either
True or False
leads to
PARADOXES
The sentence on the other side
of the line is false
The sentence on the other side
of the line is false
A barber has a sign that reads:
“I shave everyone who does
not shave himself”
Who shaves the barber?
Fuzzy Logic
• Lotfi Zadeh - Fuzzy Sets - 1965
• Membership functions
– Degree of membership between 0 and 1
• Fuzzy logic operations on fuzzy sets A and B
– NOT A => 1 - A
– A AND B => MIN(A,B)
– A OR B => MAX (A,B)
Membership Functions
Young
Not Young
Age
Membership Functions
Not Old
Old
Age
Membership Functions
Not Old
Not Young
Middle Age =
Not Old AND Not Young
Age
Probabiltiy vs. Fuzziness
Probability describes the uncertainty of an
event occurrence.
Fuzziness describes event ambiguity.
Whether an event occurs is RANDOM.
To what degree it occurs is FUZZY.
Probability:
There is a 50% chance of an apple
being in the refrigerator.
Fuzzy:
There is a half an apple in the
refrigerator.
Fuzzy logic acknowledges
and exploits the tolerance for
uncertainty and imprecision.
Fuzzy Control
• Fuzzy Sets
• Design of a Fuzzy Controller
– Fuzzification of inputs: get_inputs()
– Fuzzy Inference
– Centroid Defuzzification
Fuzzy Membership Functions
NM
NS
Z
PS
PM
1
0
0
36
82
128
174
Universe of discourse
220 255
Fuzzy Control
Inputs
Map to Fuzzy Sets get_inputs();
Fuzzy Rules
IF A AND B THEN L
*
*
Defuzzification
Output
fire_rules();
find_output();
Algorithm for a fuzzy controller
do_forever
{
get_inputs();
fire_rules();
find_output();
}
Fuzzy Control
• Fuzzy Sets
• Design of a Fuzzy Controller
– Fuzzification of inputs: get_inputs()
– Fuzzy Inference
– Centroid Defuzzification
Fuzzification of inputs
get_inputs()
for i = 1, num_inputs
{
get_x(i);
fill_weight(xi, Mi);
}
get_inputs();
Given inputs x1 and x2, find the weight
values associated with each input
membership function.
NM
NS
Z
PS
0.7
0.2
X1
W = [0, 0, 0.2, 0.7, 0]
PM
Fuzzy Control
• Fuzzy Sets
• Design of a Fuzzy Controller
– Fuzzification of inputs: get_inputs()
– Fuzzy Inference
– Centroid Defuzzification
Fuzzy Inference
if x1 is A1 and x2 is B1 then y is L1
rule 1
if x1 is A2 and x2 is B2 then y is L2
rule 2
Given the fact that
x1 is A' and x2 is B'
fact
the problem is to find the conclusion
y is L'
conclusion
Fuzzy Inference
A1
m
B1
m
rule 1
w1
m
L1
w2
w2*L1
x2
x1
m
m
A2
B2
w2
y
rule 2
m
L2
w1
a
w1*L2
x1
b
x2
y
sum
m
L'
y0
y
Comparing the MAX rule and the SUM rule
m
m
m
L'
L'
L'
y0
Maximum
y
y0
Sum
y
y0
Singletons
y
Fuzzy Control
• Fuzzy Sets
• Design of a Fuzzy Controller
– Fuzzification of inputs: get_inputs()
– Fuzzy Inference
– Centroid Defuzzification
E.5 Centroid Defuzzification
The last step in the fuzzy controller shown in Figure E.7 is defuzzification. This
involves finding the centroid of the net output fuzzy set L' shown in Figures E.10 and
E.11. Although we have used the MIN-MAX rule in the previous section we will begin
by deriving the centroid equation for the sum rule shown in Figure E.11. This will
illuminate the assumptions made in deriving the defuzzification equation that we will
actually use in the fuzzy controller.
Let Li(y) be the original output membership function associated with rule i where
y is the output universe of discourse (see Figure E.10.). After applying rule i this
membership function will be reduced to the value
mi(y) = wiLi(y)
(E.1)
where wi is the minimum weight found by applying rule i. The sum of these reduced
output membership functions over all rules is then given by
N
M(y) =
mi(y)
i=1
where N is the number of rules.
(E.2)
The crisp output value y0 is then given by the centroid of M(y) from the equation

yM(y)dy
y0 =

M(y)dy
(E.3)
Note that the centroid of membership function Li(y) is given by
yL
 i(y)dy
ci =
L
 i(y)dy
(E.4)
But
Ii = L
 i(y)dy
(E.5)
is just the area of membership function Li(y). Substituting (E.5) into (E.4) we can write
yL
 i(y)dy = ciIi
(E.6)
Using Eqs. (E.1) and (E.2) we can write the numerator of (E.3) as

yM(y)dy
 N
= y wiLi(y) dy

 i=1
N
=
 iLi(y) dy
yw
i=1
N
=
 wiciIi
i=1
where (E.6) was used in the last step.
(E.7)
Similarly, using (E.1) and (E.2) the denominator of (E.3) can be written as

M(y)dy
N
=  wiLi(y) dy

i=1
N
=
 iLi(y) dy
w
i=1
N
=
 wiIi
(E.8)
i=1
where (E.5) was used in the last step. Substituting (E.7) and (E.8) into (E.3) we can write
the crisp output of the fuzzy controller as
N
 wiciIi
i=1
y0 = N
(E.9)
 wiIi
i=1
Eq. (E.9) says that we can compute the output centroid from the centroids, ci, of the
individual output membership functions.
Note in Eq. (E.9) the summation is over all N rules. But the number of output
membership functions, Q, will, in general, be less than the number of rules, N. This
means that in the sums in Eq. (E.9) there will be many terms that will have the same
values of ci and Ii. For example, suppose that rules 2, 3, and 4 in the sum all have the
output membership function Lk as the consequent. This means that in the sum
w2c2I2 + w3c3I3 + w4c4I4
the values ci and Ii are the same values ck and Ik because they are just the centroid and
area of the kth output membership function. These three terms would then contribute the
value
(w2 + w3 + w4)ckIk = WkckIk
to the sum, where
Wk = (w2 + w3 + w4)
is the sum of all weights from rules whose consequent is output membership function Lk.
This means that the equation for the output value, y0, given by (E.9) can be rewritten as
Q
 WkckIk
y0 =
k=1
Q
(E.10)
 WkIk
k=1
If the area of all output membership functions, Ik are equal, then Eq. (E.10) reduces to
Q
 Wkck
y0 =
k=1
Q
(E.11)
 Wk
k=1
Eqs. (E.10) and (E.11) show that the output crisp value of a fuzzy controller can be
computed by summing over only the number of output membership functions rather than
over all fuzzy rules. Also, if we use Eq. (E.11) to compute the output crisp value, then
we need to specify only the centroids, ck, of the output fuzzy membership functions. This
is equivalent to assuming singleton fuzzy sets for the output.