Anda di halaman 1dari 135

# Fuzzy logic

## What is Fuzzy Logic?

A computational paradigm that is based on how humans
think.
Fuzzy Logic looks at the world in imprecise terms, in much the
same way that our brain takes in information (e.g.
temperature is hot, speed is slow), then responds with precise
actions.
The human brain can reason with uncertainties, vagueness,
and judgments. Computers can only manipulate precise
valuations. Fuzzy logic is an attempt to combine the two
techniques.
Fuzzy a misnomer, has resulted in the mistaken suspicion
that FL is somehow less exacting than traditional logic.
What Is Fuzzy Logic ?

## Form of multi-valued logic (algebra) derived from fuzzy set

theory.
Designed to deal with reasoning that is approximate rather than
accurate.
Consequence of the 1965 proposal of fuzzy set theory by Lotfi
In contrast with "crisp logic", where binary sets have binary logic,
fuzzy logic variables may have a truth value that ranges
between 0 and 1.
Can include linguistic variables, like: high, low, hot, cold, and
very.
What Is Fuzzy Logic ?

## FL is in fact, a precise problem-solving methodology.

It is able to simultaneously handle numerical data and
linguistic knowledge.
A technique that facilitates the control of a complicated
system without knowledge of its mathematical description.
Fuzzy logic differs from classical logic in that statements are no
longer black or white, true or false, on or off.
In traditional logic an object takes on a value of either zero or
one.
In fuzzy logic, a statement can assume any real value
between 0 and 1, representing the degree to which an
element belongs to a given set.
Fuzzy logic
Fuzzy logic addresses key problem in expert systems
o How to represent domain knowledge
o Humans use imprecisely calibrated terms
o How to build decision trees on imprecise thresholds
Where not to use fuzzy
logic
Do not use fuzzy logic if:
o Humans do not understand the system
o Different experts disagree
o Knowledge can not be expressed with verbal rules
o Gut instinct is involved
Not just objective analysis
Examples where fuzzy logic is used

Automobile and other vehicle subsystems, such as ABS and cruise control
(e.g. Tokyo monorail)
Air conditioners
The Massive engine used in the Lord of the Rings films, which helped show
huge scale armies create random, yet orderly movements
Cameras
Digital image processing, such as edge detection
Rice cookers
Dishwashers
Elevartors
Washing machines and other home appliances
Video game artificial intelligence
Massage boards and chat rooms
Fuzzy logic has also been incorporated into some microcontrollers and
microprocessors, for instance Freescale 68HC12.
Specific Fuzzified Applications

Elevators Cranes
Vacuum Cleaners Electric Razors
Hair Dryers Camcorders
Air Control in Soft Television Sets
Drink Production Showers
Noise Detection
on Compact Disks
In the city of Sendai in Japan, a 16-station subway system is
controlled by a fuzzy computer (Seiji Yasunobu and Soji
Miyamoto of Hitachi) the ride is so smooth, riders do not
need to hold straps
Nissan fuzzy automatic transmission, fuzzy anti-skid braking
system
CSK, Hitachi Hand-writing Recognition
Sony - Hand-printed character recognition
Ricoh, Hitachi Voice recognition
Tokyos stock market has had at least one stock-trading
portfolio based on Fuzzy Logic that outperformed the Nikkei
exchange average
Intel Corporation's Embedded Microcomputer Division Fuzzy Logic

Operation

http://www.intel.com/design/mcs96/designex/2351.htm

## Motorola 68HC12 MCU

