Fuzzy Control: Lect 4 Fuzzy Logic Process

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 89

Fuzzy Control

Lect 4 Fuzzy Logic Process


Basil Hamed
Electrical Engineering
Islamic University of Gaza
Contents
Fuzzy Logic Process
Fuzzification
Fuzzy Associate Memory(FAM)
Defuzzification
Examples

Basil Hamed 2
Fuzzy Logic Process
It is one thing to compute, to reason, and to model with
fuzzy information; it is another to apply the fuzzy results
to the world around us.
Despite the fact that the bulk of the information we
assimilate every day is fuzzy, most of the actions or
decisions implemented by humans or machines are
crisp or binary.
The decisions we make that require an action are
binary, the hardware we use is binary, and certainly the
computers we use are based on binary digital
instructions.

Basil Hamed 3
Fuzzy Logic Process
In giving instructions to an aircraft
autopilot, it is not possible to turn the
plane slightly to the west; an autopilot
device does not understand the natural
language of a human. We have to turn the
plane by 15 , for example, a crisp number.

Basil Hamed 4
Fuzzy Logic Process
Crisp Input Fuzzification
Fuzzy Input

Fuzzy Logic
-or-
F.A.M.

Fuzzy Output
De-Fuzzification Crisp Output
Basil Hamed 5
Basil Hamed 6
Fuzzy Systems

Inference
Input Fuzzification Defuzzification Output
Engine

Fuzzy
Knowledge base

Basil Hamed 7
Fuzzification
Fuzzification
Inference
Input Fuzzifier Defuzzifier Output
Engine

Fuzzy
Knowledge base

Converts the crisp input to a linguistic


variable using the membership functions
stored in the fuzzy knowledge base.

Basil Hamed 9
FUZZIFICATION

Fuzzification is the process of making a crisp quantity


fuzzy.

In the real world, hardware such as a digital voltmeter


generates crisp data, but these data are subject to
experimental error.

Basil Hamed 10
Fuzzification
Determine degree of membership of sensor reading

IF Close-by(right-sensor) THEN Left

Get value of sensor right-sensor


Find membership value of value in fuzzy set Close-by
This value determines activation of this rule

Basil Hamed 11
Fuzzification
We use Fuzzy Logic to combine predicates

IF Close-by(right-sensor) AND
FAR(goal-location)
THEN Left

We do this for all rules.


(normally some would get activation 0)

Basil Hamed 12
How tall is Kevin?
Very Tall?
Tall?
Average?
Short?
Very Short?

Basil Hamed 13
How tall is Kevin?

Very Tall (7 feet)?


Tall (6 feet)?
Average (5 feet)?
Short (4 feet)?
Very Short (3 feet)?

Basil Hamed 14
Fuzzification Rules

1
Degree of Membership

0.75 Very Short


Short
0.5 Average
Tall
0.25 Very Tall

0
2 3 4 5 6 7 8
Input (feet)

Basil Hamed 15
Some Examples:
If you are 5 feet:
Very tall - 0% Very Tall (7 feet)?
Tall - 0% Tall (6 feet)?
Average - 100% Average (5 feet)?
Short - 0% Short (4 feet)?
Very Short - 0% Very Short (3 feet)?
Same as Boolean
logic (so far)

Basil Hamed 16
Examples:

If you are 5 feet:


Very tall - 0% Very Tall (7 feet)?
Tall - 50% Tall (6 feet)?
Average - 50% Average (5 feet)?
Short - 0% Short (4 feet)?
Very Short - 0% Very Short (3 feet)?
NOT Boolean logic

Basil Hamed 17
How tall is Kevin?
Kevin is 6 2
Very Tall -
Tall -
Average -
Short -
Very Short -

Basil Hamed 18
How tall is Kevin?

Kevin is 6 2
Very Tall - 25%
Tall - 75%
Average - 0%
Short - 0%
Very Short - 0%

