Sei sulla pagina 1di 103

01EC6218 Soft Computing

Module-I: Fuzzy Logic

Dr. Pradeep R.
Associate Professor
GEC, Bartonhill
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.
 Some other mathematical languages :
 Relational algebra (operations on sets)
 Boolean algebra (operations on Boolean variables)
 Predicate logic (operations on well formed formulae (wff), also called
predicate propositions)

 Fuzzy logic deals with Fuzzy set

A brief history of Fuzzy Logic

 First time introduced by Lotfi Abdelli Zadeh (1965),

University of California, Berkley, USA.

 Dictionary meaning
of fuzzy is not clear,
noisy etc.
 Antonym of fuzzy
is crisp
Fuzzy logic vs. Crisp logic
Yes or No
Crisp answer
True or False


A liquid

Is the liquid
Fuzzy logic vs. Crisp logic

May be

May not be

Fuzzy answer



Our world is better

described with
Fuzzy logic vs. Crisp logic


Extremely honest
· Ankit

· Rajesh
· Santosh honest
· Kabita Honest at times

· Salmon
Extremely dishonest 35
Is the person
Concept of fuzzy system

Fuzzy element(s)

Fuzzy set(s)
Fuzzy rule(s)
Fuzzy implication(s)
Fuzzy system
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 = { h1 , h2 , h3 , ... , hL }
M = All Muslim population = { m1 , m2 , m3 , ... , mN }

Universe of discourse X


Here, All are the sets of finite numbers of individuals.

Such a set is called crisp set.
Example of fuzzy set

Let us discuss about fuzzy set.
X = All students in M2SP.
S = All Good students.
S = { (s, g) | s ∈ X } and g(s) is a measurement of goodness of the
student s.
S = { Ancy, 0.8), (Vismaya, 0.7), (Vyshak, 0.1), (Meenu, 0.9) } etc.
Fuzzy set vs. Crisp set

Crisp Set Fuzzy Set

1. S = { s | s ∈ X } 1. F = (s, µ) | s ∈ X and
µ(s) is the degree of s.
2. It is a collection of el- 2. It is collection of or-
ements. dered pairs.
3. Inclusion of an el- 3. Inclusion of an el-
ement s ∈ X into S is ement s ∈ X into F is
crisp, that is, has strict fuzzy, that is, if present,
boundary yes or no. then with a degree of
Fuzzy set vs. Crisp set
Note: A crisp set is a fuzzy set, but, a fuzzy set is not necessarily a
crisp set.
H = { (h1 , 1), (h2 , 1), ... , (hL, 1) }
Person = { (p1 , 1), (p2 , 0), ... , (pN , 1) }
In case of a crisp set, the elements are with extreme values of degree of
membership namely either 1 or 0.
How to decide the degree of memberships of elements in a fuzzy set?

City Hyderabad Kharagpur

Bangalore Bombay Hyder Madras Delhi
DoM 0.95 0.90 0.80 0.01 0.65 0.75

How the cities of comfort can be judged?

Few examples of fuzzy set
 Weight of Mango
 Sweetness of Orange
 Color of Apple
 Low Pressure
 High Temperature
Note: Degree of membership values lie in the range [0...1].
Some basic terminologies and
Definition 1: Membership function (and Fuzzy set)
If X is a universe of discourse and x ∈ X, then a fuzzy set A in X is
defined as a set of ordered pairs, that is
A = {(x , µA(x ))|x ∈ X } where µA(x) is called the membership function
for the fuzzy set A.

µA(x) map each element of X onto a membership grade (or
membership value) between 0 and 1 (both inclusive).

How (and who) decides µA(x) for a Fuzzy set A in X ?

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)}
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)}
Note : X = discrete value




0 2 4 6 8

Number of children

A = “Happy family”
Membership function with continuous
membership values

B ( x)  1
 x 50 
0.8 1 
 10 

0 50 100

Age (X)
Note : x = real value
B = “Middle aged”
Fuzzy terminologies: Support

Support: The support of a fuzzy set A is the set of all points

x ∈ X, such that µA(x ) > 0

Fuzzy terminologies: Core
Core: The core of a fuzzy set A is the set of all points x in X such that
µA(x ) = 1

core (A) = {x | µA(x) = 1}



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 x ∈ X such that µA(x ) = 1.

Fuzzy terminologies: Crossover points
Crossover point : A crossover point of a fuzzy set A is a point x
∈ X at which µA(x ) = 0.5. That is
Crossover (A) = {x |µA(x ) = 0.5}.
Fuzzy terminologies: α-cut and strong