For washing machines, Fuzzy Logic control is almost
becoming a standard feature
fuzzy controllers to load-weight, fabric-mix, and dirt
sensors and automatically set the
wash cycle for the best use of power, water, and
detergent
GE WPRB9110WH Top Load Washer
Others: Samsung, Toshiba, National, Matsushita, etc.
Haier ESL-T21 Top Load Washer
Miele WT945 Front Load All-in-One Washer / Dryer
AEG LL1610 Front Load Washer
Zanussi ZWF1430W Front Load Washer
NASA has studied fuzzy control for automated space docking:
simulations show that a fuzzy control system can greatly reduce
fuel consumption Canon developed an auto-focusing camera
that uses a charge-coupled device (CCD) to measure the clarity
of the image in six regions of its field of view and use the
information provided to determine if the image is in focus. It also
tracks the rate of change of lens movement during focusing, and
controls
its speed to prevent overshoot.
http://en.wikipedia.org/wiki/Fuzzy_system
The camera's fuzzy control system uses 12 inputs: 6 to obtain the
current clarity data provided by the CCD and 6 to measure the
rate of change of lens movement. The output is the position of
the lens. The fuzzy control system uses 13 rules and requires 1.1
kilobytes of memory.
In 1965, Lotfi A. Zadeh of the University of California at
Berkeley published "Fuzzy Sets," which laid out the
mathematics of fuzzy set theory and, by extension, fuzzy
logic.
Zadeh had observed that conventional computer logic
couldn't manipulate data that represented subjective or
vague ideas, so he created fuzzy logic to allow
computers to determine the distinctions among data
with shades of gray, similar to the process of human
reasoning.
What is fuzzy logic?
Definition of fuzzy
Fuzzy not clear, distinct, or precise; blurred

## Definition of fuzzy logic

A form of knowledge representation suitable for notions
that cannot be defined precisely, but which depend
upon their contexts.
Why use fuzzy logic?
Pros:
Conceptually easy to understand w/ natural maths
Tolerant of imprecise data
Universal approximation: can model arbitrary nonlinear
functions
Intuitive
Based on linguistic terms
Convenient way to express expert and common sense
knowledge
Cons:
Not a cure-all
Crisp/precise models can be more efficient and even
convenient
Other approaches might be formally verified to work
Fuzzy sets and concepts are commonly used in natural language
John is tall
Dan is smart
Alex is happy
The class is hot
E.g., the crisp set Tall can be defined as:

## But what about a person with a height = 1.79 meters?

What about 1.78 meters?

## What about 1.52 meters?

In a fuzzy set a person with a height of 1.8 meters would be
considered tall to a high degree
A person with a height of 1.7 meters would be considered tall to
a lesser degree etc.
The function can change for basketball players, Danes,
women, children etc.
Formal Definition
Fuzzy logic provides a method to formalize reasoning when
dealing with vague terms.
Traditional computing requires finite precision which is not
always possible in real world scenarios. Not every decision is
either true or false, or as with Boolean logic either 0 or 1.
Fuzzy logic allows for membership functions, or degrees of
truthfulness and falsehoods. Or as with Boolean logic, not only 0
and 1 but all the numbers that fall in between.
Fuzzy Set Theory

## In traditional set theory, an element either belongs to a

set, or it does not.

## In Fuzzy Set Theory membership functions classify

elements in the range [0,1], with 0 and 1 being no and
full inclusion, the other values being partial membership.
Where did Fuzzy Logic come from

## People generally do not divide things into clean

categories, yet still make solid, adaptive decisions.

## Dr. Zadeh felt that having controllers to accept 'noisy' data

might make them easier to create, and more effective.
Simple example of Fuzzy Logic
Controlling a fan:

Conventional model
if temperature > X, run fan
else, stop fan

Fuzzy System -
if temperature = hot, run fan at full speed
if temperature = warm, run fan at moderate speed
if temperature = comfortable, maintain fan speed
if temperature = cool, slow fan
if temperature = cold, stop fan
REPRESENTATION OF LOGIC

bool speed;
get the speed
if ( speed == 0) {
// speed is slow
}
else {
// speed is fast
}
Better (Fuzzy Representation)

Slowest
For every problem
must represent in [ 0.0 0.25 ]
terms of fuzzy sets.
Slow
What are fuzzy sets? [ 0.25 0.50 ]