Basil Hamed 19
Fuzzification
Establishes the fact base of the fuzzy system. It identifies
the input and output of the system, defines appropriate IF
THEN rules, and uses raw data to derive a membership
function.
Consider an air conditioning system that determine the best
circulation level by sampling temperature and moisture
levels. The inputs are the current temperature and moisture
level. The fuzzy system outputs the best air circulation level:
none, low, or high. The following fuzzy rules are used:
1. If the room is hot, circulate the air a lot.
2. If the room is cool, do not circulate the air.
3. If the room is cool and moist, circulate the air slightly.
A knowledge engineer determines membership functions that
map temperatures to fuzzy values and map moisture
measurements to fuzzy values.
Basil Hamed 20
Fuzzy Inference (Expert) Systems

Input_1 Fuzzy
IF-THEN
Input_2 Output
Rules
Input_3

Basil Hamed 21
Inference
Input Fuzzifier Defuzzifier Output
Engine

Inference Engine
Fuzzy
Knowledge base

Using If-Then type fuzzy rules converts the


fuzzy input to the fuzzy output.

Basil Hamed 22
Inference
Evaluates all rules and determines their truth
values.

Continuing the example, suppose that the system has


measured temperature and moisture levels and mapped
them to the fuzzy values of .7 and .1 respectively. The
system now infers the truth of each fuzzy rule. To do this
a simple method called MAX-MIN is used. This method
sets the fuzzy value of the THEN clause to the fuzzy value
of the IF clause. Thus, the method infers fuzzy values of
0.7, 0.1, and 0.1 for rules 1, 2, and 3 respectively.

Basil Hamed 23
Inference Engine
Fuzzy rules
based on fuzzy premises and fuzzy
consequences

e.g.
If height is Short and weight is Light then
feet are Small
Short( height) AND Light(weight) =>
Small(feet)
Basil Hamed 24
Graphical Technique of Inference

Basil Hamed 25
Graphical Technique of Inference
Example: 1 1 1
A A
Rule 1: if x1 is ~ 1 and x2 is ~ 2 , then y is ~ B
2 2 2
A A B
Rule 2: if x1 is ~ 1 or x2 is ~ 2 , then y is ~
input(i) = 0.35 input(j) = 55

Basil Hamed 26
Composition
Combines all fuzzy conclusions obtained by inference
into a single conclusion. Since different fuzzy rules
might have different conclusions, consider all rules.

Continuing the example, each inference suggests a different


action
rule 1 suggests a "high" circulation level
rule 2 suggests turning off air circulation
rule 3 suggests a "low" circulation level.

A simple MAX-MIN method of selection is used where the


maximum fuzzy value of the inferences is used as the final
conclusion. So, composition selects a fuzzy value of 0.7 since
this was the highest fuzzy value associated with the inference
conclusions.
Basil Hamed 27
Fuzzy Logic Rule Base

Basil Hamed 28
Remarks

Basil Hamed 29
Fuzzy Logic Rule Base

Basil Hamed 30
Fuzzy Logic Rule Base

Basil Hamed 31
Fuzzy Logic Rule Base

Basil Hamed 32
EXAMPLE

Basil Hamed 33
EXAMPLE

Basil Hamed 34
Fuzzy Logic Rule Base

Basil Hamed 35
Fuzzy Logic Rule Base

Basil Hamed 36
Fuzzy Logic Process
Crisp Input Fuzzification
Fuzzy Input

Fuzzy Logic
-or-
F.A.M.

Fuzzy Output
De-Fuzzification Crisp Output
Basil Hamed 37
Fuzzy Associative Memory (FAM)
Fuzzy Associative Memory
It is a Fuzzy Truth Table
Shows all possible outputs for all possible inputs
Easy to create!
Fuzzy associative memories are transformations
FAM map fuzzy sets to fuzzy sets, units cube to units cube.

Basil Hamed 39
FAMs as mapping

Light Medium Heavy Short Medium Long


1 1

0
0 10 20 30 yn 40
50 100 150 xn 200 Green light duration
Traffic density

Three possible fuzzy subsets of traffic-density and


green light duration, space X and Y.

Basil Hamed 40
Fuzzy Associative Memories (FAMs)

A fuzzy system with n non-interactive inputs and a single


output. Each input universe of discourse, x1, x2, , xn is
partitioned into k fuzzy partitions
The total # of possible rules governing this system is given
by: l = kn
If x1 is partitioned into k1 partitions
x2 is partitioned into k2 partitions
:
.
xn is partitioned into kn partitions
l = k1 k2 kn

Basil Hamed 41
Fuzzy Associative Memories (FAMs)