α-cut and strong α-cut :

The α-cut of a fuzzy set A is a crisp set defined by

Aα = {x | µA(x) ≥ α }

Strong α-cut is defined similarly :

Aα ’ = {x | µA(x) > α }

Note : Support(A) = A0’ and Core(A) = A1.

Fuzzy terminologies: Convexity
Convexity : A fuzzy set A is convex if and only if for any x1 and x2 ∈ X
and any λ ∈ [0, 1]
µA (λx1 + (1 -λ)x2 ) ≥ min(µA(x1 ), µA(x2 ))

Note :
• A is convex if all its α- level sets are convex.
• Convexity (Aα ) =⇒ Aα is composed of a single line segment only.
Membership function Non-convex
is convex Membership

1.0 1.0
Fuzzy terminologies: Bandwidth

Bandwidth :

For a normal and convex fuzzy set, the bandwidth (or width) is
defined as the distance the two unique crossover points:
Bandwidth(A) = | x1 - x2 |
where µA(x1) = µA(x2) = 0.5
Fuzzy terminologies: Symmetry
Symmetry :

A fuzzy set A is symmetric if its membership function around a certain

point x = c, namely µA(x + c) = µA(x - c) for all x ∈ X.
Fuzzy terminologies: Open and Closed
A fuzzy set A is
Open left
If limx →−∞ µA(x) = 1 and limx →+∞ µA(x) = 0
Open right:
If limx →−∞ µA(x) = 0 and limx →+∞ µA(x) = 1
If : limx →−∞ µA(x) = limx →+∞ µA(x) = 0

Open right
Open left Closed
Membership Functions
Fuzzy membership functions
 A fuzzy set is completely characterized by its membership function
(sometimes abbreviated as MF and denoted as µ ). So, it would be
important to learn how a membership function can be expressed
(mathematically or otherwise).
 Note: A membership function can be on
 (a) a discrete universe of discourse and
(b) a continuous universe of discourse.

1.0 1.0
0.8 0.8
0.6 0.6

0.4 0.4
0.2 0.2

0 2 4 6 8 10 0 10 20 30 40 50

Number of children (X) Age (X)

A = Fuzzy set of “Happy family” B = “Young age”

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.
 Typical examples of membership functions.


x x x

< triangular > < trapezoidal > < curve >


x x

< non-uniform > < non-uniform >

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
{a, b, c} and can be formulated as follows.
Fuzzy MFs: Trapezoidal
A trapezoidal MF is specified by four parameters
{a; b; c; d} and be defined as follows:
Fuzzy MFs: Gaussian

A Gaussian MF is specified by two parameters {c, } and can

be defined as below:
Fuzzy MFs: Generalized bell
 It is also called Cauchy MF
A generalized bell MF is specified by
three parameters {a, b, c} and is defined as:
Fuzzy MFs: Sigmoidal MFs

Parameters: {a, c} ; where c = crossover point and a =

slope at c;
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 A fuzzy implementation will look like the
 Poor = 35 ≤ Marks ≤ 50 following.
 Bad= Marks ≤ 35
Operations on Fuzzy Sets
 Union
 Intersection
 Complement
 Products
Basic fuzzy set operations: Union
 Union (A ∪ B):
µA∪B (x ) = max{µA(x ), µB (x )}
A = {(x1, 0.5), (x2, 0.1), (x3, 0.4)} and
B = {(x1, 0.2), (x2, 0.3), (x3, 0.5)};
C = A ∪ B = {(x1, 0.5), (x2, 0.3), (x3, 0.5)}
 Intersection (A ∩ B):
µA∩B (x ) = min{µA(x ), µB (x )}
A = {(x1, 0.5), (x2, 0.1), (x3, 0.4)} and
B = {(x1, 0.2), (x2, 0.3), (x3, 0.5)};
C = A ∩ B = {(x1, 0.2), (x2, 0.1), (x3, 0.4)}
fuzzy set operations:
 Complement (AC ):

µA (x ) = 1-µA(x )
 Example:
A = {(x1, 0.5), (x2, 0.1), (x3, 0.4)}
C = AC = {(x1, 0.5), (x2, 0.9), (x3, 0.6)}

 Algebric product or Vector product (A•B):

µA•B (x ) = µA(x ) • µB (x )
 Scalar product (α × A):