Fast
[ 0.50 0.75 ]

Fastest
[ 0.75 1.00 ]
Representing Fuzzy Sets

float speed;
get the speed
if ((speed >= 0.0)&&(speed < 0.25)) {
// speed is slowest
}
else if ((speed >= 0.25)&&(speed < 0.5))
{
// speed is slow
}
else if ((speed >= 0.5)&&(speed < 0.75))
{
// speed is fast
}
else // speed >= 0.75 && speed < 1.0
{
// speed is fastest
}
Range of logical values in Boolean and fuzzy logic

## 0 0 0 1 1 1 0 0 0.2 0.4 0.6 0.8 1 1

(a) Boolean Logic. (b) Multi-valued Logic.
Crisp set theory is governed by a logic that uses one of
only two values: true or false. This logic cannot represent
vague concepts, and therefore fails to give the answers
The basic idea of the fuzzy set theory is that an element
belongs to a fuzzy set with a certain degree of
membership.
Thus, a proposition is not either true or false, but may be
partly true (or partly false) to any degree. This degree is
usually taken as a real number in the interval [0,1].
The classical example in fuzzy sets is tall men. The
elements of the fuzzy set tall men are all men, but their
degrees of membership depend on their height.

Degree of Membership
Name Height, cm Crisp Fuzzy
Chris 208 1 1.00
Mark 205 1 1.00
John 198 1 0.98
Tom 181 1 0.82
David 179 0 0.78
Mike 172 0 0.24
Bob 167 0 0.15
Steven 158 0 0.06
Bill 155 0 0.01
Peter 152 0 0.00
Crisp and fuzzy sets of tall men
Degree of Crisp Sets
Membership
1.0
0.8
Tall Men
0.6
0.4
0.2
0.0
150 160 170 180 190 200 210
Height, cm
Degree of Fuzzy Sets
Membership
1.0
0.8
0.6
0.4
0.2
0.0
150 160 170 180 190 200 210
Height, cm
A fuzzy set is a set with fuzzy boundaries
Let X be the universe of discourse and its elements be
denoted as x. In the classical set theory, crisp set A of X is
defined as function fA(x) called the characteristic function
of A

## fA(x): X {0, 1}, where

1, if x A
f A ( x)
0, if x A
This set maps universe X to a set of two elements. For any
element x of universe X, characteristic function fA(x) is equal to 1
if x is an element of set A, and is equal to 0 if x is not an element
of A.
In the fuzzy theory, fuzzy set A of universe X is defined by
function A(x) called the membership function of set A
A(x): X [0, 1], where:

A(x) = 1 if x is totally in A;

A(x) = 0 if x is not in A;

## This set allows a continuum of possible choices. For any element

x of universe X, membership function A(x) equals the degree to
which x is an element of set A. This degree, a value between 0
and 1, represents the degree of membership, also called
membership value, of element x in set A.
How to represent a fuzzy set in a
computer?

## First, we determine the membership functions. In our tall men

example, we can obtain fuzzy sets of tall, short and average
men.
The universe of discourse the mens heights consists of three
sets: short, average and tall men. As you will see, a man who is
184 cm tall is a member of the average men set with a degree
of membership of 0.1, and at the same time, he is also a
member of the tall men set with a degree of 0.4.
Crisp and fuzzy sets of short, average and tall
men
Degree of Crisp Sets
Membership
1.0
0.8 Short Average Short
Tall
Tall Men
0.6
0.4
0.2
0.0
150 160 170 180 190 200 210
Height, cm
Degree of Fuzzy Sets
Membership
1.0
0.8
0.6 Short Average Tall

0.4
0.2 Tall

0.0
150 160 170 180 190 200 210
Representation of crisp and fuzzy subsets
(x)
X Fuzzy Subset A
1

0
Crisp Subset A Fuzziness Fuzziness x

## Typical functions that can be used to represent a fuzzy set are

