Fuzzy Control

Post on 17-Feb-2016

36 views 1 download

Tags:

description

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. Fuzzy Logic Process. - PowerPoint PPT Presentation

transcript

Fuzzy ControlLect 4 Fuzzy Logic ProcessBasil HamedElectrical Engineering Islamic University of Gaza

ContentsFuzzy Logic ProcessFuzzificationFuzzy Associate Memory(FAM)DefuzzificationExamples

Basil Hamed 2

Fuzzy Logic ProcessIt 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 ProcessIn 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

Basil Hamed 5

“Crisp” Input Fuzzification

“Fuzzy” Input

Fuzzy Logic-or-

F.A.M.

“Fuzzy” Output

De-Fuzzification “Crisp” Output

Basil Hamed 6

Fuzzy Systems

Basil Hamed 7

Fuzzy Knowledge base

Input Fuzzification InferenceEngine DefuzzificationOutput

Fuzzification

Fuzzification

Basil Hamed 9

Fuzzy Knowledge base

Fuzzy Knowledge base

I nput Fuzzifi er I nferenceEngine Defuzzifier OutputI nput Fuzzifi er I nferenceEngine Defuzzifier Output

Converts the crisp input to a linguistic variable using the membership functions stored in the fuzzy knowledge base.

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

FuzzificationDetermine degree of membership of sensor reading

IF Close-by(right-sensor) THEN Left

Get value of sensor right-sensorFind membership value of value in fuzzy set Close-byThis value determines activation of this rule

Basil Hamed 11

FuzzificationWe 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

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

How tall is Kevin?

Basil Hamed 14

Fuzzification Rules

0

0.25

0.5

0.75

1

2 3 4 5 6 7 8

Input (feet)

Deg

ree

of M

embe

rshi

p

Very ShortShortAverageTallVery Tall

Basil Hamed 15

Some Examples:If you are 5 feet:

Very tall - 0%Tall - 0%Average - 100%Short - 0%Very Short - 0%

Same as Boolean logic (so far…)

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

Basil Hamed 16

Examples:

If you are 5½ feet:• Very tall - 0%• Tall - 50%• Average - 50%• Short - 0%• Very Short - 0%NOT Boolean logic

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

Basil Hamed 17

How tall is Kevin?

• Very Tall -• Tall -• Average -• Short -• Very Short -

Kevin is 6’ 2”

Basil Hamed 18

How tall is Kevin?

• Very Tall -• Tall -• Average -• Short -• Very Short -

• Very Tall - 25%• Tall - 75%• Average - 0%• Short - 0%• Very Short - 0%

Kevin is 6’ 2”

Basil Hamed 19

FuzzificationEstablishes 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

Basil Hamed 21

Input_1 Fuzzy IF-THENRules OutputInput_2

Input_3

Inference Engine

Basil Hamed 22

Fuzzy Knowledge base

Fuzzy Knowledge base

I nput Fuzzifi er I nferenceEngine Defuzzifier OutputI nput Fuzzifi er I nferenceEngine Defuzzifier Output

Using If-Then type fuzzy rules converts the fuzzy input to the fuzzy output.

Inference EngineFuzzy 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 23

InferenceEvaluates 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 24

Graphical Technique of Inference

Basil Hamed 25

Graphical Technique of InferenceExample:Rule 1: if x1 is and x2 is , then y is Rule 2: if x1 is or x2 is , then y is input(i) = 0.35 input(j) = 55

1

1~A 1

2~A

~

1B2

1~A 2

2~A

~

2B

Basil Hamed 26

CompositionCombines 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

Basil Hamed 37

“Crisp” Input Fuzzification

“Fuzzy” Input

Fuzzy Logic-or-

F.A.M.

“Fuzzy” Output

De-Fuzzification “Crisp” Output

Fuzzy Associative Memory (FAM)

Fuzzy Associative MemoryIt is a Fuzzy Truth TableShows all possible outputs for all possible inputsEasy 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

200nx1 5 01 0 05 00

1 L ig h t M ed iu m Heav y

Tra f f ic de n s it y

40ny3 02 01 00

1 M ed iu mS h o r t L o n g

G re e n lig h t du ra t io n

Basil Hamed 40

Three possible fuzzy subsets of traffic-density and green light duration, space X and Y.

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 … knBasil 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

B B1 B5

Output: C C1 C4

Basil Hamed 42

l = k1 k2 = 7*5=35 rules

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 z4. IF x1 is NS, THEN y is NB

FAM for the four simple rules

x1 N B N S z P S P B

y z N B z P B z

Basil Hamed 44

Fuzzy Logic Process

Basil Hamed 45

“Crisp” Input Fuzzification

“Fuzzy” Input

Fuzzy Logic-or-

F.A.M.

“Fuzzy” Output

De-Fuzzification “Crisp” Output

Defuzzification(Fuzzy-To-Crisp conversions)

Using fuzzy to reason, to modelUsing crisp to actLike analog digital analog

Defuzzification is the process: round it off to the nearest vertex.

Fuzzy set (collection of membership values).Basil Hamed 46

DefuzzificationConvert 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

DefuzzificationConverts 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

Fuzzy Knowledge base

Fuzzy Knowledge base

I nput Fuzzifier I nferenceEngine Defuzzifier OutputI nput Fuzzifier I nferenceEngine Defuzzifier Output

Defuzzification

Basil Hamed 50

Fuzzy Knowledge base

Fuzzy Knowledge base

