Chapter 4-1 - Introduction To Fuzzy Logic
Chapter 4-1 - Introduction To Fuzzy Logic
Chapter 4:
Introduction to Fuzzy Logic
Part 4 – Fuzzy Logic and Fuzzy Set Operations
•www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 2
4.1
Overview of fuzzy systems
What is fuzzy logic?
•www.utm.my
Concept of fuzzy logic control system
History of Fuzzy Logic
Applications of Fuzzy Systems
www.utm.my
rather than the likelihood of their occurrence (probability).
For example, the degree to which a person is young is a fuzzy
event rather than a random event.
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 5
Example of Differences Between
Fuzzy Logic and Crisp Logic
Precise Imprecise
Properties Properties
www.utm.my
Girls age 13 yrs Girls about 13yrs
People 1.5m tall People about 1.5m tall
www.utm.my
Fuzzy logic can handle such linguistic imprecision
where other techniques have difficulty in handling
www.utm.my
When you are at 10 metres from the junction start braking at 50% pedal
level.
Intersection, AND
mA∩ B ( x ) = min{mA ( x ), mB ( x )}
Union, OR
www.utm.my
m A∪ B ( x) = max{m A ( x), mB ( x)}
Fuzzy Controller
Plant
www.utm.my
In this course much of the applications will be
centred around fuzzy logic control systems.
Defuzzification
Inferencing
Fuzzification
Rule Base 3
If X is A
And Y is B
1 4
Then Z is C
www.utm.my
Sensor Control
Readings Signals
www.utm.my
• Are simple to implement
• And best of all they often
work!
MEEM 1713 – ARTIFICIAL INTELLIGENCE 12
Brief History of Fuzzy Logic
www.utm.my
• 1989 - LIFE (Lab for International Fuzzy Eng.)
www.utm.my
techniques
2000 – now – More applications
www.utm.my
Tokyo’s Electric Town
MEEM 1713 – ARTIFICIAL INTELLIGENCE 15
The major success of Fuzzy Logic in the mid-eighties is mainly
due to its introduction into Consumer Products
www.utm.my
- Rice Cookers
- Air Conditioners
- Brake control of vehicles
- Heaters
MEEM 1713 – ARTIFICIAL INTELLIGENCE 16
In 1990, with the introduction of Fuzzy Logic Washing
Machines, extremely high sales were recorded!
www.utm.my
This prompted many other consumer product manufacturers
to start using fuzzy logic in their products.
Load Sensor
www.utm.my
Light Receptor
Drained out
water
MEEM 1713 – ARTIFICIAL INTELLIGENCE 18
Fuzzy Logic Automatic
Gear Shift Control in Vehicles
Output: Gear
Fuzzy Logic
Shift Pattern
www.utm.my
Fuzzy logic is used to determine the
best gear position in difficult conditions
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 20
Supervisory Elevator Control by Fuzzy Logic
Hall Call
Group Controller States of Each Car
Car Position
Command Car Calls
Direction etc.
Car Call
Actuator Actuator Actuator
www.utm.my
Elevator 1 Elevator 2 Elevator n
MEEM 1713 – ARTIFICIAL INTELLIGENCE 21
Introduction to Fuzzy Logic
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 22
4.2
Definition of Fuzzy Sets
•www.utm.my
Fuzzy sets compared with crisp set
Fuzzy set notations
Membership functions
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 24
Definition of Fuzzy Sets
www.utm.my
0
u
Membership value
Fuzzy set A
www.utm.my
1.0
Membership function
Universe of discourse u
MEEM 1713 – ARTIFICIAL INTELLIGENCE 26
4.2.2 Fuzzy Set Notations
www.utm.my
F = {(u, µ F (u )) u ∈ U }
F = Σµ F (ui ) / ui
or
F = µ F (u I ) / u I + µ F (u 2 ) / u 2 + ... + µ F (u N ) / u N
www.utm.my
or
www.utm.my
• Error
Membership Value, µΗ
www.utm.my
140 150 HEIGHT,
160 170 180
H(cm)
F= 0.1/2+0.4/3+0.85/4+1.0/5+0.85/6+0.4/7+0.1/8
F=0.4/2+0.8/3+1/4+0.8/5+0.4/6+0.1/7+0.0/8
www.utm.my
As discussed, fuzzy set (F) can be written in the following form:
µ F (u ) > 0 u
µA
Crossover point
Crossover point
The element u in U at which is called 1.0
the crossover point when
0.5
µ F (u ) = 0.5
u
www.utm.my
Fuzzy singleton µA
A fuzzy singleton
A fuzzy set whose support is a single point
in U is referred to as a fuzzy singleton.
µA
α -cut set of a fuzzy set. α-cut set
The α -cut set of a fuzzy set F, labeled with F α
by convention, is the crisp set of all points u in U 1
such that.
µF (u ) ≥ α
α
Note that an α-set discards the point whose
0
membership values are lower than α. u
Normalization µA
This process simply involves re-scaling the NORM(A)
membership function so that its maximum
www.utm.my
1
value is 1, that is: A
µ NORM ( A ) (u ) = µ A (u ) / max(µ A (u )) ∀u ∈ U
0
u
MEEM 1713 – ARTIFICIAL INTELLIGENCE 33
4.2.3 Membership Functions
Two ways to define the membership for fuzzy sets: numerical and
functional.
F= 0.1/2+0.4/3+0.85/4+1.0/5+0.85/6+0.4/7+0.1/8
www.utm.my
1
f ( x) =
1 + ( x − 5) 2
www.utm.my
gaussian.
Π - membership function µA
1.0
www.utm.my
S (u; c-b, c-b/ 2 , c ) for u ≤ c
π (u; b, c ) = 0.5
b
1-S (u; c, c + b/ 2 , c + b ) for u ≥ c
c-b c-b/2 c c+b/2 c+b u
www.utm.my
1.0
(u − a ) / (b − a ) for a ≤ u ≤ b
T (u; a, b, c ) =
(c − u ) / (c − b ) for b ≤ u ≤ c
0 for u > c
a b c u
MEEM 1713 – ARTIFICIAL INTELLIGENCE 37
Exercise 4.1
1
(2). Write down the mathematical
www.utm.my
expression of this membership
function.
-1 0 2 4 5
F = {( y, µ F ( y )) y ∈ y}
•www.utm.my
the required fuzzy set should have a maximum at around 45, and go to zero
below 30 and above 60. Usually, a Gaussian-function or T-function gives a
good description in such circumstances.
0 for 0 ≤ y ≤ 30
( y − 30 ) / 15 for 30 ≤ y ≤ 45
µF (y) =
(60 − y ) / 15 for 45 ≤ y ≤ 60
0 for 60 ≤ y ≤ 120
1.0
www.utm.my
30 45 60
www.utm.my
Draw the graph for this membership function to show “youngness”.
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 42
4.3
Fuzzy Sets Operations
Basic fuzzy set operations
Fuzzy set operations for modifying
•www.utm.my
membership functions
Some advanced fuzzy set operations
1, x ∈ A
χ A ( x) =
0, x ∉ A
where χA expresses membership in set A for the
element x in the universe.
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 44
Operations for Function-theoretic Terms
Consider 2 sets: A and B, on the universe X.
Union: A ∪ B → χ A∪ B ( x) = χ A ∨ χ B = max(χ A , χ B )
Intersection: A ∩ B → χ A∩ B ( x) = χ A ∧ χ B = min(χ A , χ B )
Complement: A → χ A ( x) = 1 − χ A ( x)
www.utm.my
Containment: A ⊆ B → χ A ( x) ≤ χ B ( x)
MEEM 1713 – ARTIFICIAL INTELLIGENCE 45
4.3.1 Basic Fuzzy Set Operations
www.utm.my
one fuzzy set
to another?
u u
Equality
Two fuzzy sets A and B are equal if they are defined on the same
universe and the membership function is the same for both, that is:
A= B iff µ A (u ) = µ B (u ) ∀ u ∈U
Union
The union of two fuzzy sets A and B is the fuzzy set whose
membership function is given by:
www.utm.my
A B
µ A∪ B (u ) = max{µ A (u ), µ B (u )} ∀ u ∈ U
Intersection
The intersection of two fuzzy sets A and B is the fuzzy set whose
membership function is given by:
µ A B (u ) = min{µ A (u ), µ B (u )} ∀ u ∈ U
www.utm.my
A B
Subset
A ⊆ B iff µ A (u ) ≤ µ B (u ) ∀u ∈ U
Draw the graph showing “subset”
Complement
The complement of a (normalized) fuzzy set A with membership
function µA is defined as the fuzzy set on the same universe with
www.utm.my
membership function:
µ A ' (u ) = 1 − µ A (u ) ∀ u ∈ U Not A
Power
If p is a positive number and A is a fuzzy set with membership
function µA(u), then A on power p, denoted by Ap, is defined as:
www.utm.my
{
A p = {( x, µ A ( x))} = ( x, ( µ A ( x)) p
p
}
1
A
CON(A)
www.utm.my
0
Note: This operation is unique with fuzzy sets only. If this operation is carried out
with a crisp set, it results in no change.
µ DIL ( A ) (u ) = (µ A (u ))0.5 ∀ u ∈ U
µA
1
DIL(A)
A
www.utm.my
0
Note: These operations are unique with fuzzy sets only. If they are carried out
with crisp sets, they result in no change.
µA
www.utm.my
1
A INT(A)
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 54
Solution 4.3
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 55
Exercise 4.4
u for 0 ≤ u ≤ 1
µ A (u ) =
www.utm.my
2 − u for 1 < u ≤ 2
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 57
4.3.3 Some Advanced Fuzzy Set Operations
Algebraic product
The algebraic product of two fuzzy sets A and B is the multiplication of
the membership functions which is given by:
µ A⋅B (u ) = µ A (u )µ B (u ) ∀ u ∈U
Algebraic sum
The algebraic sum of two fuzzy sets A and B is also known as
www.utm.my
probabilistic sum and is given by the following expression:
µ A+ˆ B (u ) = µ A (u ) + µ B (u ) - µ A (u )µ B (u ) ∀ u ∈U
Solve:
• algebraic product
www.utm.my
• algebraic sum.
µ AB (u ) = max(0, µ A (u ) + µ B (u ) − 1) ∀u ∈U
Bounded sum
The bounded sum of two fuzzy sets A and B with membership functions
and is the fuzzy set whose membership function is given by:
www.utm.my
µ A⊕ B (u ) = min{1, µ A (u ) + µ B (u ) } ∀ u ∈U
The drastic product of two fuzzy sets A and B with membership function
and is the fuzzy set whose membership function is given by:
µ A (u ) for µ B (u ) = 1
µ A⊗ B (u ) = µ B (u ) for µ A (u ) = 1
0 for µ A (u ), µ B (u ) < 1
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 61
Exercise 4.6:
Consider the fuzzy sets A and B where:
A={(x1, 0.2), (x2, 0.3), (x3, 1), (x4, 0.5), (x5, 0.1), }
B={(x1, 0.0), (x2, 0.3), (x3, 0.6), (x4, 0.7), (x5, 0.9)}
www.utm.my
(4) Bounded sum
(5) Drastic product
Equality μ A (u ) = μ B (u ) u ∈U
Union μ A B (u ) = max{μ A (u ),μ B (u )} for all u ∈ U
Intersection μ A B (u ) = min{μ A (u ),μ B (u )} for all u ∈ U
Complement μ A (u ) = 1 − μ A (u ) u ∈U
Normalization μ NORM ( A ) (u ) = μ A (u ) / max(μ A (u )) u ∈U
μ CON ( A ) (u ) = (μ A (u )) u ∈U
2
Concentration
μ DIL ( A ) (u ) = (μ A (u )) u ∈U
0.5
Dilation
www.utm.my
Bounded product u AB
u A (u ) for u B (u ) = 1
Drastic product u A⊗ B (u ) = u B (u ) for u A (u ) = 1
0 for u A (u ), u B (u ) < 1
•Algebraic Sum
•Algebraic Sum µ A+ˆ B (u ) = µ A (u ) + µ B (u ) - µ A (u )µ B (u ) ∀ u ∈U
MEEM 1713 – ARTIFICIAL INTELLIGENCE 63
4.4
Fuzzy Relations
Fuzzy Relations
•www.utm.my
Compositional Operators
The cartesian product between two fuzzy sets A and B results in a fuzzy
relation R which is contained within the full Cartesian product space:
www.utm.my
A×B=R ⊆ X×Y
where the fuzzy relation R has membership function
µR(x,y)= µA×B(x,y)=min{µA(x), µB(y)}
0.2 0.2
www.utm.my
R = 0.3 0.5
0.3 0.9
The relation does not simply state either ‘yes’(1) or ‘no’(0) but a more
natural degree of association to each pair is given.
For example a relation matrix as follows is given:
Football
1.0
F H B T Ahmad 0.8
www.utm.my
Hockey
Ahmad 0 0.8 0.7 0 Bala 0.7 0.9
Bala 1.0 0 0.3 0 Badminton
Chong 0.3
Chong 0 0.9 0 0.6 Tennis
0.6
Intersection: μ R ∩S ( x, y ) = min{µ R ( x, y ), µ S ( x, y )}
Complement: μ R ( x, y ) = 1 − µ R ( x, y )
www.utm.my
Containment: R ⊂ S ⇒ μ R ( x, y ) ≤ µS ( x, y )
T=R o S
“o” is the compositional operator.
www.utm.my
This operator is “composed” of at least 2 basic fuzzy set
operations.
Some examples are: max-min, max-max, min-max, etc.
MEEM 1713 – ARTIFICIAL INTELLIGENCE 69
Popular Compositional Operators
Max-min operation
T=R°S •In fuzzy logic control
application, Max-min and
µT(x,z) = Max {Min [µR(x,y), µS(y,z)]} Max-product composition
operations are the most
Max-product operation commonly and frequently
T=R°S used because of their
computational simplicity
µ T (x,z) = Max [µR(x,y) . µS(y,z)] and efficiency.
Others:
www.utm.my
Max-bounded sum; Max-bounded product;
Max-drastic product; Max-algebraic sum;
Max-Max; Min-Max; etc.
MEEM 1713 – ARTIFICIAL INTELLIGENCE 70
Example 4.4
www.utm.my
Then the relation, R, can be obtained using the max-min compositional
operations:
0.1 0.5 0.3 0.6 0.8 R 11 R 12 R 13
R = PQ = ° =
0.6 0.9 0.7 0.5 0.4 21
R R 22 R 23
www.utm.my
= 0.6
Assume in a university, for the field of AI, there are four courses
offered:
1. Fuzzy Theory (FT).
2. Fuzzy Control (FC).
3. Neural Networks (NN).
4. Expert Systems (ES).
Three students are planning to take these course based on their
different preferences for theory, application, hardware and
programming. Each of these courses contains parts of the four
properties as described.
www.utm.my
The students are: 1. Ali.
2. Bala.
3. Chin.
Show that the composition of fuzzy relations can help these students in
their decision making.
www.utm.my
Develop the max-min composition of the two fuzzy relations of P(X,Y)
and Q(Y,Z), where this can help the students to choose the proper
courses.
Also solve the problem using Max-product composition.
MEEM 1713 – ARTIFICIAL INTELLIGENCE 74
Based on facts, assume the student's interest is represented by the
fuzzy relation P(X,Y):
Interest, P(X,Y) =
Th Ap Hw Pg
Ali 0.2 1 0.8 0.1
Bala 1 0.1 0 0.5
Chin 0.5 0.9 0.5 1
The properties of the courses are indicated by the following fuzzy
relation Q(Y,Z):
Properties, Q(Y,Z) =
FT FC NN ES
www.utm.my
Th 1 0.5 0.6 0.1
Ap 0.2 1 0.8 0.8
Hw 0 0.3 0.7 0
Pg 0.1 0.5 0.8 1
MEEM 1713 – ARTIFICIAL INTELLIGENCE 75
Using max-min approach:
Thus, P o Q =
FT FC NN ES
AliAli
Bala
Chin
Chin
Ayu
Conclusion,
www.utm.my
1. Ali should choose ........................................
2. Bala should choose ........................................
3. Chin should choose ........................................
www.utm.my
Bala 1.0 0.5 0.6 0.5
Chin 0.5 0.9 0.8 1.0
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 78
OBJECTIVES
In order to save the armature, you need to find the following:
the minimum and maximum level of Rse ?
the minimum and maximum value of Ia ?
Let Rse be the fuzzy set having a number of possible values of the
series resistance, say n values, given by:
www.utm.my
armature current, say m values, given by:
I a = {I1 , I 2 , I 3 ,..., I m }
MEEM 1713 – ARTIFICIAL INTELLIGENCE 79
The Fuzzy sets Rse and Ia can be related through a fuzzy
relation, say R, which would allow for the establishment of
various degrees of relationship between pairs of resistance
and current.
www.utm.my
for the motor speed, say v values, given by:
W = {ω1, ω2,…,ωv }
www.utm.my
T =RοS
µI a (%a ) =
0.2 0.4 0.6 0.8 1.0 0.1
+ + + + +
20 40 60 80 100 120
www.utm.my
µW (rpm ) =
0.33 0.67 1.0 0.15
+ + +
500 1000 1500 1800
µRse (% se ) =
0.3 0.7 1.0 0.2
+ + +
30 60 100 120
• Min(Rse x Ia)
20 40 60 80 100 120
30 0.2 0.3 0.3 0.3 0.3 0.1
www.utm.my
60 0.2 0.4 0.6 0. 7 0 .7 0.1
R=
100 0.2 0.4 0 .6 0.8 1 .0 0.1
120 0.2 0 .2 0.2 0.2 0 .2 0.1
www.utm.my
µ R (60,40 ) = min (0.7,0.4 ) = 0.4, µ R (100,80 ) = min (1.0,0.8) = 0.8,
and µ S (80,1000 ) = min (0.8,0.67 ) = 0.67
www.utm.my
100 0.33 0.67 1.00 0.15
120 0.20 0.20 0.20 0.15
www.utm.my
Try Max-product next.
•www.utm.my
Fuzzy Inference
Fuzzy Reasoning
www.utm.my
rules to be easily programmed (e.g. IF A AND B THEN C).
• Various fuzzy programming tools have been developed to facilitate
fuzzy rule acquisition.
www.utm.my
imprecision which are inherent in natural language, thus it can be
used as the mathematical foundation of our natural language.
One powerful aspect of fuzzy sets in this context is the ability to deal with
linguistic quantifiers or ‘hedges’.
The fuzzy set operations such CON, DIL, INT, etc. (see the Table of Hedges
www.utm.my
and Operators) can be used to modify the fuzzy set HIGH such as shown
below.
Very F CON=F 2
More or Less F DIL=F 0.5
More or less HIGH
HIGH
Plus F F 1.25
Not F 1-F
Not very F 1-CON(F)
www.utm.my
Slightly F INT [Plus F AND Not (Very F)]
A But F A AND F
As an example, if x = Speed with U=[0,100], then its term set T(Speed) could
be.
T(Speed) = {Very Slow, Slow, Moderate, Fast,..}.
Let U be the universe of the fuzzy variable Speed and fuzzy set Fast on U as.
www.utm.my
0 0 .1 0 .3 0 .8 1 1
Fast = + + + + +
5 30 50 70 90 100
µ SPEED
1
Fast
0 Speed
50 90 110
The other corresponding membership functions for the variable speed can also
be formulated in the following manner:
Very Slow
µ
www.utm.my
SPEED
Slow Average Fast
1
0
20 50 70 90 110 Speed
www.utm.my
Fuzzy rules are a set of conditional statements as given in case (ii).
INPUTS OUTPUTS
The general form of the fuzzy control rules in the case of multi-input single
output system (MISO) is:
www.utm.my
where x,.., y and z are linguistic variables representing the process state
variables and the control variable. Ai,.., Bi and Ci are linguistic values of
linguistic variables x,.., y and z in the universes of discourse U,..V and W,
respectively.
MEEM 1713 – ARTIFICIAL INTELLIGENCE 95
4.5.5 Fuzzy Inference
Dragon Fly
6 legs
Knowledge
wings
Base
Body with 3 parts
Insect
Infer
www.utm.my
This is a Sensor
dragon fly!
Knowledge
Base
Sensor Inference
SOLUTIONS
readings Engine
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 97
Example of Intelligent Interpretation
www.utm.my
Humans can handle linguistic imprecision easily because they can infer
well and have a strong knowledge base.
www.utm.my
Fact : The tomato is very red.
www.utm.my
IF <CONDITIONS> THEN <ACTIONS>.
The connectives ‘AND’ and ‘OR’ are frequently used in the antecedent part of
the fuzzy rules, while the connective ‘ALSO’ is often used in the consequent
part of the fuzzy rules.
For instance, consider the kth fuzzy rule in a fuzzy knowledge base expressed
www.utm.my
by:
IF x1 is A k1 OR x 2 is A k2 AND x 3 is A k3
THEN y1 is Bk1 ALSO y 2 is Bk2
MEEM 1713 – ARTIFICIAL INTELLIGENCE 101
Connectives “AND” and “OR”
www.utm.my
OR Union or M
∨ Max.
ax.
• It can be seen that there are two outputs in the consequent part of the
rule.
•www.utm.my
• The fire strength of the rule, which is calculated from the antecedent part,
is applied twice in the computation of y1 and of y2.
The fuzzy rule base shown previously calls the relation corresponding to the kth
rule as Rk.
The overall relation, R, of the fuzzy rule base can be obtained by performing a
“union” operation on R1, R2, R3, ……RN.
Consider a MISO system with N rules. Its kth fuzzy rule is given by:
www.utm.my
In general, the fuzzy relation Rk of the kth rule can be expressed as:
Rk = Ak → Bk
Two examples are given here: (1) max-min and (2) max-product.
The system antecedents are two inputs x = A’ and the consequent is y = B’.
In fuzzy control engineering, the actual inputs are usually in ‘crisp’ form.
www.utm.my
MEEM 1713 – ARTIFICIAL INTELLIGENCE 105
Fuzzy reasoning based on max-min operator is usually referred to as
MAX-MIN fuzzy inference due to the minimum operation rule Rc
involved.
www.utm.my
n
k =1
N
•where A' = A k
k =1
= A' R k
k =1
In many cases several Bk will be obtained where their waveforms are then
combined.
www.utm.my
The defuzzification procedure will be discussed in the next section under
fuzzy logic control.