sigmoid, Gaussian and pi. However, these functions increase the
time of computation. Therefore, in practice, most applications use
linear fit functions.
For example, the fuzzy set of tall men can be
represented as a fit-vector
o Tall men ={0/180, 0.5/185, 1/190}
o Average men ={0/165, 1/175, 0/185}
o Short men ={1/160, 0.5/165, 0/170}
Fuzzy logic example
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.
Let temperature (t) is the linguistic variable which
represents the temperature of a room.
To qualify the temperature, terms such as hot" and
cold" are used in real life.
These are the linguistic values of the temperature.
Then, T(t) = {too-cold, cold, warm, hot, too-hot} can be
the set of decompositions for the linguistic variable
temperature.
Each member of this decomposition is called a linguistic
term and can cover a portion of the overall values of
the temperature.
A temperature value can be considered as cold" and too-cold" at the
same time, with different degree of memberships.
Membership Functions

## Membership functions are used in the fuzziffication and defuzziffication steps

of a FLS, to map the non-fuzzy input values to fuzzy linguistic terms and vice
versa. A membership function is used to quantify a linguistic term.
Membership Functions

## The following criteria are valid for all membership

functions:
The membership function must be a real valued
function whose values are between 0 and 1.
The membership values should be 1 at the center of
the set, i.e., for those members that definitely belong
to the set.
The membership function should fall off in an
appropriate way from the center through the
boundary.
Membership Functions for T(temperature) = {too-cold, cold, warm,

hot, too-hot}.
Different Types of Membership
Functions.
There are different forms of membership functions such as triangular,
trapezoidal, Gaussian, or singleton. The most common types of
membership functions are triangular, trapezoidal, and Gaussian
shapes.
Singleton

triangle

Trapezoid
al

Sigmoidal
Trapezoidal Membership Functions

LeftTrapezoid
Left_Slope = 0
Right_Slope = 1 / (A - B)

CASE 1: X < a
Membership Value = 1
CASE 2: X >= b
Membership Value = 0
CASE 3: a < x < b
Membership Value = Right_Slope * (X - b)
RightTrapezoid
Left_Slope = 1 / (B - A)
Right_Slope = 0
CASE 1: X <= a
Membership Value = 0
CASE 2: X >= b
Membership Value = 1
CASE 3: a < x < b
Membership Value = Left_Slope * (X - a)
Regular Trapezoid
Left_Slope = 1 / (B - A)
Right_Slope = 1 / (C - D)
CASE 1: X <= a Or X >= d
Membership Value = 0
CASE 2: X >= b And X <= c
Membership Value = 1
CASE 3: X >= a And X <= b
Membership Value = Left_Slope * (X - a)
CASE 4: (X >= c) And (X <= d)
Membership Value = Right_Slope * (X - d)
Membership functions: S-function
The S-function can be used to define fuzzy sets
S(x, a, b, c) =
0 for x a
2(x-a/c-a)2 for a x b
1 2(x-c/c-a)2 for b x c
1 for x c
Membership functions: Function
(x, a, b) =
S(x, b-a, b-a/2, b) for x b
1 S(x, b, b+a/2, a+b) for x b
Membership functions: S-function
The S-function can be used to define fuzzy sets
Membership functions: Function
Simple membership functions
Piecewise linear: triangular etc.
Easier to represent as e ep ese t and calculate
saves computation
Membership Functions

## Temp: {Freezing, Cool, Warm, Hot}

Degree of Truth or "Membership"

## Freezing Cool Warm Hot

1

0
10 30 50 70 90 110
Temp. (F)
Membership Functions

How cool is 36 ?

## Freezing Cool Warm Hot

1

0
10 30 50 70 90 110
Temp. (F)
Membership Functions

How cool is 36 F ?
It is 30% Cool and 70% Freezing

## Freezing Cool Warm Hot

1
0.7

0.3

