Lec16 (Is)
Lec16 (Is)
Intelligent Systems
Lecture 16
Fuzzy Logic
Lecturer
Dr. Faris S. Alghareb
PhD in Computer Engineering @ UCF
email: [email protected]
Copyright © 2020 Faris S. Alghareb. All rights reserved.
Fuzzy Logic
v In the real world, many times we encounter in our daily work and home environments a situation
when we cannot determine whether the state is true or false
v In some case, it is hard to make a decision since it is not adequately clear or is vague, therefore,
fuzzy logic was developed to assist in solving complex or fuzzy problems.
v Zadeh had observed that conventional computer logic could not manipulate data
that represented subjective or vague ideas, thus he invented fuzzy logic to allow
computers to determine the distinctions among data with shades of gray in a way
such that the process of human reasoning.
v Fuzzy logic-based systems can be used to do precise decisions, so they are perfectly used where
systems are particularly complex.
v They have been used successfully in many applications such as voice and handwriting recognition
and subway train speed control.
v A crisp subset can be defined from a more extensive set where the elements of the set belong to the
subset according to some condition.
v The opposite word (antonym) of fuzzy is crisp. Fuzzy means unclear or ambiguous while crisp
means clear and sharp (precise).
crisp deals with values that have a strict boundaries, i.e., Fales or True.
v Fuzzy logic provides a very valuable flexibility for reasoning, for example, we can consider the
inaccuracies and uncertainties of any situation
v On the other hand, experienced practical engineers may well be able to control a process without
having the slightest knowledge of its mathematical model.
v They can control the system by knowing only its overall physical characteristics and using their
experience.
v Artificial Intelligence (AI) based control systems have been developed to attempt to replicate the
benefits of human-type reasoning in controller design and implementation.
v In this module, the AI technique that we are going to focus on in this lecture is Fuzzy Logic.
v Fuzzy logic is based on Fuzzy Set Theory – a development of set theory which replace the Boolean
concept of entities either being members of a well-defined set or not with the notion that membership
can be Fuzzy – that entities can have degrees of membership of a set.
v In the next slide, we will start a quick review of basic theory and then extend those concepts to
describe Fuzzy Set Theory.
Shape C
Shape A Shape B Shape D
v Clearly then the objects that have only curves are: Shape C, Shape D, Shape F, and Shape H.
v Therefore, a set {S1} can be created that has these objects.
EECIE20-S4305 Intelligence Systems & Software Engineering: Fuzzy logic Slide 4
Fuzzy Set Theory
v Mathematically, this is written as: S1 = {Shape C, Shape D, Shape F, Shape H}
v The set, {S2}, that has all other objects is: S2 = {Shape A, Shape B, Shape E, Shape G}
v The set that has all the objects is called the universe of discourse and is:
Ø SU = {Shape A, Shape B, Shape C, Shape D, Shape E, Shape F, Shape G, Shape H}
v Subsets can also be created, for example a set S3 that consists of all the objects with 4
angles is: S3 = {Shape A, Shape B, Shape G}
Ø S3 clearly is a subset of S2, i.e., 𝐒𝟑 ⊂ 𝐒𝟐
v Set intersection in=s another set that has the common elements in two sets:
Ø Let S4 = {Shape G, Shape H} then
S2 ∩ S4 = {Shape G}. Note that S2 ∩ S4 = S4 ∩ S2
EECIE20-S4305 Intelligence Systems & Software Engineering: Fuzzy logic Slide 5
Other properties of sets
Other properties of sets are:
Ø A∪A=A
Ø A∩A=A
Ø A ∪ (B ∪ C) = (A ∪ B) ∪ C = A ∪ B ∪ C
Ø A ∩ (B ∩ C) = (A ∩ B) ∩ C = A ∩ B ∩ C
Ø A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)
Ø A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
Ø A∪ ∅=A
Ø A∩ ∅= ∅
v In all the above, an element was either 100% a member of set or 0%. This logic is called Boolean
(True & False logic).
v Now, assume that there is a set of temperatures. Further create a subset that will have all the
temperatures that will correspond to a hot environment.
v Then by using the previous logic, it might be said that hot temperatures are all the temperatures
above 25 degrees:
BUT what about a temperature of 24.99 degrees.
Ø HOT = {temperature | temperature > 25} à Is it hot?
EECIE20-S4305 Intelligence Systems & Software Engineering: Fuzzy logic Slide 6
Boolean and fuzzy sets
v Obviously it is, but not so hot as 25 degrees. This points towards the need to create sets (fuzzy sets)
with elements that do not follow Boolean logic.
v However, this will require a membership function that determines how much they belong to a set.
v For example, the temperature 25 is hot 100%, then 24 is hot 90%, 20 is 50% hot, 15 is 0%, and so
on
Membership Membership
Function Function
𝝁 𝝁
100% 100%
0% 0%
25 Temperature 15 25 Temperature
Boolean Fuzzy
v The membership function that is shown in the figure above is nothing more than a function that
shows how much an element is a member or not of a fuzzy set.
v For instance, if “t ” is the temperature then its membership function for a specific set is 𝝁(t).
EECIE20-S4305 Intelligence Systems & Software Engineering: Fuzzy logic Slide 7
Membership – Mathematical expression
v In the previous example, t = 25 degrees, 𝜇(t) = 1, for t = 24, 𝜇(t) = 0.9, and for t = 15, 𝜇(t) =
0.
v Therefor, to fully define a fuzzy set, it is not enough to say that an element is in it or not.
Pair is needed which will define the element and how much the element belongs or not, i.e.,
its membership function:
A = {𝒙, 𝝁(𝒙) |𝒙 ∈ X}
Ø The above expression indicates that the set A has the element 𝑥 with the membership
𝜇 𝑥 when 𝑥 belongs to the universe of discourse.
Ø Membership value normally goes from zero membership (0) to complete membership
(1).
v The main membership functions that are sometimes used are:
! Triangular form
Triangular
! Trapezoidal form
! Gaussian forms
! Sigmoidal forms Trapezoidal
! Polynomial forms
EECIE20-S4305 Intelligence Systems & Software Engineering: Fuzzy logic Slide 8
Membership Functions
v The choice of membership function shape is not straightforward and only experience can help the
designer. The most common choices are the triangular and trapezoidal, due to their simplicity and
their linearity.
v The figure below illustrates a possible set of fuzzy membership functions that describe temperature.
𝝁(𝒙)
Very
cold Cold Warm Hot
70%
30%
Temperatures
v We can see that the temperature at 11 belongs to the membership function (MF) “Very clod” to the
value around 70% and to the MF Cold about 30%.
v What about temperature 15? (if we try to interest the 15 with the membership form, we can find it is
100% belongs to the MF Cold.
EECIE20-S4305 Intelligence Systems & Software Engineering: Fuzzy logic Slide 9
Membership Function (MF)
v In Boolean Logic, elements are either members of a set or not. There is either full membership or no
membership.
v Thus, the Boolean membership function can be expressed as the following formula:
1, 𝑥 ∈ 𝐴
𝜇! 𝑥 = . i.e., 𝜇' 𝑥 = {0, 1}
0, 𝑥 ∉ 𝐴
v In Fuzzy Logic, set A has no sharp borderline; it is a fuzzy subset of the universe of discourse X.
v Element has a degree of membership of the Fuzzy Set A which lies between 0 and 1. Therefore,
we write its membership function for a fuzzy set as:
𝜇' 𝑥 = {[0, 1]} , where [0, 1] is the range of all values between 0 and 1.
X: Universe A X: Universe A
This element Element that
is not in set A has a degree of
Membership,
This element is Between 0 & 1,
in set A in set A
Boolean system
Yes à 1
using Is the tea hot?
values No à 0
Fuzzy logic
Fuzzification
(Input 1)
Rules Defuzzification
Fuzzification
(Input 2)
T Fuzzy Position
M L M H
H controller
B M H H
Solar system for power-harvesting
Output cases
EECIE20-S4305 Intelligence Systems & Software Engineering: Fuzzy logic Slide 14
Fuzzy system – Example #1
Ø The general representation of the system
S M B
1
T
0 1 2 3 4 5
Fuzzification
(Input 1)
Rules Defuzzification
Fuzzification
(Input 2) T
H S M B
L M H
S L L M 1
S M B
1 M L M H
B M H H 0 15 30 45 60 75 90
H Output cases
1 2 3 4 5 Position
0
EECIE20-S4305 Intelligence Systems & Software Engineering: Fuzzy logic Slide 15
Programming the controller (Rules) – Example #1
S M B
1
0.5
T intersects with S at 0.2, and
0.2 T intersects with M at 0.5
T
0 1 2 3 4 5
S M B
1
0.5
Take the Max to draw
the function,
0.2
0.1 Position then apply
15 30 45 60 75 90 center of gravity
0
on the graph to find
46o the angle
EECIE20-S4305 Intelligence Systems & Software Engineering: Fuzzy logic Slide 18
Fuzzy Logic Controllers
v Do not need much detailed knowledge of the system
à What the controller should do is determined by the Linguistic rules
v If optimization tools are used like Genetic Algorithms, can get away without knowing much
of anything.
v The system does not need to be reduced or idealized to develop a working Fuzzy Logic
Controller
v The conditions when Fuzzy Controllers will work are much more robust because they can
account for more variability in the inputs.
◆ Image processing
◆ Decision-making
◆ Route-planning