µαA(x ) = α · µA(x )
Sum and Difference
Equality and Power
Cartesian product
Properties of fuzzy sets
Properties of fuzzy sets
What are the fuzzy sets representing the following?
1. Not cold climate
2. Not hold climate
3. Extreme climate
4. Pleasant climate
Note: Note that ”Not cold climate” 6 = ”Hot climate” and vice-
Fuzzy Resolution Principle
Generation of MFs
Linguistic variables and values
 To understand the fuzzy relations, it is better to discuss first
crisp relation.
 Suppose, A and B are two (crisp) sets. Then Cartesian
product denoted as A x B is a collection of order pairs, such
Ax B = {(a,b)|a €A and b € B}
Note :
(1) Ax B≠ B x A
(2) |A x B| = |A|x |B|
(3)A x B provides a mapping from a € A to b € B.
 The mapping so mentioned is called a relation.
Crisp Relation
 Consider the two crisp sets A and B as given below. A ={ 1, 2, 3, 4} B
= {3, 5, 7 }
Then, A x B = {(1; 3); (1; 5); (1; 7); (2; 3); (2; 5); (2; 7); (3; 3); (3;
5); (3; 7); (4; 3); (4; 5); (4; 7)}
Let us define a relation R as R = {(a; b)|b = a + 1; (a; b) € Ax B}
Then, R = {(2; 3); (4; 5)} in this case.
We can represent the relation R in a matrix form as follows.
Fuzzy relations
 Fuzzy relation is a fuzzy set defined on the Cartesian product of crisp set
 Here, n-tuples (x1, x2,… xn) may have varying degree of memberships
within the relationship.
 The membership values indicate the strength of the relation between the
X = { typhoid, viral, cold } and Y = { running nose, high temp, shivering }
The fuzzy relation R is defined as
Binary (Fuzzy) relation
 A special fuzzy relation called a binary (fuzzy) relation plays an
important role in fuzzy set theory.
 A binary fuzzy relation is a fuzzy relation between two sets X
andY and is denoted by R (X,Y).When X ≠Y, binary relations
R (X,Y) are referred to as bipartite graphs.
 When X =Y, R is a binary fuzzy relation on a single set X, and
the relations are referred to as directed graphs, or digraphs, and
are denoted by R (X, X) or R (X2).
Operations on Fuzzy relations
Fuzzy rule
 A fuzzy implication (also known as fuzzy If-Then rule, fuzzy
rule, or fuzzy conditional statement) assumes the form :
If x is A then y is B
where, A and B are two linguistic variables defined by fuzzy
sets A and B on the universe of discourses X and Y,
 Often, x is A is called the antecedent or premise, while y is B
is called the consequence or conclusion.
Fuzzy implication : Example 1
 If pressure is High then temperature is Low
 If road is Good then driving is Smooth else traffic is High
 If mango is Yellow then mango is Sweet else mango is Sour
 The fuzzy implication is denoted as R : A  B
 In essence, it represents a binary fuzzy relation R on the
(Cartesian) product of A x B
 Suppose, P and T are two universes of discourses
representing pressure and temperature, respectively as
 P ={1,2,3,4} and T ={10, 15, 20, 25, 30, 35, 40, 45, 50 }
 Let the linguistic variable High temperature and Low
pressure are given as
 THIGH={(20; 0:2); (25; 0:4); (30; 0:6); (35; 0:6); (40; 0:7);
(45; 0:8); (50; 0:8)}
 PLOW = {(1; 0:8); (2; 0:8); (3; 0:6); (4; 0:4)}
 Then the fuzzy implication If temperature is High then
pressure is Low can be defined as
T-norm operator
Zadeh’s Max-Min rule
Operations of fuzzy sets
Let A and B be fuzzy sets in universal sets U and V respectively.
Fuzzy inferences
 Two important inferring procedures are used in fuzzy systems :

 Generalized Modus Ponens (GMP)

If x is A Then y is B
x is A’
y is B’

 Generalized Modus Tollens (GMT)

If x is A Then y is B
y is B’
x is A’
Example: GMP
Example: GMT
Fuzzy logic controller (FLC)
 Fuzzy logic control (FLC), initiated by the pioneering work
of Mamdani and Assilian [1975]
 To incorporate the "expert experience" of a human operator
In the design of the controller
 Input-output relationship is described by a collection of fuzzy
control rules (e.g., IF-THEN rules)
 Comprised of four principal components: a fuzzifier, a
fuzzy rule base, an inference engine, and a defuzzifier.
Fuzzy logic controller (FLC)
Input-Output Spaces
 Typically, the input variables in a FLC are the state, state