0
10 30 50 70 90 110
Temp. (F)
Linguistic Hedges
Modifying the meaning of a fuzzy set using hedges
such as very, more or less, slightly, etc.
Fuzzy sets with the hedge very
Degree of
Membership
1.0
Short Short
Tall
0.8
0.6 Average

0.4
Very Short Very
VeryTall
Tall
Tall
0.2
0.0
150 160 170 180 190 200 210
Height, cm
Representation of hedges in fuzzy logic
Representation of hedges in fuzzy logic
(continued)
Operations of fuzzy sets
The classical set theory developed in the late 19th century by
Georg Cantor describes how crisp sets can interact. These
interactions are called operations.
Cantors sets
Complement
Crisp Sets: Who does not belong to the set?
Fuzzy Sets: How much do elements not belong to the set?

## The complement of a set is an opposite of this set. For example, if

we have the set of tall men, its complement is the set of NOT
tall men.
When we remove the tall men set from the universe of discourse,
we obtain the complement.
If A is the fuzzy set, its complement A can be found as follows:

A(x) = 1 A(x)
Containment
Crisp Sets: Which sets belong to which other sets?
Fuzzy Sets: Which sets belong to other sets?

## Similar to a Chinese box, a set can contain other sets. The

smaller set is called the subset. For example, the set of
tall men contains all tall men; very tall men is a subset of
tall men. However, the tall men set is just a subset of the
set of men.
In crisp sets, all elements of a subset entirely belong to a
larger set. In fuzzy sets, however, each element can
belong less to the subset than to the larger set.
Elements of the fuzzy subset have smaller memberships in it
than in the larger set.
Intersection
Crisp Sets: Which element belongs to both sets?
Fuzzy Sets: How much of the element is in both sets?

## In classical set theory, an intersection between two sets

contains the elements shared by these sets. For example,
the intersection of the set of tall men and the set of fat
men is the area where these sets overlap.
In fuzzy sets, an element may partly belong to both sets with
different memberships. A fuzzy intersection is the lower
membership in both sets of each element. The fuzzy
intersection of two fuzzy sets A and B on universe of
discourse X:
AB(x) = min [A(x), B(x)] = A(x) B(x),
where xX
Union
Crisp Sets: Which element belongs to either set?
Fuzzy Sets: How much of the element is in either set?

The union of two crisp sets consists of every element that falls
into either set. For example, the union of tall men and fat
men contains all men who are tall OR fat.
In fuzzy sets, the union is the reverse of the intersection. That
is, the union is the largest membership value of the
element in either set.
The fuzzy operation for forming the union of two fuzzy sets A
and B on universe X can be given as:

## AB(x) = max [A(x), B(x)] = A(x) B(x),

where xX
Operations of fuzzy sets
Fuzzy logical operations
Step 1. Evaluate the antecedent for
each rule
Step 2. Obtain each rule's conclusion
Step 3. Aggregate conclusions
Step 4. Defuzzification
Fuzzy Inference
In binary logic we have only two possible values for a logical variable, true or false, 1
or 0. As we have seen in this chapter, many phenomena can be better represented
by fuzzy sets than by crisp classes. Fuzzy sets can also be applied to reasoning when
vague concepts are involved.
In binary logic reasoning is based on either deduction (modus ponens) or induction
(modus tollens). In fuzzy reasoning we use a generalized modus ponens which reads
as
Premise1: If x is A then y is B
Premise2: x is A
Conclusion: y is B
Here, A, B , A , and B are fuzzy sets where A and B are not exactly the same as A
and B .

## Consider the generalized modus ponens for temperature control:

Premise1: If the temperature is low then set the heater to high
Premise2: Temperature is very low
Conclusion: Set the heater to very high

With logic inference we normally have more than one rule. In fact, the number of
rules can be rather large. We know several methods for fuzzy reasoning
Inference
Input Fuzzifier Defuzzifier Output
Engine

Defuzzifier
Fuzzy
Knowledge base

## Converts the fuzzy output of the inference engine to

