Fuzzy Expert System: Fuzzy Logic: Faculty of Electrical & Electronics Engineering University Malaysia Pahang
Fuzzy Expert System: Fuzzy Logic: Faculty of Electrical & Electronics Engineering University Malaysia Pahang
FUZZY LOGIC
Achievements : CO2
o Introduction, or what is fuzzy thinking?
o Fuzzy sets
o Linguistic variables and hedges
o Operations of fuzzy sets
o Fuzzy rules
o Summary
Experts rely on common sense when they
solve problems
How can we represent expert knowledge that
uses vague and ambiguous terms in a
computer?
Fuzzy logic is not logic that is fuzzy, but logic
that is used to describe fuzziness.
Fuzzy logic is based on the idea that all
things admit of degrees.
Fuzzy logic is the theory of fuzzy sets, sets
that calibrate vagueness.
Bicycle tyre pressure : IC supply voltage :
Expert knows how to Expert knows a
measure and human Existence of considerable average
may understand on Degree or of voltage stability and
when to re-pump the range to be supplied,
pressure. But how Level but can system or
about computer software define
interpretation? properly as we expect?
Degree of
confidence,
multi-
valued,
humanistic
Range of
Vagueness logic
Classic
logic
0.6
0.4
0.2
0.0
150 160 170 180 190 200 210
Height, cm
Degreeof Fuzzy Sets
Membership
1.0
0.8
0.6 Short Average Tall
0.4
0.2
0.0
150 160 170 180 190 200 210
A B
Fuzzy set
Crisp set
Crisp set Fuzzy set
fA(x): X ® {0, 1}, where mA(x): X → [0, 1], where mA(x) = 1 if x is
totally in A;
1, if x A mA (x) = 0 if x is not in A;
f A ( x) =
0, if x A 0 < mA (x) < 1 if x is partly in A.
A = { (x1, μA(x1)), (x2, μA(x2)),…., (xn, μA(xn)) }
Membership association
Achievements : CO2
3.3 Fuzzy Set Operations
0.4
Very Short Very
VeryTall
Tall
Tall
0.2
0.0
150 160 170 180 190 200 210
Height, cm
Hedges in fuzzy logic
Hedge Mathematical Graphical Representation
Expression
Very [ mA (x)] 2
Extremely [ mA(x) ] 3
Hedges in fuzzy logic (cont’d)
Mathematical
Hedge Graphical Representation
Expression
Somewhat mA (x)
2 [mA (x )]2
if 0 m A 0.5
Indeed
1 − 2 [1 −m A ( x)]2
if 0.5 < mA 1
Operations of fuzzy sets
The classical set theory developed in the late 19th
century by Georg Cantor describes how crisp sets can
interact. These interactions are called operations.
Not A
B
A AA
Complement Containment
A B AA B
Intersection Union
◼ Complement
Crisp Sets: Who does not belong to the set?
Fuzzy Sets: How much do elements not belong to
the set?
The complement of a set is an opposite of this set.
Tall men : (0/180, 0.25/182.5, 0.5/185, 0.75/187.5, 1/190)
For example, if we have the set of tall men, its
NOT Tall men : (1/180, 0.75/182.5, 0.5/185, 0.25/187.5, 0/190)
complement is the set of NOT tall men. When we
remove the tall men set from the universe of
discourse, we obtain the complement. If A is the
fuzzy set, its complement ØA can be found as
follows:
mA(x) = 1 − mA(x)
◼ Containment
Crisp Sets: Which sets belong to which other sets?
Fuzzy Sets: Which sets belong to other sets?
Similar to a Chinese box, a set can contain other
sets. The smaller set is called the subset. For
example, the set of tall men contains all tall men;
very
Tall mentall men is
: (0/180, 0.25/182.5, of tall men
a subset 0.5/185, 0.75/187.5, 1/190)
. However, the
Very
talltall
menmenset
: (0/180,
is just0.1/182.5,
a subset0.4/185, 0.3/187.5,
of the set of men1/190)
. In
crisp sets, all elements of a subset entirely belong to
a larger set. In fuzzy sets, however, each element
can belong less to the subset than to the larger set.
Elements of the fuzzy subset have smaller
memberships in it than in the larger set.
◼ Intersection
Crisp Sets: Which element belongs to both sets?
Fuzzy Sets: How much of the element is in both sets?
In classical set theory, an intersection between two sets contains
the elements shared by these sets. For example, the intersection
of the set of tall men and the set of fat men is the area where
Tall men : (0/180, 0.25/182.5, 0.5/185, 0.75/187.5, 1/190)
these sets overlap. In fuzzy sets, an element may partly
Very tall men : (0/180, 0.1/182.5, 0.4/185, 0.3/187.5, 1/190)
belong to both sets with different memberships. A fuzzy
So, mA∩B(x) = (0/180, 0.1/182.5, 0.4/185, 0.3/187.5, 1/190)
intersection is the lower membership in both sets of each
element. The fuzzy intersection of two fuzzy sets A and B on
universe of discourse X:
mA∩B(x) = min [mA (x), mB (x)] = mA (x) ∩ mB(x),
where xϵX
◼ Union
Crisp Sets: Which element belongs to either set?
Fuzzy Sets: How much of the element is in either set?
The union of two crisp sets consists of every element
that falls into either set. For example, the union of
tall men and fat men contains all men who are tall
OR men
Tall fat. :In fuzzy0.25/182.5,
(0/180, sets, the union is 0.75/187.5,
0.5/185, the reverse1/190)
of the
Very tall men : (0/180,
intersection. 0.1/182.5,
That is, 0.4/185,
the union is the0.3/187.5,
largest 1/190)
So, mAUB(x) = (0/180,
membership value0.25/182.5, 0.5/185,
of the element in 0.75/187.5,
either set. 1/190)
The
fuzzy operation for forming the union of two fuzzy
sets A and B on universe X can be given as:
m ( x) m ( x)
1 1
AB AB
0 0
x x
1 AB 1
AB
0 0
x x
Intersection Union
Commutavity - A U B = B U A
Associativity
A U (B U C) = (A U B) U C
A ∩ (B ∩ C) = (A ∩ B) ∩ C
Distributivity
A U (B ∩ C) = (A U B) ∩ ( A U C)
A ∩ (B U C) = (A ∩ B) U ( A ∩ C)
Idempotency
Identity
Involution
Transitivity
3.4 Fuzzy Relation
3.5 Fuzzy Inference
LO1 : Able to execute fuzzy sets using the common fuzzy operations
LO2 : Able to understand and determine the purpose of fuzzy relations
LO3 : Able to understand how inference process is done in fuzzy
implication
LO4 : Able to understand how to design a fuzzy logic controller
LO5 : Able to understand how inference process is done in a fuzzy logic
controller
Achievements : CO2
Fuzzy rules
In 1973, Lotfi Zadeh published his second most
influential paper.
IF x is A
THEN y is B
Rule: 1 Rule: 2
IF speed is > 100 IF speed is < 40
THEN stopping_distance is long THEN stopping_distance is short
The variable speed can have any numerical value between 0 and
220 km/h, but the linguistic variable stopping_distance can take
either value long or short.
Rule 1 : Rule 2 :
IF speed is fast IF speed is slow
THEN stopping_distance is long THEN stopping_distance is short
0.4 0.4
0.2 0.2
0.0 0.0
160 180 190 200 70 80 100 120
Height, cm Weight, kg
0.4 0.4
0.2 0.2
0.0 0.0
160 180 190 200 70 80 100 120
Height, cm Weight, kg
A fuzzy rule can have multiple antecedents,
for
example:
IF project_duration is long
AND project_staffing is large
AND project_funding is inadequate
THEN risk is high
IF service is excellent
OR food is delicious
THEN tip is generous
The consequent of a fuzzy rule can also
include multiple parts, for instance:
IF temperature is hot
THEN hot_water is reduced;
cold_water is increased
Fuzzy inference - process of mapping a
given input to an output using the fuzzy sets
theory.
Several techniques are available, commonly
listed as follow;
◦ Mamdani-style inference
◦ Sugeno-style inference
Historic event ; Prof Ebrahim Mamdani designed a control
system for a combination of steam engine and boiler
combination using fuzzy system.
Rule 1
IF project funding is adequate
OR project staffing is small
THEN risk is low Project Funding
Rule 2
IF project funding is marginal
AND project staffing is large
THEN risk is normal
Project Staffing
Rule 3
1 IF project funding is1 inadequate 1
THEN risk is A3
high B1 C1 C2 C3
0.1 OR 0.1
0.0
(max)
0 x1 X 0 y1 Y 0 Z
Risk
Rule 1: IF x is A3 (0.0) OR y is B1 (0.1) THEN z is C1 (0.1)
Rule 1
IF x is A3 Crisp Input Crisp Input
OR y is B1 x1 = 35% y1 = 60%
THEN z is C1
Rule 2
IF x is A2
AND y is B2
THEN z is C2
Rule 3
IF x is A1
THEN z is C3
The second step is to take the fuzzified
inputs,
m(x=A1) = 0.5 m(y=B1) = 0.1
m(x=A2) = 0.2 m(y=B2) = 0.7
0 x1 X 0 Z
Rule 3: IF x is A1 (0.5) THEN z is C3 (0.5)
Fuzzified Val → m(x=A1) = 0.5, m(x=A2) = 0.2, m(y=B1) = 0.1, m(y=B2) = 0.7,
Now the result of the antecedent evaluation can be
applied to the membership function of the
consequent.
◼ The most common method of correlating the rule
consequent with the truth value of the rule antecedent
is clipping; to cut the consequent membership
function at the level of the antecedent truth.
◼ Since the top of the membership function is sliced, the
clipped fuzzy set loses some information.
◼ Clipping involves less complex and faster
mathematics, and generates an aggregated output
surface that is easier to defuzzify.
◼ While clipping is a frequently used method, scaling
offers a better approach for preserving the original
shape of the fuzzy set. The original membership
function of the rule consequent is adjusted by
multiplying all its membership degrees by the truth
value of the rule antecedent. This method, which
generally loses less information, can be very useful in
fuzzy expert systems.
Degree of Degree of
Membership Membership
1.0 1.0
C2 C2
0.2 0.2
Clipping Scaling
0.0 0.0
Z Z
Aggregation : process of unification of
outputs of all rules or combining clipped or
scaled rules on previous consequents.
The output
One fuzzy set for each output variable.
Aggregation of the rule outputs
1 1 1
C1 C2 C3
0.5 0.5
0.2 0.2
0.1 0.1
0 Z 0 Z 0 Z 0 Z
b
mA x x dx
COG = a
b
m A x dx
a
◼ Centroid defuzzification method finds a point
representing the centre of gravity of the fuzzy set,
A, on the interval, ab.
◼ A reasonable estimate can be obtained by
calculating it over a sample of points.
1.0
0.8
0.6 A
0.4
0.2
a b
0.0 X
150 160 170 180 190 200 210
Centre of gravity (COG):
(0 + 10 + 20) 0.1 + (30 + 40 + 50 + 60) 0.2 + (70 + 80 + 90 + 100) 0.5
COG = = 67.4
0.1 + 0.1 + 0.1 + 0.2 + 0.2 + 0.2 + 0.2 + 0.5 + 0.5 + 0.5 + 0.5
Degreeof
Membership
1.0
0.8
The risk percentage to conduct project with 35% project
0.6
funding and 60% project staffing will give result 67.4% risk.
0.4
0.2
0.0
0 10 20 30 40 50 60 70 80 90 100
67.4 Z
3.4 Fuzzy Relation
3.5 Fuzzy Inference
LO1 : Able to execute fuzzy sets using the common fuzzy operations
LO2 : Able to understand and determine the purpose of fuzzy relations
LO3 : Able to understand how inference process is done in fuzzy
implication
LO4 : Able to understand how to design a fuzzy logic controller
LO5 : Able to understand how inference process is done in a fuzzy logic
controller
Achievements : CO2
3.5 Fuzzy Inference – Sugeno style
inference
Achievements : CO2
Mamdani-style : finding the centroid/weightage of the
consequent across continuously varying function – not
computationally efficient
Michino Sugeno-style use singleton to represent the
membership of a system instead of trapezium, triangle etc.
Rule 2 Rule 2
In Sugeno :
IF project funding is marginal IF x is A2
1
AND project staffing is large AND y is B2
THEN risk is normal THEN z is C2
Rule 3 Rule 3
IF project funding is 0 k1 k2 k3 Z
IF x is A1
inadequate User define : k1 = 20, k2 = 50 and k3 = 80
THEN z is C3
THEN risk is high
Dwi Pebrianti, 2015/2016 Semester 2
1 1 1
A3 B1
0.1 OR 0.1
0.0
(max)
0 x1 X 0 y1 Y 0 k1 Z
0 x1 X 0 k3 Z
Rule 3: IF x is A1 (0.5) THEN z is k3 (0.5)
0 z1 Z
Crisp Output
z1
Hamam, A.; Georganas, N.D.; 2008
Mamdani-style
Refer KALAM in Chapter 3 section.
The universe of discourse is X = {0, 20, 40, 60, 80, 100} . Find the membership
function for the two sensors: Find the following membership functions using
standard set operations:
a) μS1 U S2(x) b) μS1 ∩ S2(x)
Each sensors has the following membership of fuzzy set.
S1 = {0.5/20, 0.65/40, 0.85/60, 1/80, 1/100 }
S2 = {0.35/20, 0.5/40, 0.75/60, 0.9/80, 1/100}
a) μS1 U S2(x)
= {0.5/20, 0.65/40, 0.85/60, 1/80, 1/100 }
b) μS1 ∩ S2(x)
= {……………………………………………………………}
Let x be the universe of commercial aircraft of interest
Very [ mA (x)] 2
Extremely [ mA(x) ] 3
Hedges in fuzzy logic (cont’d)
Mathematical
Hedge Graphical Representation
Expression
Somewhat mA (x)
2 [mA (x )]2
if 0 m A 0.5
Indeed
1 − 2 [1 −m A ( x)]2
if 0.5 < mA 1
The problem is to design a fuzzy expert
system to predict (advise) how much to buy
or sell shares in a company based on two
sources of information:
1. the past share price of the company itself (share
pr), and
2. the Euro / Dollar exchange rate (xchg rate)
Membership of each Input
1. share_pr : falling, stable, rising
2. xchg_rate : low, medium, high
Rule applied :
1. IF share_pr is falling AND xchg_rate is high THEN
advice is sell
2. IF share_pr is stable THEN advice is keep
3. IF share_pr is rising OR xchg_rate is low then
advice is buy
share_pr xchg_pr advice
If the previous share price is 10, and the exchange rate is 4.5, then what should the
company do?
Do the calculation by using Mamdani.
-1.82 → the company
should buy more
share about 1.82