Example: for n = 2
A1 A2 A3 A4 A5 A6 A7
B1 C1 C4 C4 C3 C3
B2 C1 C2
B3 C4 C1 C1 C2
B4 C3 C3 C1 C1 C2
B5 C3 C4 C4 C1 C3

A A1 A7
l = k1 k2 = 7*5=35 rules
B B1 B5
Output: C C1 C4

Basil Hamed 42
Fuzzy Associative Memories (FAMs)

Example:
Non-linear membership function: y = 10 sin x

Basil Hamed 43
Fuzzy Associative Memories (FAMs)

Few simple rules for y = 10 sin x


1. IF x1 is Z or P B, THEN y is z.
2. IF x1 is PS, THEN y is PB.
3. IF x1 is z or N B, THEN y is z
4. IF x1 is NS, THEN y is NB

FAM for the four simple rules

x1 NB NS z PS PB
y z NB z PB z

Basil Hamed 44
Fuzzy Logic Process
Crisp Input Fuzzification
Fuzzy Input

Fuzzy Logic
-or-
F.A.M.

Fuzzy Output
De-Fuzzification Crisp Output
Basil Hamed 45
Defuzzification
(Fuzzy-To-Crisp conversions)

Using fuzzy to reason, to model


Using crisp to act
Like analog digital analog
Defuzzification is the process: round it off to the nearest
vertex.

Fuzzy set (collection of membership values).

Basil Hamed 46
Defuzzification
Convert the fuzzy value obtained from
composition into a crisp value. This process is
often complex since the fuzzy set might not
translate directly into a crisp value. Defuzzification
is necessary, since controllers of physical systems
require discrete signals.
Defuzzification is the conversion of a fuzzy quantity to
a precise quantity, just as fuzzification is the
conversion of a precise quantity to a fuzzy quantity.
The output of a fuzzy process can be the logical union
of two or more fuzzy membership functions defined on
the universe of discourse of the output variable.
Basil Hamed 47
DEFUZZIFICATION
Defuzzification strategy is aimed at producing a non-fuzzy
control action, or can say defuzzification means the
conversion of the fuzzy output values into crisp values. For
example, if we say "the output force must be large" and large
variable takes the values between (70, 90) N, then what is the
force will be needed 75 or 80 or N, we can know what is
the force we want by using defuzzification method. There are
different types of defuzzification methods.

Basil Hamed 48
Inference
Input Fuzzifier Defuzzifier Output
Engine

Defuzzification
Fuzzy
Knowledge base

Converts the fuzzy output of the inference


engine to crisp using membership functions
analogous to the ones used by the fuzzifier.
Some commonly used defuzzifying methods:
Centroid of area (COA)
Weighted average method
Mean of maximum (MOM)
Smallest of maximum (SOM)

Basil Hamed 49
Inference
Input Fuzzifier Defuzzifier Output
Engine

Defuzzification
Fuzzy
Knowledge base

Basil Hamed 50
Inference
Input Fuzzifier Defuzzifier Output
Engine

Defuzzification
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 ) *}
Basil Hamed 51
Centroid
It finds the point where a vertical line would
slice the aggregate set into two equal masses.
Mathematically this centre of gravity (COG) can
be expressed as:

x x dx
A

COG a
b

x dx
a
A
Centroid defuzzification method finds a point
representing the centre of gravity of the fuzzy
set, A, on the interval, ab.
A reasonable estimate can be obtained by
calculating it over a sample of points.
(x)
1.0
0.8

0.6 A

0.4
0.2
a b
0.0 X
150 160 170 180 190 200 210
Centre of gravity (COG):
(0 10 20) 0.1 (30 40 50 60) 0.2 (70 80 90 100) 0.5
COG 67.4
0.1 0.1 0.1 0.2 0.2 0.2 0.2 0.5 0.5 0.5 0.5

Degree of
Membership
1.0

0.8
0.6
0.4

0.2
0.0
0 10 20 30 40 50 60 70 80 90 100
67.4 Z
Centroid

Basil Hamed 55
Defuzzification Methods

Max-membership principle

1
c(Z*) c(z) z Z

z* z

Centroid principle

1
c ( z ) zdz
z
*

c ( z )dz

z* z

