HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
Fuzzy Logic
1. 1
Fundamentals of Fuzzy Logic
• Introduction
• Fuzzy Set and example
• Fuzzy Terminology
• Fuzzy Logic Control and case study of
Room Cooler
• Fuzzy Regions, Fuzzy Profiles and Fuzzy
Rules
• Fuzzification
• Defuzzifier
2. 2
Introduction
• Fuzzy systems, Neural networks and Genetic
Algorithms are a part of soft computing
technologies
• Assume that the problems to be solved belong
to a multidimensional input-output space or
search space; for example a two input and one
output space where the inputs and output are
related with nonlinear function
• The objective is to find the best input that
produces the required output
3. 3
Introduction contd..
• Fuzzy systems and Neural networks model
such complex nonlinearity by combining
multiple simple functions
• Neural networks use sigmoid or other simple
functions and synaptic weights
• Fuzzy systems use several rules and
membership functions
4. 4
Introduction to fuzzy logic
• Uncertainty is inherent in accessing
information from large amount of data;
for example words like near and slow in
sentences like” My house is near to the
office, “He drivels slowly”
• If we set slow as speeds <=20 and fast
otherwise, then is 20.1 is fast?
5. 5
Introduction to fuzzy logic contd..
• Fuzzy logic deals with techniques to capture
the essence of comprehension and embed it on
the system
• Thus using fuzzy logic a gradual transition
from slow to high speed is allowed
• Due to the comprehension, fuzzy logic
provides higher intelligence quotient to
machines
6. 6
Crisp sets and Fuzzy sets
Crisp sets: In a crisp set, members belong to the group
identified by the set or not
slow = {s such that 0 <= s <= 40}
fast = {s such that 40 < s <70}
40.1 belongs to set fast, hence 40.1 is not slow
Drawback of crisp sets: Suppose a physical system has
to apply brakes if the speed of the vehicle is fast and
release the brake if the speed is slow. If the speed is
in the interval [39, 41], such a system would
continuously keep jerking which is not desired
7. 7
Fuzzy Sets
• To reduce the complexity of
comprehension, vagueness is introduced
in crisp sets
• Fuzzy set contains elements; each
element signifies the degree or grade of
membership to a fuzzy aspect
• Membership values denote the sense of
belonging of a member of a crisp set to a
fuzzy set
8. 8
Example of a fuzzy set
• Consider a crisp set A with elements representing
ages of a set of people in years
• A = { 2, 4, 10, 15, 20, 30, 35, 40, 45, 60, 70}
• Classify the age in terms of six fuzzy variables or
names given to fuzzy sets as: infant, child, adolescent,
adult, young and old
• Membership is different from probabilities
• Memberships do not necessarily add up to one
10. Explanation of Example
• How to categorize a person with age 30?
• A person with age 40 is old?
• The table 1. shows the fuzzy sets namely ages,
infant, child, adolescent, adult, young and old
• The values in the table indicate the memberships to
the fuzzy sets
• For example, consider the fuzzy set child.
• A child with age 4 belongs to the fuzzy set child with
0.5 membership value and a child with age 10 is
100% member
10
11. Explanation of Example contd..
• As per the table 1. a person with age 30 is 60%
young and 100% adult
• A person with age 40 is 40% young and 100%
adult
• A person with age 60 is 100% adult and 80%
old
11
12. 12
Features of Fuzzy Sets
1. A complex nonlinear input-output relation is
represented as a combination of simple input-output
relations
2. The simple input-output relation is described in
each rule
3. The system output from one rule area to the next
rule area gradually changes
4. Fuzzy logic systems are augmented with techniques
that facilitate learning and adaptation to the
environment; thus logic and fuzziness are separate
in fuzzy systems
13. 13
Features of Fuzzy Sets contd..
• In Conventional two value logic based systems
logic and fuzziness are not different
• fuzzy logic systems modify rules when logic is
to be changed and change membership
functions when fuzziness is to be changed
14. Some Fuzzy Terminology
• Universe of Discourse (U): The range of all possible
values that comprise the input to the fuzzy system
• Fuzzy set: A set that has members with membership
(real) values in the interval [0,1]
• Membership function: It is the basis of a fuzzy set.
The membership function of the fuzzy set A is given
by µA: U [0,1]
14
15. Fuzzy Terminology contd..
• Support of a fuzzy set (Sf): The support S of a fuzzy
set f in a universal crisp set U is that set which
contains all elements of the set U that have a non-zero
membership value in f
the support of the fuzzy set adult S adult is given by
S adult= {21,30,35,40,45,60,70}
Depiction of a fuzzy set: A fuzzy set in a universal crisp
set U is written as
f =µ1/s1 + µ2/s2+…+ µn/sn wher µi is the membership, si
is the corresponding term in the support set ; + and / are only
user for representation purpose; fuzzy set OLD is depicted as
Old =0.1/21+0.3/30+0.35/35+0.4/40+0.6/45+0.8/60+1/70 15
16. Fuzzy Set Operations
• Union: The membership function of the union
of two fuzzy sets A and B is defined as the
maximum of the two individual membership
functions. It is equivalent to the Boolean OR
operation µ AUB = max( µA, µ B)
• Intersection: The membership function of the
Intersection of two fuzzy sets A and B is
defined as the minimum of the two individual
membership functions. It is equivalent to the
Boolean AND operation µ A^B = min(µA, µ B)
16
17. Fuzzy Set Operations contd..
Complement: The membership function of the
complement of a fuzzy set A is defined as the
negation of the specified membership function
It is equivalent to the Boolean NOT operation
µ Ac
= (1- µA)
17
18. Fuzzy Inference Processing
• There are three models for Fuzzy processing
based on the expressions of consequent parts
in fuzzy rules
Suppose xi are inputs and y is the consequents
in fuzzy rules
1.Mamdani Model: y = A
where A is a fuzzy number to reflect fuzziness
• Though it can be used in all types of systems,
the model is more suitable for knowledge
processing systems than control systems 18
19. Fuzzy Inference Processing contd..
2. TSK (Takagi-Sugano-Kang) model:
y = a0 + ai xi where ai are constantsƩ
The output is the weighted linear combination of input
variables (it can be expanded to nonlinear
combination of input variables)
Used in fuzzy control applications
3. Simplified fuzzy model: y = c
where c is a constant
Thus consequents are expressed by constant values
19
20. Applications of Fuzzy Logic
• Fuzzy logic has been used in many
applications including
- Domestic appliances like washing machines
and cameras
-Sophisticated applications such as turbine
control, data classifiers etc.
- Intelligent systems that use fuzzy logic
employ techniques for learning and adaptation
to the environment
20
21. Case Study: Controlling the speed of a motor in a room cooler
• Through this case study we can understand fuzzy
logic, defining fuzzy rules and fuzzy inference and
control mechanisms
• Mamdani style of inference processing is used
• Problem: A room cooler has a fan encased in a box
with wool or hay. The wool is continuously
moistened by water that flows through a pump
connected to a motor. The rate of flow of water is to
be determined; it is a function of room temperature
and the speed of motor
• The speed of the motor is based on two parameters:
temperature and humidity; humidity is increased to reduce
temperature 21
22. Case Study: Operation of a room cooler contd..
• Two input variables –room temperature and cooler
fan speed control the output variable – flow rate of
the water. The fuzzy regions using fuzzy terms for
input-output are defined as follows
Variable name Fuzzy terms
Temperature Cold, Cool, Moderate, Warm and Hot
Fan speed Slack, Low, Medium, Brisk, fast
((rotations per minute)
Flow rate of water Strong Negative (SN), Negative (N),
Low-Negative (LN), Medium (M), Low-Positive
(LP), Positive (P), and High-Positive (HP)
22
23. Case Study: Operation of a room cooler contd..
• Fuzzy profiles are defined for each of the three parameters by
assigning memberships to their respective values
• The profiles have to be carefully designed after studying the
nature and desired behavior of the system
23
1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49
Temperature
Degree of
membership
Cold Cool Moderate Warm
Fig.1. Fuzzy relationships for the inputs
Temperature
1.2
1
0.8
0.6
0.4
0.2
0
Hot
24. Case Study: Operation of a room cooler contd..
Figure 2. Fuzzy relationships for the inputs Fan Motor speed
24
1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49
Motor speed RPM
Degree of
membership
Slack Low Medium Brisk Fast
1.2
1
0.8
0.6
0.4
0.2
0
Slack Low Medium Brisk Fast
25. Case Study: Operation of a room cooler contd..
Figure 3. Fuzzy relationships for the outputs Water Flow Rate
25
0 0.2 0.4 0.6 0.8 1 1.2 14 1.6
Flow rate (ml/Sec)
Degree of
membership
SN N LN M LP P HP
1.2
1
0.8
0.6
0.4
0.2
0
26. Fuzzy Rules for fuzzy room cooler
• The fuzzy rules form the triggers of the fuzzy engine
• After a study of the system, the rules could be written as
follows
R1: If temperature is HOT and fan motor speed is
SLACK then the flow-rate is HIGH-POSITIVE
R2: If temperature is HOT and fan motor speed is LOW
then the flow-rate is HIGH-POSITIVE
R3: If temperature is HOT and fan motor speed is
MEDIUM then the flow-rate is POSITIVE
R4: If temperature is HOT and fan motor speed is
BRISK then the flow-rate is HIGH-POSITIVE
27. Fuzzy Rules for fuzzy room cooler contd..
• R5: If temperature is WARM and fan motor speed is
MEDIUM then the flow-rate is LOW-POSITIVE
• R6: If temperature is WARM and fan motor speed is
BRISK then the flow-rate is POSITIVE
• R7: If temperature is COOL and fan motor speed is
LOW then the flow-rate is NEGATIVE
• R8: If temperature is MODERATE and fan motor
speed is LOW then the flow-rate is MEDIUM 27
28. Fuzzification
• The fuzzifier that performs the mapping of the
membership values of the input parameters
temperature and fan speed to the respective
fuzzy regions is known as fuzzification. This is
the most important step in fuzzy systems
• Suppose that at some time t, the temperature is
42 degrees and fan speed is 31 rpm. The
corresponding membership values and the
fuzzy regions are shown in Table 2
28
29. Example of fuzzification
• From Figure 1., the temperature 42 degrees
correspond to two membership values 0.142 and 0.2
that belong to WARM and HOT fuzzy regions
respectively
• Similarly From Figure 2., the fan speed 31 rpm
corresponds to two membership values 0.25 and
0.286 that belong to MEDIUM and BRISK fuzzy
regions respectively Table 2
29
Parameters Fuzzy Regions Memberships
Temperature Warm, hot 0.142, 0.2
Fan Speed medium, brisk 0.25, 0.286
30. Example of fuzzification contd..
• From Table 2, there are four combinations possible
• If temperature is WARM and fan speed is MEDIUM
• If temperature is WARM and fan speed is BRISK
• If temperature is HOT and fan speed is MEDIUM
• If temperature is HOT and fan speed is BRISK
• Comparing the above combinations with the left side
of fuzzy rules R5, R6, R3, and R4 respectively, the
flow-rate should be LOW-POSITIVE, POSITIVE,
POSITIVE and HIGH-POSITIVE
• The conflict should be resolved and the fuzzy region is to be
given as a value for the parameter water flow-rate
30
31. Defuzzification
• The fuzzy outputs LOW-POSITIVE, POSITIVE, and HIGH-
POSITIVE are to be converted to a single crisp value that is
provided to the fuzzy cooler system; this process is called
defuzzification
• Several methods are used for defuzzification
• The most common methods are
1. The centre of gravity method and
2. The Composite Maxima method
The centroid, of a two-dimensional shape X is the intersection of all
straight lines that divide X into two parts of equal moment about the line
or the average of all points of X. (Moment is a quantitative measure of
the shape of a set of points.)
In both these methods the composite region formed by the
portions A, B, C, and D (corresponding to rules R3, R4, R5
and R6 respectively) on the output profile is to be computed31
36. Defuzzification contd..
36
Temperature 42 D Centigrade Motor speed (RPM) 31
1.2
1
0.8
0.6
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
P
Flow rate (ml/Sec)
LP
HP
Centroid
A B is within C as it is
a subset of the
region C
D
Figure 8When parameters are connected by AND
the minimum of their memberships is taken
The area C is the region formed by the
application of rule R3 as shown in Figure 4.3
The area D is the region formed by the
application of rule R4 as shown in Figure 5.3
The area A is the region formed by the
application of rule R5 as shown in Figure 6.3
The area B is the region formed by the
application of rule R6 as shown in Figure 7.3
The composite region formed by the portions
A, B, C and D on the output profile is shown
in Figure 8.
The centre of gravity of this composite
region is the crisp output or the desired flow
rate value
37. Steps in Fuzzy logic based system
• Formulating fuzzy regions
• Fuzzy rules
• Embedding a Defuzzification procedure
In Defuzzification procedure, depending on the
application, either the centre of gravity or the
composite maxima is found to obtain the crisp output