crisp using membership functions analogous to the
ones used by the fuzzifier.
Five commonly used defuzzifying methods:
o Centroid of area (COA)
o Bisector of area (BOA)
o Mean of maximum (MOM)
o Smallest of maximum (SOM)
o Largest of maximum (LOM)
Inference
Input Fuzzifier Defuzzifier Output
Engine

Defuzzifier
Fuzzy
Knowledge base
Inference
Input Fuzzifier Defuzzifier Output
Engine

Defuzzifier
Fuzzy
Knowledge base

A ( z ) zdz
zCOA Z
,

Z
A ( z )dz

zdz
zBOA zMOM Z
,
A ( z )dz A ( z )dz,
Z
dz
zBOA

where Z {z; A ( z ) *}
A Simple FLS to Control an Air
Conditioner.
Fuzzification

## Input variables are assigned degrees of membership in

various classes e.g. A temperature input might be
graded according to its degree of coldness, coolness,
warmth or heat.
We will see a complete example of the steps involved
later.
The purpose of fuzzification is to map the inputs from a
set of sensors (or features of those sensors) to values from
0 to 1 using a set of input membership functions.
Mamdani assumption
Min operation for AND operator between conditions in
one rule

IF a AND b THEN c

## Max operation for the aggregation of the rules

conclusions with the same decision value.

IF a AND b THEN c
IF k AND b THEN d
IF a AND g THEN c
IF a AND b THEN f
Fuzzy Disjunction
AB = max(A, B)
AB = C "Quality C is the disjunction of Quality A
and B"

A B
1 1

0.75

0.375

0 0

(AB = C) (C = 0.75)
Fuzzy Conjunction

AB = min(A, B)
AB = C "Quality C is the conjunction of Quality A
and B"
A B
1 1

0.75

0.375

0 0

(AB = C) (C = 0.375)
Example: Fuzzy Conjunction
Calculate AB given that A is .4 and B is 20

A B
1 1

0 0
.1 .2 .3 .4 .5 .6 .7 .8 .9 1 5 10 15 20 25 30 35 40
Example: Fuzzy Conjunction
Calculate AB given that A is .4 and B is 20

A B
1 1

0 0
.1 .2 .3 .4 .5 .6 .7 .8 .9 1 5 10 15 20 25 30 35 40

## Determine degrees of membership:

Example: Fuzzy Conjunction
Calculate AB given that A is .4 and B is 20

A B
1 1

0.7

0 0
.1 .2 .3 .4 .5 .6 .7 .8 .9 1 5 10 15 20 25 30 35 40

## Determine degrees of membership:

A = 0.7
Example: Fuzzy Conjunction
Calculate AB given that A is .4 and B is 20

A B
1 1
0.9
0.7

0 0
.1 .2 .3 .4 .5 .6 .7 .8 .9 1 5 10 15 20 25 30 35 40

## Determine degrees of membership:

A = 0.7 B = 0.9
Example: Fuzzy Conjunction
Calculate AB given that A is .4 and B is 20

A B
1 1
0.9
0.7

0 0
.1 .2 .3 .4 .5 .6 .7 .8 .9 1 5 10 15 20 25 30 35 40

## Determine degrees of membership:

A = 0.7 B = 0.9
Apply Fuzzy AND
AB = min(A, B) = 0.7
Fuzzy Control

## Fuzzy Control combines the use of fuzzy linguistic

variables with fuzzy logic

## It depends on the weather

Disjunction of Conjunctions
Inputs: Temperature

## Freezing Cool Warm Hot

1

0
10 30 50 70 90 110
Temp. (F)
Inputs: Temperature, Cloud Cover
Temp: {Freezing, Cool, Warm, Hot}

## Freezing Cool Warm Hot

1

0
10 30 50 70 90 110
Temp. (F)

## Sunny Partly Cloudy Overcast

1

0
0 20 40 60 80 100
Cloud Cover (%)
Output: Speed

Slow Fast
1