Basil Hamed 56
Defuzzification Methods

Weighted average method


(Only valid for symmetrical output membership functions)

c ( z ) z .9
z
* ~

c ( z ) .5
~

0 a b z

Formed by weighting each functions in the output by its


respective maximum membership value

Produces results very close to centroid method


Less computational intensive
Basil Hamed 57
Defuzzification Methods


Mean-max membership
(middle-of-maxima method)
1

z* a b 2
0 a z* b z

Basil Hamed 58
Defuzzification Methods

Example 4.3:
A railroad company intends to lay a new rail line in a particular part of a
county. The whole area through which the new line is passing must be
purchased for right-of-way considerations. It is surveyed in three stretches,
and the data are collected for analysis. The surveyed data for the road are
given by the sets B~ 1,B~ 2 and B~ 3 , where the sets are defined on the universe of
right-of-way widths, in meters. For the railroad to purchase the land, it must
have an assessment of the amount of land to be bought. The three surveys
on the right-of-way width are ambiguous , however, because some of the
land along the proposed railway route is already public domain and will not
need to be purchased. Additionally, the original surveys are so old (circa
1860) that some ambiguity exists on the boundaries and public right-of-way
for old utility lines and old roads. The three fuzzy sets B~ 1,B~ 2 and B~ 3 , shown in
the figures below, represent the uncertainty in each survey as to the
membership of the right-of-way width, in meters, in privately owned land.
We now want to aggregate these three survey results to find the single most
nearly representative right-of-way width (z) to allow the railroad to make its
initial estimate
Basil Hamed 59
Defuzzification Methods

Basil Hamed 60
Defuzzification Methods

Centroid method:

z *

( z ) zdz
B
~

( z)dz
B
~

1 4 z 3

3.6 5.5 6 7 8
0 (. 3 z ) zdz 1 (. 3 z ) dz 3.6 2 4
zdz (. 5) zdz 5.5 z 5 zdz 6 zdz 7 8 z zdz

1 4 z 3
.3z dz (.3)dz
3.6 5.5 6 7 8
dz (.5)dz ( z 5)dz dz (8 z )dz
0 1 3.6
2 4 5.5 6 7

4.9meters

Basil Hamed 61
Defuzzification Methods

Weighted-Average Method:

z *

.3 2.5 .5 5 1 6.5
5.41meters
.3 .5 1

Mean-Max Method: (6 7) / 2 6.5meters

Basil Hamed 62
Defuzzification Methods

Example 4.4. Many products, such as tar, petroleum


jelly, and petroleum, are extracted from crude oil. In a
newly drilled oil well, three sets of oil samples are taken
and tested for their viscosity. The results are given in
the form of the three fuzzy sets B1, B2, and B3, all
defined on a universe of normalized viscosity, as shown
in Figures below. we want to find the most nearly
representative viscosity value for all three oil samples,
and hence find z for the three fuzzy viscosity sets.

Basil Hamed 63
Defuzzification Methods

Basil Hamed 64
Defuzzification Methods

Basil Hamed 65
Defuzzification Methods

According to the centroid method,

z *

( z ) zdz
B
~

( z)dz
B
~

1.5 (.67 z ) zdz 1.82 .67 z zdz 2 z 1zdz 2.33 3 z zdz


0 1.5 1.8 2
3
2.33 .5 z .5zdz 3 2.5 .5 z zdz
5

1.5 .67 z dz 1.82 .67 z dz 2 ( z 1)dz 2.33 3 z dz

3
0 1.5 1.8 2

2.33 .5 z .5dz 3 2.5 .5 z dz
5

2.5
Basil Hamed 66
Defuzzification Methods

The centroid value obtained, z*, is shown in the figure


below:

Basil Hamed 67
Defuzzification Methods

According to the weighted average method:

z *

11.5 1 2 1 3
2.25
111

Basil Hamed 68
Defuzzification Methods

Three other popular methods are available


because of their appearance in some
applications:(Hellendoorn and Thomas, 1993)
The Center of Sums,
Center of Largest Area,
First of Maxima Methods

Basil Hamed 69
Defuzzification Methods
Center of sums Method
Faster than any defuzzification method
Involves algebraic sum of individual output fuzzy sets,
instead of their union
Drawback: intersecting areas are added twice.

