Soft Computing Techniques - Material
Soft Computing Techniques - Material
Soft Computing Techniques - Material
1
INTRODUCTION TO SOFT COMPUTING
• Concept of computation
• Hard computing
• Soft computing
• How soft computing?
• Hard computing vs. Soft computing
• Hybrid computing
Debasis Samanta
CSE
2
IIT Kharagpur
CONCEPT OF COMPUTATION
Control Action
Figure: Basic of computing
𝑦 = 𝑓 𝑥 , 𝑓 is a mapping function.
𝑓 is also called a formal method or an algorithm to solve a problem.
Debasis Samanta
CSE
3
IIT Kharagpur
Important characteristics of computing
Debasis Samanta
CSE
4
IIT Kharagpur
Hard computing
Debasis Samanta
CSE
5
IIT Kharagpur
Examples of hard computing
• Solving numerical problems (e.g., roots of polynomials,
integration, etc.).
• Searching and sorting techniques.
• Solving computational geometry problems (e.g., shortest
tour in a graph, finding closet pair of points given a set of
points, etc.).
• many more…
Debasis Samanta
CSE
6
IIT Kharagpur
Soft computing
• The term soft computing was proposed by the inventor of
fuzzy logic, Lotfi A. Zadeh. He describes it as follows.
Definition 1: Soft computing
Soft computing is a collection of methodologies that aim to exploit the
tolerance for imprecision and uncertainty to achieve tractability, robustness,
and low solution cost. Its principal constituents are fuzzy logic, neuro-
computing, and probabilistic reasoning. The role model for soft computing is
the human mind.
Debasis Samanta
CSE
7
IIT Kharagpur
Characteristics of soft computing
• It does not require any mathematical modeling of problem solving.
• It may not yield the precise solution.
Debasis Samanta
CSE
8
IIT Kharagpur
Examples of soft computing
Soft
computing
⋮
Debasis Samanta
CSE
9
IIT Kharagpur
Examples of soft computing
Debasis Samanta
CSE
11
IIT Kharagpur
How soft computing?
• How a student learns from his teacher?
• Teacher asks questions and tell the answers then.
• Teacher puts questions and hints answers and asks whether the
answers are correct or not.
• Student thus learn a topic and store in his memory.
• Based on the knowledge he solves new problems.
• This is the way how human brain works.
• Based on this concept Artificial Neural Network is used to solve problems.
Debasis Samanta
CSE
12
IIT Kharagpur
How soft computing?
• How world selects the best?
• It starts with a population (random).
• Reproduces another population (next generation).
• Rank the population and selects the superior individuals.
• Genetic algorithm is based on this natural phenomena.
• Population is synonymous to solutions.
• Selection of superior solution is synonymous to exploring the optimal
solution.
Debasis Samanta
CSE
13
IIT Kharagpur
How soft computing?
• How a doctor treats his patient?
• Doctor asks the patient about suffering.
• Doctor find the symptoms of diseases.
• Doctor prescribed tests and medicines.
• This is exactly the way Fuzzy Logic works.
• Symptoms are correlated with diseases with uncertainty .
• Doctor prescribes tests/medicines fuzzily.
Debasis Samanta
CSE
14
IIT Kharagpur
Hard computing vs. Soft computing
Hard computing Soft computing
It requires a precisely stated It is tolerant of imprecision,
analytical model and often a lot of uncertainty, partial truth, and
computation time. approximation.
It is based on binary logic, crisp
It is based on fuzzy logic, neural
systems, numerical analysis and
nets and probabilistic reasoning.
crisp software.
It has the characteristics of precision It has the characteristics of
and categoricity. approximation and dispositionality.
Debasis Samanta
CSE
15
IIT Kharagpur
Hard computing vs. Soft computing
Debasis Samanta
CSE
16
IIT Kharagpur
Hybrid computing
• It is a combination of the conventional hard computing and
emerging soft computing.
HC SC
Hybrid computing
Debasis Samanta
CSE
17
IIT Kharagpur
In this course…
• You will be able to learn
• Basic concepts of Fuzzy algebra and then how to solve problems using
Fuzzy logic.
• How to build an artificial neural network and train it with input data to
solve a number of problems, which are not possible to solve with hard
computing.
Debasis Samanta
CSE
18
IIT Kharagpur
Debasis Samanta
CSE
19
IIT Kharagpur
Soft Computing
Introduction to Fuzzy Logic
1
What is Fuzzy logic?
• Fuzzy logic is a mathematical language to express something.
• This means it has grammar, syntax, semantic like a language for
communication.
• There are some other mathematical languages also known
• Relational algebra (operations on sets)
• Boolean algebra (operations on Boolean variables)
• Predicate algebra (operations on well formed formulae (wff), also called predicate
propositions)
• Fuzzy logic deals with Fuzzy set or Fuzzy algebra.
Debasis Samanta
CSE
IIT KHARAGPUR 2
What is fuzzy?
Debasis Samanta
CSE
IIT KHARAGPUR 3
Example : Fuzzy logic vs. Crisp logic
Yes or No
Crisp answer
True or False
· Milk Yes
· Water
A liquid Crisp
· Coca
No
· Sprite
Is the liquid
colorless?
Debasis Samanta
CSE
IIT KHARAGPUR 4
Example : Fuzzy logic vs. Crisp logic
May be
May not be
Partially
etc.
Debasis Samanta
CSE
IIT KHARAGPUR 5
Example : Fuzzy logic vs. Crisp logic
Score
99
Extremely honest
· Ankit
· Rajesh
Very honest 75
· Santosh
Fuzzy
· Kabita Honest at times 55
· Salmon
Extremely dishonest 35
Is the person
honest?
Debasis Samanta
CSE
IIT KHARAGPUR 6
World is fuzzy!
Debasis Samanta
CSE
IIT KHARAGPUR 7
Concept of fuzzy system
Fuzzy element(s)
Fuzzy sets
I
N
P Fuzzy rules
U
T
Fuzzy implications
(Inferences)
O
U
T
Fuzzy system P
U
T
Debasis Samanta
CSE
IIT KHARAGPUR 8
Concept of fuzzy set
To understand the concept of fuzzy set it is better, if we first clear our idea of
crisp set.
X = The entire population of India.
H = All Hindu population = {ℎ1 , ℎ2 , ℎ3 , … … , ℎ𝐿 , }
M = All Muslim population ={𝑚1 , 𝑚2 , 𝑚3 , … … , 𝑚𝑁 , }
Universe of discourse X
H
Here, All are the sets of finite numbers of individuals.
M
Such a set is called crisp set.
Debasis Samanta
CSE
IIT KHARAGPUR 9
Example of fuzzy set
Let us discuss about fuzzy set.
X = All students in NPTEL.
S = All Good students.
S = {(𝑠, 𝑔(𝑠)) | 𝑠 ∈ 𝑋 } and g(s) is a measurement of goodness of the
student s.
Example:
S = 𝑅𝑎𝑗𝑎𝑡, 0.8 , 𝐾𝑎𝑏𝑖𝑡𝑎, 0.7 , 𝑆𝑎𝑙𝑚𝑎𝑛, 0.1 , 𝐴𝑛𝑘𝑖𝑡, 0.9 , etc.
Debasis Samanta
CSE
IIT KHARAGPUR 10
Fuzzy set vs. Crisp set
Debasis Samanta
CSE
IIT KHARAGPUR 11
Fuzzy set vs. Crisp set
Note: A crisp set is a fuzzy set, but, a fuzzy set is not necessarily a crisp set.
Example:
H = (ℎ1 , 1 , (ℎ2 , 1) … … … , (ℎ𝐿 , 1)}
Person = (𝑝1 , 0 , (𝑝2 , 0) … … … , (𝑝𝑁 , 0)}
In case of a crisp set, the elements are with extreme values of degree of
membership namely either 1 or 0.
Debasis Samanta
CSE
IIT KHARAGPUR 12
Degree of membership
How to decide the degree of memberships of elements in a fuzzy set?
Debasis Samanta
CSE
IIT KHARAGPUR 13
Example: Course evaluation in a crisp way
𝐸𝑋 ∶ Marks ≥ 90
𝐴 ∶ 80 ≤ Marks < 90
𝐵 ∶ 70 ≤ Marks < 80
𝐶 ∶ 60 ≤ Marks < 70
𝐷 ∶ 50 ≤ Marks < 60
𝑃 ∶ 35 ≤ Marks < 50
𝐹 ∶ Marks ≤ 35
Debasis Samanta
CSE
IIT KHARAGPUR 14
Example: Course evaluation in a crisp way
F P D C B A EX
1
0
35 50 60 70 80 90 100
Debasis Samanta
CSE
IIT KHARAGPUR 15
Example: Course evaluation in a fuzzy way
F P D C B A EX
1
0
35 50 60 70 80 90 100
Debasis Samanta
CSE
IIT KHARAGPUR 16
Few examples of fuzzy set
• High Temperature
• Low Pressure
• Colour of Apple
• Sweetness of Orange
• Weight of Mango
Debasis Samanta
CSE
IIT KHARAGPUR 17
Some basic terminologies and notations
Definition 1: Membership function (and Fuzzy set)
If 𝑋 is a universe of discourse and 𝑥 ∈ 𝑋, then a fuzzy set A in 𝑋 is
defined as a set of ordered pairs, that is
A = {(𝑥, 𝜇𝐴 𝑥 )|𝑥 ∈ 𝑋} where 𝜇𝐴 𝑥 is called the membership function
for the fuzzy set A.
Debasis Samanta
CSE
IIT KHARAGPUR 18
Some basic terminologies and notations
Example:
X = All cities in India
A = City of comfort
A={(New Delhi, 0.7), (Bangalore, 0.9), (Chennai, 0.8), (Hyderabad, 0.6),
(Kolkata, 0.3), (Kharagpur, 0)}
Debasis Samanta
CSE
IIT KHARAGPUR 19
Membership function with discrete membership
values
The membership
values may be of
discrete values.
µA(x)
x
A fuzzy set with discrete values of
Debasis Samanta
CSE
IIT KHARAGPUR 20
Membership function with discrete membership
values
Either elements or their membership values (or both) also may be of discrete values.
A ={(0,0.1),(1,0.30),(2,0.78)……(10,0.1)}
1.0
***
0.8
0.6 Note : X = discrete value
µ
0.4 *
0.2 * ****
*0 2 4 6 8
*
10
How you measure happiness ??
A = “Happy family”
Debasis Samanta
CSE
IIT KHARAGPUR 21
Membership function with continuous membership
values
1.0
B ( x) 1
4
0.8 x 50
1
0.6 10
µ
0.4
0.2
0 50 100
B={(x,µB(x))}
Age (X)
Note : x = real value
B = “Middle aged” = R+
Debasis Samanta
CSE
IIT KHARAGPUR 22
Fuzzy terminologies: Support
Support: The support of a fuzzy set A is the set of all points 𝑥 ∈ 𝑋 such that 𝜇𝐴 (𝑋) > 0
support
x
Debasis Samanta
CSE
IIT KHARAGPUR 23
Fuzzy terminologies: Core
Core: The core of a fuzzy set A is the set of all points 𝑥 in 𝑋 such that 𝜇𝐴 𝑋 = 1
1.0
µ
0.5
Debasis Samanta
CSE
IIT KHARAGPUR 24
Fuzzy terminologies: Normality
Normality : A fuzzy set A is a normal if its core is non-empty. In other words, we can
always find a point 𝑥 ∈ 𝑋 such that 𝜇𝐴 (𝑋) = 1
Debasis Samanta
CSE
IIT KHARAGPUR 25
Fuzzy terminologies: Crossover points
Crossover point : A crossover point of a fuzzy set A is a point 𝑥 ∈ 𝑋 at which 𝜇𝐴 (𝑋) =
0.5. That is Crossover (A) ={𝑥|𝜇𝐴 𝑥 = 0.5}
µ 1.0
0.5
Crossover point
x
Debasis Samanta
CSE
IIT KHARAGPUR 26
Fuzzy terminologies: Fuzzy Singleton
Fuzzy Singleton : A fuzzy set whose support is a single point in 𝑋 with 𝜇𝐴 (𝑥) = 1 is
called a fuzzy singleton. That is |𝐴| = {𝑥|𝜇𝐴 𝑥 = 1}
singleton
1.0
*
* *
µ
0.5
*
* * * * *
core
x
Debasis Samanta
CSE
IIT KHARAGPUR 27
Fuzzy terminologies: 𝜶-cut and strong 𝜶-cut
Debasis Samanta
CSE
IIT KHARAGPUR 28
Fuzzy terminologies: Bandwidth
Bandwidth :
For a fuzzy set, the bandwidth (or width) is defined as the distance between the two
unique crossover points:
Bandwidth 𝐴 = |𝑥1 − 𝑥2 |
where 𝜇𝐴 𝑥1 = 𝜇𝐴 𝑥2 = 0.5
Debasis Samanta
CSE
IIT KHARAGPUR 29
Fuzzy terminologies: Symmetry
Symmetry :
A fuzzy set A is symmetric if its membership function around a certain point 𝑥 = 𝑐,
namely 𝜇𝐴 𝑥 + 𝑐 = 𝜇𝐴 𝑥 − 𝑐 for all 𝑥 ∈ 𝑋
1.0
µ
x=c
x
Debasis Samanta
CSE
IIT KHARAGPUR 30
Fuzzy terminologies: Open and Closed
A fuzzy set A is
Open left : If lim 𝑥 → −∞ 𝜇𝐴 𝑥 = 1and lim 𝑥 → +∞ 𝜇𝐴 𝑥 = 0
Open right: If lim 𝑥 → −∞ 𝜇𝐴 𝑥 = 0and lim 𝑥 → +∞ 𝜇𝐴 𝑥 = 1
Closed: If lim 𝑥 → −∞ 𝜇𝐴 𝑥 = lim 𝑥 → +∞ 𝜇𝐴 𝑥 = 0
Debasis Samanta
CSE
IIT KHARAGPUR 31
Fuzzy vs. Probability
Fuzzy : When we say about certainty of a thing
Example: A patient come to the doctor and he has to diagnose so that
medicine can be prescribed.
Doctor prescribed a medicine with certainty 60% that the
patient is suffering from flue. So, the disease will be cured with
certainty of 60% and uncertainty 40%. Here, in stead of flue,
other diseases with some other certainties may be.
Debasis Samanta
CSE
IIT KHARAGPUR 32
Prediction vs. Forecasting
The Fuzzy vs. Probability is analogical to Prediction vs. Forecasting
Prediction : When you start guessing about things.
Forecasting : When you take the information from the past job and apply it to new job.
Debasis Samanta
CSE
IIT KHARAGPUR 33
34
Introduction to Soft Computing
Fuzzy membership functions
1
Fuzzy membership functions
A fuzzy set is completely characterized by its membership function (sometimes
abbreviated as 𝑀𝐹 and denoted as 𝜇 ). So, it would be important to learn how a
membership function can be expressed (mathematically or otherwise).
Example:
Note: A membership function can
be on 1.0 1.0
µA
µB
0.6 0.6
b) a continuous universe of
Number of children (X) Age (X)
discourse.
A = Fuzzy set of “Happy family” B = “Young age”
Debasis Samanta
CSE
2
IIT Kharagpur
Fuzzy membership functions
So, membership function on a discrete universe of course is trivial. However, a
membership function on a continuous universe of discourse needs a special attention.
µ
µ
µ
Following figures shows x x x
typical examples of < triangular > < trapezoidal > < curve >
membership functions.
µ
x x
< non-uniform > < non-uniform >
Debasis Samanta
CSE
3
IIT Kharagpur
Fuzzy MFs : Formulation and parameterization
In the following, we try to parameterize the different MFs on a continuous universe of
discourse.
Triangular MFs : A triangular MF is specified by three parameters {𝑎, 𝑏, 𝑐} and can be
formulated as follows.
0 𝑖𝑓 𝑥 ≤ 𝑎
𝑥−𝑎
1.0 𝑖𝑓 𝑎 ≤ 𝑥 ≤ 𝑏
𝑎 − 𝑏
triangle 𝑥; 𝑎, 𝑏, 𝑐 = 𝑐 − 𝑥
𝑖𝑓 𝑏 ≤ 𝑥 ≤ 𝑐
𝑐−𝑏
0 𝑖𝑓 𝑐 ≤ 𝑥
a b c
Debasis Samanta
CSE
4
IIT Kharagpur
Fuzzy MFs: Trapezoidal
A trapezoidal MF is specified by four parameters {𝑎, 𝑏, 𝑐, 𝑑} and can be defined as
follows:
0 𝑖𝑓 𝑥 ≤ 𝑎
𝑥−𝑎
𝑖𝑓 𝑎 ≤ 𝑥 ≤ 𝑏
𝑏−𝑎
trapozoid 𝑥; 𝑎, 𝑏, 𝑐, 𝑑 = 1 𝑖𝑓 𝑏 ≤ 𝑥 ≤ 𝑐
1.0 𝑑−𝑥
𝑖𝑓 𝑐 ≤ 𝑥 ≤ 𝑑
𝑑−𝑐
0 𝑖𝑓 𝑑 ≤ 𝑥
a b c d
Debasis Samanta
CSE
5
IIT Kharagpur
Fuzzy MFs: Gaussian
A Gaussian MF is specified by two parameters 𝑐, 𝜎 and can be defined as below:
1 𝑥−𝑐 2
−2 𝜎
𝑔𝑎𝑢𝑠𝑠𝑖𝑎𝑛 𝑥; 𝑐, 𝜎 = 𝑒
c
0.1
0.1c 0.9c
Debasis Samanta
CSE
6
IIT Kharagpur
Fuzzy MFs: Generalized bell
It is also called Cauchy MF. A generalized bell MF is specified by three parameters
{𝑎, 𝑏, 𝑐} and is defined as:
1
𝑏𝑒𝑙𝑙(𝑥; 𝑎, 𝑏, 𝑐) =
𝑥 − 𝑐 2𝑏
1+ 𝑎
b
Slope at x =
2a
b
Slope at y =
x b y
2a
c-a c c+a
Debasis Samanta
CSE
7
IIT Kharagpur
Example: Generalized bell MFs
1
Example: 𝜇 𝑥 = 1+ 𝑥 2;
a = b = 1 and c = 0;
1.0
-1 0 1
Debasis Samanta
CSE
8
IIT Kharagpur
Generalized bell MFs: Different shapes
Changing a Changing b
Changing a
Changing a and b
Debasis Samanta
CSE
9
IIT Kharagpur
Fuzzy MFs: Sigmoidal MFs
Parameters: {𝑎, 𝑐} ; where 𝑐 = crossover point and 𝑎 = slope at 𝑐;
1.0
1
𝑆𝑖𝑔𝑚𝑜𝑖𝑑(𝑥; 𝑎, 𝑐) = 𝑥−𝑐
− 𝑎
Slope = a 1+ 𝑒
0.5
Debasis Samanta
CSE
10
IIT Kharagpur
Fuzzy MFs : Example
Example : Consider the following grading system for a course.
Excellent = Marks ≤ 90
Very good = 75 ≤ Marks ≤ 90
Good = 60 ≤ Marks ≤ 75
Average = 50 ≤ Marks ≤ 60
Poor = 35 ≤ Marks ≤ 50
Bad= Marks ≤ 35
Debasis Samanta
CSE
11
IIT Kharagpur
Grading System
A fuzzy implementation will look like the following.
Bad poor Average Good Very Good Excellent
1
.8
.6
.4
.2
0
10 20 30 40 50 60 70 80 90
marks
You can decide a standard fuzzy MF for each of the fuzzy grade.
Debasis Samanta
CSE
12
IIT Kharagpur
Few More on Membership Functions
Debasis Samanta
CSE
13
IIT Kharagpur
Generation of MFs
Given a membership function of a fuzzy set representing a linguistic hedge, we can derive
many more MFs representing several other linguistic hedges using the concept of
Concentration and Dilation.
1. Concentration: 𝐴𝑘 = [𝜇𝐴 𝑥 ]𝑘 ; 𝑘 > 1
2. Dilation: 𝐴𝑘 = [𝜇𝐴 𝑥 ]𝑘 ; 𝑘 < 1
Example : Age = { Young, Middle-aged, Old }
Thus, corresponding to Young, we have : Not young, Very young, Not very young and so on.
Similarly, with Old we can have : Not old, Very old, Very very old, Extremely old, etc.
Thus, 𝜇𝐸𝑥𝑡𝑟𝑒𝑚𝑒𝑙𝑦 𝑜𝑙𝑑 𝑥 = (((𝜇𝑂𝑙𝑑 𝑥 )2 )2 )2 and so on
Or, 𝜇𝑀𝑜𝑟𝑒 𝑜𝑟 𝑙𝑒𝑠𝑠 𝑜𝑙𝑑 𝑥 = 𝐴0.5 = (𝜇𝑂𝑙𝑑 𝑥 )0.5
Debasis Samanta
CSE
14
IIT Kharagpur
Linguistic variables and values
1
𝜇𝑦𝑜𝑢𝑛𝑔 𝑥 =bell(x,20,2,0) = 𝑥
1+( )4
20
Young Old
Middle-Aged
1
𝜇𝑜𝑙𝑑 𝑥 =bell(x,30,3,100) = 𝑥−100
1+( 30 )6 Very Old
𝜇𝑚𝑖𝑑𝑑𝑙𝑒−𝑎𝑔𝑒𝑑 𝑥 =bell(x,30,60,50)
Debasis Samanta
CSE
15
IIT Kharagpur
Debasis Samanta
CSE
16
IIT Kharagpur
Introduction to Soft Computing
Operations on Fuzzy sets
1
Basic fuzzy set operations: Union
Union (A ∪ B): 𝜇𝐴∪𝐵 𝑥 = max(𝜇𝐴 𝑥 , 𝜇𝐵 𝑥 )
Example:
𝐴 = {(𝑥1, 0.5), (𝑥2, 0.1), (𝑥3, 0.4)} and
𝐵 = { 𝑥1, 0.2 , 𝑥2, 0.3 , 𝑥3, 0.5 };
𝐶 = 𝐴 ∪ 𝐵 = { 𝑥1, 0.5 , 𝑥2, 0.3 , 𝑥3, 0.5 }
µA µA
µB µB
µ
µAUB
a p x b q c a p x b q c
Debasis Samanta
CSE
2
IIT Kharagpur
Basic fuzzy set operations: Intersection
Intersection (A ∩ B): 𝜇𝐴∩𝐵 𝑥 = min(𝜇𝐴 𝑥 , 𝜇𝐵 𝑥 )
Example:
𝐴 = {(𝑥1, 0.5), (𝑥2, 0.1), (𝑥3, 0.4)} and
𝐵 = { 𝑥1, 0.2 , 𝑥2, 0.3 , 𝑥3, 0.5 };
𝐶 = 𝐴 ∩ 𝐵 = { 𝑥1, 0.2 , 𝑥2, 0.1 , 𝑥3, 0.4 }
µA
µB
µA?B
µ
a p x b q c a p x b q c
Debasis Samanta
CSE
3
IIT Kharagpur
Basic fuzzy set operations: Complement
Complement (𝐴𝑐 ): 𝜇𝐴𝑐 𝑥 = 1 − 𝜇𝐴 𝑥
Example:
𝐴 = {(𝑥1, 0.5), (𝑥2, 0.1), (𝑥3, 0.4)}
𝐶 = 𝐴𝑐 = { 𝑥1, 0.5 , 𝑥2, 0.9 , 𝑥3, 0.6 }
µA µA
1.0 µA’
p x q p x q
Debasis Samanta
CSE
4
IIT Kharagpur
Basic fuzzy set operations: Products
𝜇𝐴∙𝐵 𝑥 = 𝜇𝐴 𝑥 ∙ 𝜇𝐵 𝑥
𝜇𝛼𝐴 𝑥 = 𝛼 × 𝜇𝐴 𝑥
Debasis Samanta
CSE
5
IIT Kharagpur
Basic fuzzy set operations: Sum and Difference
Sum (A + B):
𝜇𝐴+𝐵 𝑥 = 𝜇𝐴 𝑥 + 𝜇𝐵 𝑥 − 𝜇𝐴 𝑥 . 𝜇𝐵 𝑥
Difference (𝐴 − 𝐵 = 𝐴 ∩ 𝐵𝐶 ) :
𝜇𝐴−𝐵 𝑥 = 𝜇𝐴∩𝐵𝐶 𝑥
Disjunctive sum:
𝐴⨁𝐵 = (𝐴𝐶 ∩ 𝐵) ∪ (𝐴 ∩ 𝐵𝐶 )
Bounded Sum:
| 𝐴 𝑥 ⨁𝐵 𝑥 |= 𝜇|𝐴(𝑥)⨁𝐵(𝑥)| = min{1, 𝜇𝐴 𝑥 + 𝜇𝐵 𝑥 }
Bounded Difference:
𝐴 𝑥 ⊖𝐵 𝑥 = 𝜇|𝐴(𝑥)⊖𝐵(𝑥)| = max{0, 𝜇𝐴 𝑥 + 𝜇𝐵 𝑥 − 1}
Debasis Samanta
CSE
6
IIT Kharagpur
Basic fuzzy set operations: Equality and Power
Equality (𝐴 = 𝐵):
𝜇𝐴 𝑥 = 𝜇𝐵 𝑥
Power of a fuzzy set 𝐴𝛼 :
𝜇𝐴𝛼 𝑥 = (𝜇𝐴 𝑥 )𝛼
Debasis Samanta
CSE
7
IIT Kharagpur
Basic fuzzy set operations: Cartesian product
Caretsian Product (𝐴 × 𝐵): 𝜇𝐴×𝐵 𝑥, 𝑦 = min(𝜇𝐴 𝑥 , 𝜇𝐵 𝑦 )
Example:
𝐴 𝑥 = {(𝑥1 , 0.2), (𝑥2 , 0.3), (𝑥3 , 0.5), (𝑥4 , 0.6)}
𝐵 𝑦 = { 𝑦1 , 0.8 , 𝑦2 , 0.6 , 𝑦3 , 0.3 }
A × 𝐵 = min 𝜇𝐴 𝑥 , 𝜇𝐵 𝑦 =
Debasis Samanta
CSE
8
IIT Kharagpur
Properties of fuzzy sets
Commutativity :
𝐴∩𝐵 = 𝐵∩𝐴
𝐴∪B = 𝐵∪A
Associativity :
𝐴 ∪ (𝐵 ∪ 𝐶) = (𝐴 ∪ 𝐵) ∪ 𝐶
𝐴 ∩ (𝐵 ∩ 𝐶) = (𝐴 ∩ 𝐵) ∩ 𝐶
Distributivity :
𝐴 ∪ (𝐵 ∩ 𝐶) = (𝐴 ∪ 𝐵) ∩ (𝐴 ∪ 𝐶)
𝐴 ∩ (𝐵 ∪ 𝐶) = (𝐴 ∩ 𝐵) ∪ (𝐴 ∩ 𝐶)
Debasis Samanta
CSE
9
IIT Kharagpur
Properties of fuzzy sets
Idempotence :
𝐴 ∪ 𝐴 = 𝐴
𝐴 ∩ 𝐴 =∅;
𝐴 ∪ ∅; = 𝐴
𝐴 ∩∅; = ∅;
Transitivity :
If 𝐴 ⊆ 𝐵; 𝐵 ⊆ 𝐶 then 𝐴 ⊆ 𝐶
Involution :
(𝐴𝑐 )𝑐 = 𝐴
De Morgan’s law :
(𝐴 ∩ 𝐵)𝑐 = 𝐴𝑐 ∪ 𝐵𝑐
(𝐴 ∪ 𝐵)𝑐 = 𝐴𝑐 ∩ 𝐵𝑐
Debasis Samanta
CSE
10
IIT Kharagpur
Example 1: Fuzzy Set Operations
Let A and B are two fuzzy sets defined over a universe of discourse X with
membership functions 𝜇𝐴 𝑥 and 𝜇𝐵 𝑥 , respectively. Two MFs 𝜇𝐴 𝑥 and
𝜇𝐵 𝑥 are shown graphically.
µA(x)
µB(x)
a1 a2 a3 a4 b1 a1=b2 a2=b3 a4
x x
Debasis Samanta
CSE
11
IIT Kharagpur
Example 1: Plotting two sets on the same graph
Let’s plot the two membership functions on the same graph
µB µA
µ
b1 a1 a2 b4 a3 a4
x
Debasis Samanta
CSE
12
IIT Kharagpur
Example 1: Union and Intersection
The plots of union 𝐴 ∪ 𝐵 and intersection 𝐴 ∩ 𝐵 are shown in the following.
µB µA
µ
b1 a1 a2 b4 a3 a4
x
A B ( x)
A B ( x)
a2 b4
x b1 a1 a2 a3 a4
x
Debasis Samanta
CSE
13
IIT Kharagpur
Example 1: Complementation
The plots of union 𝜇𝐴 𝑥 of the fuzzy set A is shown in the following.
Debasis Samanta
CSE
14
IIT Kharagpur
Fuzzy set operations: Practice
Consider the following two fuzzy sets A and B defined over a universe of
discourse [0,5] of real numbers with their membership functions
𝑥
𝜇𝐴 𝑥 = and 𝜇𝐵 𝑥 = 2−𝑥
1+𝑥
Determine the membership functions of the following and draw them
graphically.
I. 𝐴 , 𝐵
II. 𝐴 ∪ 𝐵
III. 𝐴 ∩ 𝐵
IV. (𝐴 ∪ 𝐵)𝑐
[Hint: Use De’ Morgan law]
Debasis Samanta
CSE
15
IIT Kharagpur
Example 2: A real-life example
Two fuzzy sets A and B with membership functions 𝜇𝐴 𝑥 and 𝜇𝐵 𝑥 , respectively
defined as below.
A = Cold climate with 𝜇𝐴 𝑥 as the MF.
B = Hot climate with 𝜇𝐵 𝑥 as the M.F.
µA µB
1.0
Debasis Samanta
CSE
16
IIT Kharagpur
Example 2: A real-life example
What are the fuzzy sets representing the following?
1. Not cold climate
2. Not hot climate
3. Extreme climate
4. Pleasant climate
Note: Note that ”Not cold climate” ≠ ”Hot climate” and vice-versa.
Debasis Samanta
CSE
17
IIT Kharagpur
Example 2: A real-life example
Answer would be the following.
Not cold climate
𝐴 with 1 − 𝜇𝐴 𝑥 as the MF.
Not hot climate
𝐵 with 1 − 𝜇𝐵 𝑥 as the MF.
Extreme climate
A ∪ 𝐵 with 𝜇𝐴∪𝐵 𝑥 = max(𝜇𝐴 𝑥 , 𝜇𝐵 𝑥 ) as the MF.
Pleasant climate
A ∩ 𝐵 with 𝜇𝐴∩𝐵 𝑥 = min(𝜇𝐴 𝑥 , 𝜇𝐵 𝑥 ) as the MF.
Debasis Samanta
CSE
18
IIT Kharagpur
Example 2: A real-life example
The plot of the MFs of A ∪ 𝐵 and A ∩ 𝐵 are shown in the following.
Debasis Samanta
CSE
19
IIT Kharagpur
Debasis Samanta
CSE
20
IIT Kharagpur
Soft Computing
Fuzzy Relations
1
Fuzzy Relations
• Crisp relations
• Operations on crisp relations
• Examples on crisp relations
• Fuzzy relations
• Operations on fuzzy relations
• Examples on fuzzy relations
Debasis Samanta
CSE
2
IIT Kharagpur
Crisp relations
• Order pairs:
Suppose, A and B are two (crisp) sets. Then Cartesian product denoted as
𝐴 × 𝐵 is a collection of order pairs, such that
𝐴 × 𝐵 = {(𝑎, 𝑏)|𝑎 ∈ 𝐴 𝑎𝑛𝑑 𝑏 ∈ 𝐵}
Note :
(1) 𝐴 × 𝐵 ≠ 𝐵 × 𝐴 (2) |𝐴 × 𝐵| = |𝐴| × |𝐵|
(3) 𝐴 × 𝐵 provides a mapping from 𝑎 ∈ 𝐴 to 𝑏 ∈ 𝐵.
Debasis Samanta
CSE
3
IIT Kharagpur
Crisp relations
Example:
Consider the two crisp sets 𝐴 and 𝐵 as given below.
𝐴 = {1, 2, 3, 4} 𝐵 = {3, 5, 7}.
Debasis Samanta
CSE
4
IIT Kharagpur
Crisp relations
We can represent the relation 𝑅 in a matrix form as follows.
Debasis Samanta
CSE
5
IIT Kharagpur
Operations on crisp relations
Suppose, 𝑅(𝑥, 𝑦) and 𝑆(𝑥, 𝑦) are the two relations defined over two crisp sets
𝑥 ∈ 𝐴 and 𝑦 ∈ 𝐵
• Complement: 𝑅 𝑥, 𝑦 = 1 − 𝑅(𝑥, 𝑦)
Debasis Samanta
CSE
6
IIT Kharagpur
Example: Operations on crisp relations
Suppose, 𝑅(𝑥, 𝑦) and 𝑆(𝑥, 𝑦) are the two relations defined over two crisp sets
𝑥 ∈ 𝐴 and 𝑦 ∈ 𝐵
0 1 0 0 1 0 0 0
0 0 1 0 0 1 0 0
𝑅= and 𝑆 =
0 0 0 1 0 0 1 0
0 0 0 0 0 0 0 1
Find the following
• 𝑅∪𝑆
• 𝑅∩𝑆
• 𝑅
Debasis Samanta
CSE
7
IIT Kharagpur
Composition of two crisp relations
Given 𝑅 is a relation on 𝑋, 𝑌 and 𝑆 is another relation on 𝑌, 𝑍. Then, 𝑅 ∘ 𝑆 is
called a composition of relation on 𝑋 and 𝑍 which is defined as follows.
𝑅 ∘ 𝑆 = { 𝑥, 𝑧 | 𝑥, 𝑦 ∈ 𝑅 𝑎𝑛𝑑 𝑦, 𝑧 ∈ 𝑆 𝑎𝑛𝑑 ∀𝑦 ∈ 𝑌}
Max-Min Composition
Given the two relation matrices 𝑅 and 𝑆, the max-min composition is defined as
𝑇 = 𝑅∘𝑆;
𝑇(𝑥, 𝑧) = 𝑚𝑎𝑥{𝑚𝑖𝑛{𝑅 𝑥, 𝑦 , 𝑆(𝑦, 𝑧) 𝑎𝑛𝑑 ∀𝑦 ∈ 𝑌}}
Debasis Samanta
CSE
8
IIT Kharagpur
Composition: Composition
Example : Given 𝑋 = 1, 3, 5 ; 𝑌 = 1, 3, 5 ; 𝑅 = 𝑥, 𝑦 𝑦 = 𝑥 + 2 ;
𝑆 = {(𝑥, 𝑦)|𝑥 < 𝑦}
Here, 𝑅 and 𝑆 is on 𝑋 × 𝑌.
Thus, we have 𝑅 = 1, 3 , 3, 5 , 𝑆 = { 1, 3 , 1, 5 , (3, 5)}
1 0 1 0 1 0 1 1
𝑅=3 0 0 1 𝑎𝑛𝑑 𝑆= 3 0 0 1
5 0 0 0 5 0 0 0
1 0 0 1
Using max-min composition 𝑅∘ 𝑆=3 0 0 0
5 0 0 0
Debasis Samanta
CSE
9
IIT Kharagpur
Fuzzy relations
• Fuzzy relation is a fuzzy set defined on the Cartesian product of crisp set
𝑋1, 𝑋2, … , 𝑋𝑛
• Here, n-tuples (𝑥1, 𝑥2, … , 𝑥𝑛) may have varying degree of memberships
within the relationship.
• The membership values indicate the strength of the relation between the
tuples.
Debasis Samanta
CSE
10
IIT Kharagpur
Fuzzy relations
Example:
𝑋 = 𝑡𝑦𝑝ℎ𝑜𝑖𝑑, 𝑣𝑖𝑟𝑎𝑙, 𝑐𝑜𝑙𝑑 , 𝑌 = { 𝑟𝑢𝑛𝑛𝑖𝑛𝑔 𝑛𝑜𝑠𝑒, ℎ𝑖𝑔ℎ 𝑡𝑒𝑚𝑝, 𝑠ℎ𝑖𝑣𝑒𝑟𝑖𝑛𝑔 }
The fuzzy relation 𝑅 is defined as
Debasis Samanta
CSE
11
IIT Kharagpur
Fuzzy Cartesian product
Suppose
• 𝐴 is a fuzzy set on the universe of discourse 𝑋 with 𝜇𝐴(𝑥)|𝑥 ∈ 𝑋
• 𝐵 is a fuzzy set on the universe of discourse 𝑌 with 𝜇𝐵(𝑦)|𝑦 ∈ 𝑌
Debasis Samanta
CSE
12
IIT Kharagpur
Fuzzy Cartesian product
Example :
𝐴 = {(𝑎1, 0.2), (𝑎2, 0.7), (𝑎3, 0.4)} and 𝐵 = {(𝑏1, 0.5), (𝑏2, 0.6)}
𝑎1 0.2 0.2
𝑅 = 𝐴 × 𝐵 = 𝑎2 0.5 0.6
𝑎3 0.4 0.4
Debasis Samanta
CSE
13
IIT Kharagpur
Operations on Fuzzy relations
Let 𝑅 and 𝑆 be two fuzzy relations on 𝐴 × 𝐵.
• Union: 𝜇𝑅U𝑆(𝑎, 𝑏) = 𝑚𝑎𝑥{𝜇𝑅 𝑎, 𝑏 , 𝜇𝑆(𝑎, 𝑏)}
• Intersection: 𝜇𝑅∩𝑆 (𝑎, 𝑏) = 𝑚𝑖𝑛{𝜇𝑅 𝑎, 𝑏 , 𝜇𝑆(𝑎, 𝑏)}
• Complement: 𝜇𝑅 𝑎, 𝑏 = 1 − 𝜇𝑅 (𝑎, 𝑏)
• Composition: 𝑇 = 𝑅∘𝑆
Debasis Samanta
CSE
14
IIT Kharagpur
Operations on Fuzzy relations: Example
Example : 𝑋 = (𝑥1 , 𝑥2 , 𝑥3 ), 𝑌 = 𝑦1 , 𝑦2 , 𝑍 = 𝑧1 , 𝑧2 , 𝑧3 ,
Debasis Samanta
CSE
15
IIT Kharagpur
Fuzzy relation : An example
Consider the following two sets 𝑃 and 𝐷, which represent a set of paddy plants and a set
of plant diseases. More precisely
𝑃 = {𝑃1 , 𝑃2 , 𝑃3 , 𝑃4 } a set of four varieties of paddy plants
𝐷 = {𝐷1 , 𝐷2 , 𝐷3 , 𝐷4 } of the four various diseases affecting the plants.
In addition to these, also consider another set 𝑆 = {𝑆1 , 𝑆2 , 𝑆3 , 𝑆4 } be the common
symptoms of the diseases.
Let, 𝑅 be a relation on 𝑃 × 𝐷, representing which plant is susceptible to which diseases,
which is stated as
Obtain the association of plants with the different symptoms of the disease using
max-min composition.
Hint: Find 𝑅 ∘ 𝑇, and verify that
𝑃1 0.8 0.8 0.8 0.9
𝑃 0.8 0.8 0.8 0.9
𝑅∘𝑆 = 2
𝑃3 0.8 0.8 0.8 0.9
𝑃4 0.8 0.8 0.7 0.9
Debasis Samanta
CSE
17
IIT Kharagpur
Fuzzy relation : Another example
Let, 𝑅 = 𝑥 is relevant to 𝑦
and 𝑆 = 𝑦 is relevant to 𝑧
be two fuzzy relations defined on 𝑋 × 𝑌 and 𝑌 × 𝑍, respectively, where 𝑋 =
{1,2,3}, 𝑌 = {𝛼, 𝛽, 𝛾, 𝛿} and 𝑍 = {𝑎, 𝑏}. Assume that 𝑅 and 𝑆 can be
expressed with the following relation matrices :
𝛼 0.9 0.1
1 0.1 0.3 0.5 0.7
𝛽 0.2 0.3
𝑅 = 2 0.4 0.2 0.8 0.9 𝑎𝑛𝑑 𝑆 = 𝛾
0.5 0.6
3 0.6 0.8 0.3 0.2 𝛿 0.7 0.2
Debasis Samanta
CSE
18
IIT Kharagpur
Fuzzy relation : Another example
Now, we want to find 𝑅 ∘ 𝑆, which can be interpreted as a derived fuzzy relation
𝑥 is relevant to 𝑧.
Suppose, we are only interested in the degree of relevance between 2 ∈ 𝑋 and
𝑎 ∈ 𝑍. Then, using max-min composition,
𝜇𝑅∘𝑆 (2, 𝑎) = max{ 0.4 ∧ 0.9 , 0.2 ∧ 0.2 , 0.8 ∧ 0.5 , 0.9 ∧ 0.7 }
= max{0.4, 0.2, 0.5, 0.7} = 0.7
R s
1
a
2
b
3
Debasis Samanta
CSE
19
IIT Kharagpur
2D Membership functions : Binary fuzzy relations
(Binary) fuzzy relations are fuzzy sets 𝐴 × 𝐵 which map each element in 𝐴 × 𝐵
to a membership grade between 0 and 1 (both inclusive).
Note that a membership function of a binary fuzzy relation can be depicted with
a 3D plot.
( x, y )
Important: Binary fuzzy relations are fuzzy sets with two dimensional MFs and
so on.
Debasis Samanta
CSE
20
IIT Kharagpur
2D membership function : An example
+
Let, 𝑋 = 𝑅 = 𝑦 (the positive real line) and
𝑅 = 𝑋 × 𝑌 = "𝑦 is much greater than 𝑥“
The membership function of 𝜇𝑅 𝑥, 𝑦 is defined as
(𝑦 − 𝑥)
𝑖𝑓 𝑦 > 𝑥
𝜇𝑅 𝑥, 𝑦 = 4
0 𝑖𝑓 𝑦 ≤ 𝑥
Suppose, 𝑋 = {3,4,5} and 𝑌 = {3,4,5,6,7}, then
Debasis Samanta
CSE
21
IIT Kharagpur
Example:
How you can derive the following?
If x is A or y is B then z is C;
Given that
• R1: If x is A then z is 𝐶 [𝑅1 ∈ 𝐴 × 𝐶]
• R2: If y is B then z is 𝐶 [𝑅2 ∈ 𝐵 × 𝐶]
Hint:
You have given two relations R1 and R2.
Then, the required can be derived using the union operation of R1
and R2
Debasis Samanta
CSE
22
IIT Kharagpur
Debasis Samanta
CSE
23
IIT Kharagpur