0
0 25 50 75 100
Speed (mph)
Rules

## If it's Sunny and Warm, drive Fast

Sunny(Cover)Warm(Temp) Fast(Speed)

## If it's Cloudy and Cool, drive Slow

Cloudy(Cover)Cool(Temp) Slow(Speed)

## Driving Speed is the combination of output of these

rules...
Example Speed Calculation

## How fast will I go if it is

o 65 F
o 25 % Cloud Cover ?
Fuzzification:
Calculate Input Membership Levels
65 F Cool = 0.4, Warm= 0.7
Freezing Cool Warm Hot
1

0
10 30 50 70 90 110
Temp. (F)

## 25% Cover Sunny = 0.8, Cloudy = 0.2

Sunny Partly Cloudy Overcast
1

0
0 20 40 60 80 100
Cloud Cover (%)
...Calculating...
If it's Sunny and Warm, drive Fast
Sunny(Cover)Warm(Temp)Fast(Speed)
0.8 0.7 = 0.7
Fast = 0.7

## If it's Cloudy and Cool, drive Slow

Cloudy(Cover)Cool(Temp)Slow(Speed)
0.2 0.4 = 0.2
Slow = 0.2
Defuzzification: Constructing the Output

## Speed is 20% Slow and 70% Fast

Slow Fast
1

0
0 25 50 75 100
Speed (mph)
Find centroids: Location where membership is 100%
Defuzzification: Constructing the Output

Fast
70% Fast
Slow
1

0
0 25 50 75 100
Speed (mph)

## Find centroids: Location where membership is 100%

100% Slow = 25
100% Fast = 75
Defuzzification: Constructing the Output

Slow Fast
1

0
0 25 50 75 100
Speed (mph)

Slow Fast
1

0
0 25 50 75 100
Speed (mph)

## Speed = weighted mean

= (20*25+70*75)/(20 + 70)
= 63.8 mph
Rule Base
Air Temperature Fan Speed

## Set cold {50, 0, 0} Set stop {0, 0, 0}

Set cool {65, 55, 45} Set slow {50, 30, 10}
Set just right {70, 65, 60} Set medium {60, 50, 40}
Set warm {85, 75, 65} Set fast {90, 70, 50}
Set hot {, 90, 80} Set blast {, 100, 80}
Rules
Air Conditioning Controller Example:

## IF Cold then Stop

If Cool then Slow
If OK then Medium
If Warm then Fast
IF Hot then Blast
Fuzzy Air Conditioner
0

100
s t If Hot
90 Bla then
Blast

80 Fa
st If Warm
then
70 Fast

60
Med If Just Right
ium then
50 Medium

40 IF Cool
Sl
ow then
30 Slow

if Cold
20
then Stop

10
St
o p

1
m

t
l

Ho
o

ar
Co

W
Co

Rig t
ht
Jus
ld

45 50 55 60 65 70 75 80 85 90
Mapping Inputs to Outputs
Defuzzification
After the inference step, the overall result is a fuzzy value. This result
should be defuzzified to obtain a final crisp output. This is the purpose
of the defuzzifier component of a FLS. Defuzzification is performed
according to the membership function of the output variable. For
instance, assume that we have the result in Figure 5 at the end of the
inference. In this figure, the shaded areas all belong to the fuzzy
result. The purpose is to obtain a crisp value, represented with a dot
in the figure, from this fuzzy result
Average maximum
First maximum
Last maximum
u udu Center of gravity
u0 U
u du
U
Defuzzification algorithms
Temperature controller
Having the value of the temperature in the room we
switch on or switch off the fan.
Fuzzy controller
Inference rules

## IF temperature IS cold THEN fan_speed IS high

IF temperature IS cool THEN fan_speed IS medium
IF temperature IS warm THEN fan_speed IS low
IF temperature IS hot THEN fan_speed IS zero
How the controller works ?

## Input: temerature (e.g. 78 oF) which mean