z C z dz
n
k 1

* z ~k
z
C z dz
n

z k 1 ~k

It is similar to the weighted average method, but the


weights are the areas, instead of individual membership
values. Basil Hamed 70
Defuzzification Methods

Center of largest area: If the output fuzzy set has at least


two convex sub regions, then the center of gravity (i.e., z
is calculated using the centroid method) of the convex
fuzzy sub region with the largest area is used to obtain
the defuzzified value z of the output

Basil Hamed 71
First (or last) of maxima: This method uses the overall
output or union of all individual output fuzzy sets Ck to
determine the smallest value of the domain with
maximized membership degree in Ck.

See Examples 4.5, and 4.6( Page 108)

Basil Hamed 72
Picking a Method

Which of these methods is the right one?


There's no simple answer. But if you want to
get started quickly, generally the centroid
method is good enough. Later you can always
change your defuzzification method to see if
another method works better.

Basil Hamed 73
EXAMPLES
EXAMPLE 1

Basil Hamed 75
EXAMPLE 1

Basil Hamed 76
EXAMPLE 1

Basil Hamed 77
EXAMPLE 1

Basil Hamed 78
EXAMPLE 1

Basil Hamed 79
EXAMPLE 1

Basil Hamed 80
Solar Pool Heater Example
suppose we measure the pool water temp and the
wind speed and we want to adjust the valve that
sends water to the solar panels

we have two input parameters


temp
wind_speed

we have one output parameter


change_in_valve

Basil Hamed 81
Solar Pool Heater Example
set up membership functions for the inputs
for each input, decide on how many categories there will be
and decide on their membership functions
cold
nominal warm
cool hot calm
strong
brisk

calm brisk strong

60 70 80 90 100 F 4 12 20 mph

temp Basil Hamed wind_speed 82


Solar Pool Heater Example
set up membership functions for the output(s)
for each output, decide on how many categories there will be
and decide on their membership functions
big no small
neg. small change pos. big
neg. pos.

big neg sm. neg. no ch. sm. pos. Big pos.

-10 -5 0 5 10 degrees

change_in_valve
Basil Hamed 83
Solar Pool Heater Example

set up the rules

if (temp is hot) AND (wind_speed is calm)


then (change_in_valve is big_negative)

if (temp is warm) AND (wind_speed is brisk)


then (change_in_valve is small_negative)

if (temp is nominal) OR (temp is warm)


then (change_in_valve is no_change)

Basil Hamed 84
Solar Pool Heater Example
Fuzzify the inputs

cold
nominal warm
0 cool hot calm
0.35 0.6
strong
0 0 0.4 brisk
0.55 0

calm brisk strong

60 70 80 90 100 F 4 12 20 mph

temp = 87F Basil Hamed wind_speed = 9 mph 85


Solar Pool Heater Example
cold
nominal warm
0 cool hot
0.35 0.6
0 0
fire the rules
0 0.4
if (temp is hot) AND (wind_speed is calm)
then (change_in_valve is big_negative)
0.6 0
0.55
if (temp is warm) AND (wind_speed is
calm
brisk) then (change_in_valve is
strong
small_negative) 0.55 0.4 brisk
0.35 0.6 0.55 0

if (temp is nominal) OR (temp is warm)


then (change_in_valve is no_change) 86
0.6
Solar Pool Heater Example
big no small
neg. small change pos. big
neg. pos.
0 0.6 0
0.55 0
Fire the rules
0 0.4
if (temp is hot) AND (wind_speed is calm)
then (change_in_valve is big_negative)
0
0.6 0.55
if (temp is warm) AND (wind_speed is brisk)
then (change_in_valve is small_negative)
0.55
0.35 0.6
if (temp is nominal) OR (temp is warm)
then (change_in_valve is no_change)
Basil Hamed 0.6 87
Solar Pool Heater Example
big no small
neg. small change pos. big
neg. pos.
Defuzzify the output(s) 0 0.6 0
0.55 0

.6
.55

Basil Hamed 88
HW 3
4.9, 4.10, 5.12, 6.1, 6.4
In Problem 4.9, and 4.10 use any 3
methods for defuzzification.

Due 13/11/2012
Good Luck

Basil Hamed 89

You might also like