error, state error derivative, state error integral, and so on.
 The input vector x which includes the input state linguistic
variables xi form a fuzzy input space U = U1x U2x . . . .x Xn
 The output state vector y which includes the output state (or
control) linguistic variables yi form a fuzzy output space
V=V1xV2x . . . .xVn

where T(xi) is the term set of xi

For example, if xi, indicates real numbers,
then T(xi) ={ T1 xi.,T2 xi.,T3xi} may be “N-negative,”,“ZE-zero,” and “P-
positive.” The size (or cardinality) of a term set | T(xi) |= ki is
called the fuzzy partition of xi
 It is mapping from an observed input space to labels of fuzzy
sets in a specified input universe of discourse.
 A simple fuzzification approach is to convert a crisp value x0
into a fuzzy singleton A.
 The membership function of A, µ(x), is equal to 1 at the point
x0 , and zero at other places.
 Here a specific value xi(t) at time t, it is mapped to the fuzzy
set T1xi with degreeµ1xi (xi(t)) and to the fuzzy set T2xi with
degree µ2xi (xi(t)) and so on.
 Complex cases require both probabilistic and possibilistic
modes of characterization.
Fuzzy Rule Base
 a collection of fuzzy IF-THEN rules
 collection of fuzzy control rules characterizes the simple
input-output relation of the system.
The general form of the fuzzy control rules of multi-input-
single-output systems (MISO) is:
Ri: IF x is Ai,…., AND y is Bi, THEN z = Ci i=1,2,…, n
Inference Engine
 It is the kernel of the FLC
 The generalized modus ponens GMP (forward data-driven
inference) widely used

 Other Four types of compositional operators that can be used

Various Fuzzy Implication Rules

Among the various fuzzy implications, Mamdani's fuzzy implication method Rc associated
with the max-min composition is the most frequently used in fuzzy logic control.
Let us assume that we have two fuzzy control rules as follows:
R1: IF x is A1 AND y is B1, THEN z is C1
R2: IF x is A2 AND y is B2, THEN z is C2
Then the firing strengths α1 and α2 of the first and second rules
may be expressed as

where µA1(x0) and µB1(y0) indicate the degrees of partial match

between the user-supplied data and the data in the fuzzy rule
 Mamdani's minimum fuzzy implication rule, Rc :The ith fuzzy
control rule leads to the control decision

 The final inferred consequent C is given by

 In many practical applications crisp control action is required
to actuate the control
 Defuzzification is a mapping from a space of fuzzy control
actions defined over an output universe of discourse into a
space of nonfuzzy (crisp) control actions.
 It is aimed at producing a nonfuzzy control action
 No systematic procedure for choosing a defuzzification
 Two commonly used methods of defuzzification are :
 center of area (COA) method
 mean of maximum (MOM) method.
Center of area (COA) method
 It generates the center of gravity of the possibility
distribution of a control action.

for discrete cases where n is the number of quantization

levels of the output and for continuous cases
Mean of maximum (MOM) method.
 This strategy generates a control action that represents the mean
value of all local control actions whose membership functions
reach the maximum
 For a discrete universe, the control action is:

where Zj is the support value at which the membership function

reaches the maximum value µC(zj) and m is the number of such
support values

 (* COA strategy has been shown to yield superior results)

Given a fuzzy logic control system with the following two fuzzy control rules
Rule 1: IF x is A1 AND y is B1, THEN z is C1
Rule 2: IF x is A2 AND y is B2, THEN z is C2
Suppose x0 and y0 are the sensor readings for linguistic input variables x and y and the
following Membership functions for fuzzy predicates A1, A2, B1, B2, C1 and C2 are given:
Further assume that at time t1, we are reading the sensor values at x0 (t1) = 4 and
y0(t1) = 8. How the final control output is computed?

The principal elements of designing a FLC include

1. Defining input and output variables,
2. Deciding on the fuzzy partition of the input and output spaces
and choosing the membership functions for the input and
output linguistic variables,
3. Deciding on the types and the derivation of fuzzy control rules,
4. Designing the inference mechanism, which includes choosing a
fuzzy implication and a compositional operator, and the
interpretation of sentence connectives AND and ALSO, and
5. Choosing a defuzzification operator.
Derivation of fuzzy control rules
There are four methods for the derivation of fuzzy control rules and these methods are not
mutually exclusive.
1. Expert experience and control engineering knowledge
2. Modeling an operator's control actions
3. Based on a fuzzy model or behavior analysis of a controlled process
4. Based on learning (or self-organizing)
Try do some problems given in text….