You are on page 1of 41

Fuzzy Logic

Prepared By
Artificial Intelligence
Biprodip Pal
CSE 609
Lecturer
Dept. of CSE
RUET
Fuzzy Logic
 One way to represent inexact data and knowledge, closer
to humanlike thinking, is to use fuzzy rules instead of
exact rules when representing knowledge.
 Fuzzy rules represent in a straightforward way knowledge
that is subjective, ambiguous, vague, or contradictory
Applications

 Control of automatic washing machines


 Automatic camera focusing
 Control of transmission systems in new models of cars
 Automatic landing systems for aircraft
 Automatic air-conditioning systems
 Cooperative robots
 …
Main components of FLS

 Fuzzy input and output variables, defined by their fuzzy


values
 A set of fuzzy rules
 Fuzzy inference mechanism

Input : exact / crisp (e.g., 7) /fuzzy values (e.g.," moderate").


Output : fuzzy / exact (crisp).
Fuzzy Sets
 In fuzzy sets an object can belong to a set partially. The
degree of membership is defined through membership
function:

μA(u): U  [0,1]

where U is called the universe, and A is a fuzzy subset of U.


Fuzzy Sets

Table: Degree of membership of ‘tall men’


Fuzzy Sets

Fig.: (a) Crisp set (b) Fuzzy Set for Tall men
Crisp and Fuzzy Subset Representation
A Fuzzy Logic System.
Algorithm : Fuzzy logic algorithm

 1. Define the linguistic variables and terms (initialization)


 2. Construct the membership functions (initialization)
 3. Construct the rule base (initialization)
 4. Convert crisp input data to fuzzy values
using the membership functions (fuzzification)
 5. Evaluate the rules in the rule base (inference)
 6. Combine the results of each rule (inference)
 7. Convert the output data to non-fuzzy values
(defuzzification)
A Simple FLS to Control an Air Conditioner.
Linguistic Variables

 Linguistic variables are the input or output variables of


the system whose values are words or sentences from a

natural language, instead of numerical values.

temperature (t) : represents the temperature of a room.


Membership Functions
 A membership function is used to quantify a linguistic
term.
 Used in the fuzzification (steps map the non-fuzzy input
values to fuzzy linguistic terms)
 Also used in defuzzification (vice versa)
Membership Functions (Cont.)
Membership functions (Triangular)
Membership functions (Triangular)
Membership functions (Trapezoidal)
Membership functions (Trapezoidal)
Membership functions (Gaussian)
Membership functions (Bell)
Membership functions (Sigmoid)
Fuzzy Rules
 Simple IF-THEN rule
 Constructed to control the output variable
Fuzzy Rules (Cont…)
Fuzzy Set Operations

 MAX Max {μA(x), μB(x)}

 MIN Min{μA(x), μB(x)}

 NOT (complement) 1-μA(x)


Inference Procedure

 Mamdani-style inference
 Sugeno-style inference
 …
Example Problem

 Estimate the level of risk involved in a software


engineering project based on two inputs: project
funding and project staffing.
Inference Example
X: If project funding is adequate than I shall take the risk of
doing it.

Y: Project funding is inadequate, so risk is high, someone


else will do it.

X:Than if project staffing is small than I can proceed too.

Y: As manager says project funding will be around 35% and


project staffing will be around 60% so what to do?
Inference Example

Input
project_funding = 35%
and
project_staffing = 60%.
Inference Example
Linguistic Variables

project_funding project_staffing risk


inadequate small low
marginal Large normal
adequate high
Inference Example
Company Uses values like 35%, 50% etc.
We are comfortable with linguistics.

project_funding project_staffing risk


Inadequate (x≤40) Small(…) Low
Marginal(20 ≤x≤ 80) Large(…) normal
Adequate(x ≥ 80) high
Inference Example
Fuzzy Membership Value

Project_funding Project_staffing
Inference Example
 Calculation

 Let for inadequate region(trapezoidal)


c=30
d=40
So, µ(35) = (x-d)/(c-d) =(35-40)/(30-40)=5/10=.5
inadequate


Inference Example
 Conversion from crisp input to fuzzy value according to
membership

µ(35)inadequate =.5

project_funding = 35%
µ(35)marginal =.25

µ(35)adequate =0
Inference Example
 Conversion from crisp input to fuzzy value according to
membership

µ(60)small =.1

project_staffing = 60%

µ(60)large =.7
Inference Example
 Rules

 If project_funding is adequate or project_staffing is small


then risk is low.
 If project_funding is marginal and project_staffing is large
then risk is normal.
 If project_funding is inadequate then risk is high.
Inference Example
 Rule Evaluation:
 Rule 1 - If project_funding is adequate or project_staffing is small
then risk is low
µrisk=nlow =max( µ(35)adequate , µ(60)small )
=max(0 , .1)
=.1
 Rule 2 - If project_funding is marginal and project_staffing is large
then risk is normal
µrisk=normal =max(
.25 µ(35)marginal , µ(60)large )
=max(.25 , .7)
=.7
 Rule 3 - If project_funding is inadequate then risk is high

µrisk=high =.5
Inference Example
 Final result : Union on all of the scaled functions
Inference Example
Inference Example
 Defuzzification
 Centroid method:

COG=
Inference Example
 Defuzzification

COG =
(0+10 +20)*.1+(30 + 40 +50 +60)*.2 +(70 +80 +90 +100)*.5
.1* 3+.2*4 +.5*4
=67.4
Inference Example
 The result is that this project has 67.4% risk associated
with it given the definitions above.

***

You might also like