warm (as 0.6, 60%) and hot (as 0.2, 20%)

## Fuzzyfication: compute the fuzzy value of the

parameter, evaluate the rules.
Only two given rules may be activated.
Activating rule nr 3 the value of fan_speed
means low and is set on 0.6
Activating rule nr 4 the value of fan_speed
means zero and is set on 0.2

## Defuzzyfication: Represent the output value

in the natural language.
Values 60% and 20% are connected using
Center of Gravity (COG)) method and
calculated as 13.5 RPM
Fuzzy inference rules (mamdami)

## The example of the insurance company

1.if driver young and car power high then risk high
2.if driver young and car power average then risk high
3.if driver medium and car power high then risk average
4.if driver medium and car power average then risk low
Age of the driver Car power
1,2
1,2
1
1
young 0,8 small
0,8
medium 0,6 average
0,6
old high
0,4 0,4

0,2 0,2
0 0
20 30 40 50 60 20 70 120 170 220

## Driver ={young, medium,old } assurance risk

1,2
Car power = {small,average,high}
1
risk = {low, average, high}
0,8 low
average
0,6
high
0,4

0,2

0
0 5 10 15 20 25 30 35 40
Age of a driver

## Age of the driver

1,2

0,8 young
medium
0,6 old

0,4

0,2

0
20 30 40 50 60
Car power

Car power

1,2

0,8 small
average
0,6
high
0,4

0,2

0
20 70 120 170 220
Insurance company risk low

average

high

assurance risk

1,2

0,8
low
average
0,6
high

0,4

0,2

0
0 5 10 15 20 25 30 35 40
Fuzzy inference rules (mamdami)

## Age of the driver Car power assurance risk

1,2
1,2
1,2 1
1
1 small low
young 0,8 0,8
0,8 average average
medium 0,6 0,6
0,6 high
old 0,4 0,4 high
0,4
0,2
0,2
0,2 0
0 0
20 70 120 170 220
20 30 40 50 60 0 5 10 15 20 25 30 35 40

## RULES 1st with degree min(0.2,0.92) = 0.2

Driver age= 38 2nd with degree min(0.2,0.08) = 0.08
Car power = 166 3th with degree min(0.8,0.92) = 0.8
4th with degree min(0.8,0.08) = 0.08
KM
We find rules to activate

1.if driver young and car power high then risk high
2.if driver young and car power average then risk high
3.if driver medium and car power high then risk average
4.if driver medium and car power average then risk low

## We choose the MIN

value in each rule
We find rules to activate

1.if driver young and car power high then risk high
2.if driver young and car power average then risk high
3.if driver medium and car power high then risk average
4.if driver medium and car power average then risk low

## 2 rules with the

same decision but
different values.
We find rules to activate

1.if driver young and car power high then risk high
2.if driver young and car power average then risk high
3.if driver medium and car power high then risk average
4.if driver medium and car power average then risk low
2 rules with the
same decision but
different values.
So we have to
choose one decision
by calculation MAX
value
We find rules to activate
We find rules to activate
defuzzification
Center of gravity

Mean of maximum

First maximum

Last maximum
Fuzzy inference rules (mamdami)

## Risk is High with degree = max(0.2,0.08) = 0.2

Average with degree = 0.8
low with degree 0.08

## Risk value as a center of gravity:

Fuzzy inference rules (mamdami)

## Risk is High with degree = max(0.2,0.08) = 0.2

Average with degree = 0.8
low with degree 0.08

Mean maximum
20

high
First maximum
17,5

high
Last maximum
22,5

## Average Average high

high
Notes: Drawbacks to Fuzzy logic
Requires tuning of membership functions

complex problems

## Deals with imprecision, and vagueness, but not

uncertainty
CONCLUSION
Fuzzy logic provides an alternative way to represent
linguistic and subjective attributes of the real world
in computing.

## It is able to be applied to control systems and other

applications in order to improve the efficiency and
simplicity of the design process.