I nput Fuzzifi er I nferenceEngine Defuzzifier OutputI nput Fuzzifi er I nferenceEngine Defuzzifier Output

Defuzzification

( ),

( )

AZ

COAA

Z

z zdzz

z dz

Basil Hamed 51

Fuzzy Knowledge base

Fuzzy Knowledge base

I nput Fuzzifi er I nferenceEngine Defuzzifier OutputI nput Fuzzifi er I nferenceEngine Defuzzifier Output

( ) ( ) ,BOA

BOA

z

A Az

z dz z dz

*

,

{ ; ( ) }

ZMOM

Z

A

zdzz

dz

where Z z z

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:

b

aA

b

aA

dxx

dxxxCOG

Centroid

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.0

0.2

0.4

0.6

0.8

160 170 180 190 200

a b

210

A

150X

Centre of gravity (COG):4.67

5.05.05.05.02.02.02.02.01.01.01.05.0)100908070(2.0)60504030(1.0)20100(

COG

1.0

0.0

0.2

0.4

0.6

0.8

0 20 30 40 5010 70 80 90 10060Z

Degree ofMembership

67.4

Centroid

Basil Hamed 55

Defuzzification Methods

Max-membership principle

c(Z*) c(z) z Z

z* z

1

Centroid principle

dz)z(zdz)z(z

c

c*

z* z

1

Basil Hamed 56

Defuzzification Methods

Weighted average method(Only valid for symmetrical output membership functions)

)z(z)z(

z~

~

c

c*

0 a b z

.9

.5

Basil Hamed 57

Produces results very close to centroid methodLess computational intensive

Formed by weighting each functions in the output by its respective maximum membership value

Defuzzification Methods

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

2baz* 0 a z* b z

1

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 , 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 , 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

3~2~1~BandB,B

3~2~1~BandB,B

Basil Hamed 59

Defuzzification Methods

Basil Hamed 60

Defuzzification Methods

meters

dzzdzdzzdzdzzdzdzz

zdzzzdzzdzzzdzzdzzdzzzdzz

dzz

zdzzz

B

B

9.4

)8()5()5(.2

3)3(.3.

85)5(.2

3)3(.)3(.

)(

)(

1

0

6.3

1

4

6.3

5.5

4

6

5.5

7

6

8

7

1

0

6.3

1

4

6.3

5.5

4

6

5.5

7

6

8

7

*

~

~

Centroid method:

Basil Hamed 61

Defuzzification Methods

Weighted-Average Method: metersz 41.5

15.3.5.6155.5.23.*

Mean-Max Method: meters5.62/)76(

Basil Hamed 62

Basil Hamed 63

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.

Defuzzification Methods

Basil Hamed 64

Defuzzification Methods

Basil Hamed 65

Defuzzification Methods

According to the centroid method,

5.2

5.5.25.5.

3)1(67.267.

5.5.25.5.

3167.2)67(.

)(

)(

5

3

3

33.2

33.2

2

2

8.1

8.1

5.1

5.1

0

5

3

3

33.2

33.2

2

2

8.1

8.1

5.1

5.1

0

*

~

~

dzzdzz

dzzdzzdzzdzz

zdzzzdzz

zdzzzdzzzdzzzdzz

dzz

zdzzz

B

B

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:

25.2111

31215.11*

z

Basil Hamed 68

Basil Hamed 69

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

Defuzzification Methods

Defuzzification Methods

Center of sums Method

Faster than any defuzzification methodInvolves algebraic sum of individual output fuzzy sets, instead of their unionDrawback: intersecting areas are added twice.

It is similar to the weighted average method, but the weights are the areas, instead of individual membership values.

z

n

k C

z

n

k C

dzz

dzzzz

k

k

1

1*

~

~

Basil Hamed 70

Basil Hamed 71

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

Defuzzification Methods

Basil Hamed 72

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)

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 Examplesuppose 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 parameterstempwind_speed

we have one output parameterchange_in_valve

Basil Hamed 81

Solar Pool Heater Exampleset up membership functions for the inputs

for each input, decide on how many categories there will be and decide on their membership functions

Basil Hamed 82wind_speed

calm

brisk strong

temp

coldcool

nominalwarmhot

4 12 20 mph 60 70 80 90 100 °F

calm brisk strong

Solar Pool Heater Exampleset up membership functions for the output(s)

for each output, decide on how many categories there will be and decide on their membership functions

Basil Hamed 83change_in_valve

bigneg. small

neg.

nochange

smallpos. big

pos.

-10 -5 0 5 10 degrees

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

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

Basil Hamed 85wind_speed = 9 mph

calm

brisk strong

temp = 87°F

coldcool

nominalwarmhot

4 12 20 mph 60 70 80 90 100 °F

calm brisk strong

00

0.350

0.60.4

0.55 0

Solar Pool Heater Example

fire the rulesif (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) 86

0 0.4

0

0.55

0.6 0.55

0.35 0.6

coldcool

nominalwarmhot

calm

brisk strong

0.6

0

00.35

00.6

0.40.55 0

Solar Pool Heater Example

fire the rulesif (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 87

0 0.4

0

0.55

0.6 0.55

0.35 0.6

0.6

bigneg. small

neg.

nochange

smallpos. big

pos.0

0.550.6 0

0

Solar Pool Heater Example

defuzzify the output(s)

Basil Hamed 88

bigneg. small

neg.

nochange

smallpos. big

pos.0

0.550.6 0

0

.55

.6

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

Due 16/10/2011Good Luck

Basil Hamed 89