lectures 4&5: fuzzy rules and fuzzy reasoning

104
In the Name of God Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Upload: others

Post on 01-Nov-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

In the Name of God

Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Page 2: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Outline

▫ Extension principle▫ Fuzzy relations▫ Fuzzy if-then rules▫ Compositional rule of inference▫ Fuzzy reasoning

Page 3: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Why fuzzy rules?y y

▫ Fuzzy rules and fuzzy reasoning are the y y gbackbone of fuzzy inference systems

▫ Fuzzy inference systems are the most important d li t l i thi fi ldmodeling tool in this field

▫ They have been successfully applied to many applications such asapplications such as automatic control expert systems pattern recognition data classification …

Page 4: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Extension Principle

▫ It provides general procedure for extending crisp g gdomains of mathematical expressions to fuzzy domainsit li i t t i t i f f ti▫ it generalizes point-to-point mapping of a function f(.) to a mapping between fuzzy sets

Page 5: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Extension Principle

A is a fuzzy set on X :A is a fuzzy set on X :A x x x x x xA A A n n ( ) / ( ) / ( ) /1 1 2 2

The image of A under f(.) is a fuzzy set B:

1 1 2 2( ) ( ) / ( ) / ( ) /B B B n nB f A x y x y x y

where yi = f(xi), i = 1 to n.

If f(.) is a many-to-one mapping, then

B f Ay x( ) max ( )( )

1x f y( ) 1

Note that f(.) is a function from X to Y

Page 6: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

An example

▫ Let:▫ and ▫ Upon applying the extension principle, We have :

Page 7: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

An example with continuous universe

▫ Let:

▫ and

▫ It is many-to-one mapping for x in the range [-1,2]▫ So the membership grades for y in the range▫ So, the membership grades for y in the range

[-1,0] should be obtained by obtaining the maximums

▫ This causes discontinuity in the membership function of B

Page 8: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

An example with continuous universe

MAX

Page 9: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

General definition

• Suppose f is a mapping from n-D product space X1×…×Xn to a single universe Y such that f(x1,…,xn) = y

• There is a fuzzy set Ai in each Xi• Each element in an input vector (x x ) occurs• Each element in an input vector (x1,…,xn) occurs

simultaneously, which implies AND operator• The membership grade of fuzzy set B induced by the

mapping f should be the minimum of the membership graded of fuzzy set Ai’s.

Page 10: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

General definition

• The extension principle implies that fuzzy set B induced by the mapping f is defined by

• Note that this assumes that y = f(x1,…,xn) is a crisp function.

• In case where f is a fuzzy function we can employ the• In case where f is a fuzzy function, we can employ the compositional rule of inference (we will see it later on)

Page 11: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example

• Let:( ) 0.5 / 1 0.8 / 1( ) 0.3 / 1 1 / 0 0.7 / 1

A xB x

• and:: * , ( 1, 2) 1. 2f X X X f x x x x

• applying the extension principle (by applying the product instead of min):

( , ) 0.15 /1 0.5 / 0 0.35 / 1 0.24 / 1 0.8 / 0 0.56 /1(0.35 0.24) / 1 (0.5 0.8) / 0 (0.15 0.56) /10 35 / 1 0 8 / 0 0 56 /1

f A B

0.35 / 1 0.8 / 0 0.56 /1

Page 12: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Crisp Relations

• Crisp relation:▫ A crisp relation represents the presence or absence of

association, interaction or interconnectedness between the elements of two or more sets.

▫ Characteristic function of a relation:

Page 13: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Crisp Relations (Example)( )

Page 14: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Relationsy

• Binary fuzzy relations are fuzzy sets in X×Y mapping each element in X×Y to a membership grade between 0 and 1

• Unary fuzzy relations are fuzzy sets with 1D MFs• Unary fuzzy relations are fuzzy sets with 1D MFs• Binary fuzzy relations are fuzzy sets with 2D MFs• Many applications including fuzzy control and decision

making• Let us be restricted to binary fuzzy relations

Page 15: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Relationsy

• A fuzzy relation is a fuzzy set defined on the Cartesian product of crisp sets A1, A2, ..., An where tuples (x1, x2, ..., xn) may have varying degrees of membership within the relation.relation.

• The membership grade indicates the strength of the relation present between the elements of the tuple.

1 2

1 2 1 2 1 1 2 2

: ... [0,1](( , ,..., ), ) | ( , ,..., ) 0, , ,...,

R n

n R R n n n

A A AR x x x x x x x A x A x A

Page 16: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Relations

A fuzzy relation R is a 2D MF:

Example:

R x y x y x y X YR {(( , ), ( , ))| ( , ) }

p

It i b tt t h th f l ti l ti t iIt is better to show the fuzzy relation as a relation matrix:

Page 17: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Relations

• Example. The relation y >> x can be defined as:µ (y x)

.

)(10011

;0),(

2 yxxy

yxyxR

µ (y-x)R

• "x is A" AND "x is B" = "x is (A AND B)”"x is A" OR "x is B" = "x is (A OR B)”

)(1001 xyy - x

0

x is A OR x is B = x is (A OR B)

x x

"x is A" AND "y is B" = "(x,y) is A B”"x is A" OR "y is B" = "(x,y) is A Y X B"

x x

yB

A

y

A

B

Page 18: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Relations

Other common examples are:i l t ( d b )• x is close to y (x and y are numbers)

• x depends on y (x and y are events)• x and y look alike (x, and y are persons or objects)y ( , y p j )• If x is large, then y is small (x is an observed reading and y is a corresponding action)

Page 19: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Relations (Example)

Page 20: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Relations

• Representations of binary relation▫ Membership matrices▫ Membership matrices▫ Sagittal diagram

Page 21: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Relations

• The reverse of a fuzzy relation:

• For example:

600302.03.0

4.012.06.003.0

4.06.010 1 TRRR

Page 22: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy relation on a single set

• Representations of binary relations R(X,X):

Page 23: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Domain and range of fuzzy relation

• Domain: ( ) ( ) max ( , )dom R Ry Bx x y

• Range:y

( ) ( ) max ( , )ran R Rx Ay x y

( ) 1

( ) 2

( ) 1.0

( ) 0.4dom R

dom R

x

x

( ) 3

( ) 4

( ) 1.0

( ) 1.0dom R

dom R

x

x

( ) 5

( ) 6

( ) 0.5

( ) 0.2dom R

dom R

x

x

Page 24: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

More on fuzzy relations

• Various important types of binary fuzzy relations are distinguished on the basis of three different characteristic properties: reflexivity, symmetry, and transitivityand transitivity.

• A fuzzy relation R(X,X) is reflexive if and only if

R , 1 for all x x x X

Page 25: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

More on fuzzy relations

• A fuzzy relation R(X,X) is symmetric if and only if

• If it is not satisfied for some x yX then the

R R , , for all x y y x x X

• If it is not satisfied for some x,yX, then the relation is called asymmetric. If the equality is not satisfied for all members of the support of the relation, then the relation is called antisymmetric. If above equation is not satisfied for all x,yX, then R(X X) is called strictly antisymmetricthen R(X,X) is called strictly antisymmetric.

Page 26: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

More on fuzzy relations

• A fuzzy relation R(X,X) is transitive (or, more specifically, max-min transitive if and only if

2R R R, max min , , , for all ,x z x y y z x z X

• If this is not true for some members of X, R(X,X) is called nontransitive If the inequality of above

R R R , max min , , , for all ,y Y

x z x y y z x z X

is called nontransitive. If the inequality of above equation does not hold for all (x,z)X2, then R(X X) is called antitransitiveR(X,X) is called antitransitive.

Page 27: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Max-Min Composition

• The max-min composition of two fuzzy relations R1

(defined on X and Y) and R2 (defined on Y and Z) is

( , ) m ax m in[ ( , ), ( , )]R R R Rx z x y y z 1 2 1 2

1 2

( , ) [ ( , ), ( , )]

[ ( , ) ( , )]

R R R Ry

R Ry

y y

x y y z

• Properties:• Associativity: R S T R S T ( ) ( )

• Distributivity over union:

• Week distributivity over intersection:

R S T R S R T ( ) ( ) ( )

R S T R S R T ( ) ( ) ( )y

• Monotonicity:

( ) ( ) ( )

S T R S R T ( ) ( )

Page 28: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Max-Min Composition

• The max-min composition is associative and its inverse pis equal to the reverse composition of the inverse relations.

• However, it is not commutative.

Page 29: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example

• For example:

Page 30: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Max-Min Composition

• R1 and R2 are expressed as relation matrices• The calculation of R1 o R2 is almost the same as matrix

multiplication, except that × and + are replaced by ˄ and ˅ respectivelyand ˅, respectively.

• For this reason, the max-min composition is also called max-min product

• Although max-min composition is widely used, it is not easy to approach mathematically

• To have better mathematical tractability max-product• To have better mathematical tractability, max product composition can be alternatively used

Page 31: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Max-product Composition

• Max product composition:• Max-product composition:

1 2 1 2( , ) max[ ( , ). ( , )]R R R Ryx z x y y z

• In general, we have max-* composition:1 2

[ ( , ). ( , )]R Ryx y y z

In general, we have max composition: R R y R Rx z x y y z

1 2 1 2 ( , ) [ ( , ) * ( , )]

• where * is a T-norm operator.

Page 32: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example

• Let

• and

Page 33: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example

x y z

1 a0.40.9

0 2

x y z

2

3

b0.2

0.8

0.2

0.51 2

1 2

(2, ) 0.7 (max-min composition)

(2, ) 0.63 (max-product composition)R R

R R

a

a

3

0.9 0.7

Page 34: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Linguistic Variables (detailed description)

• A numerical variables takes numerical values:Age = 65

• A linguistic variables takes linguistic values:Age is oldg

• A linguistic value is a fuzzy set.• A linguistic variable is characterized by (x, T(x), X, M)• x: the name of the variable• x: the name of the variable• T(x): the term set of x, that is the set of all linguistic

values or linguistic termsX th i f di• X: the universe of discourse

• M: the semantic rule that associates with each linguistic value A its meaning M(A), where M(A) denotes a fuzzy set in X

Page 35: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Linguistic Variables (detailed description)

• T(age) = {young, not young, very young, middle aged,not middle aged, old, not old, very old, more or less old,not very young and not very old}

• The semantic rule defines the MFs• The semantic rule defines the MFs

Page 36: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Linguistic Values (Terms)g ( )

Page 37: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Linguistic Variable Modifiersg

• Modifiers (hedges) are words like "extremely", "very" which changes the predicate.

• For example, "It is cold today" becomes "It is very cold today“today .

• Some possible implementations of modifiers are: Very, somewhat, Not, positively, etc.

• CONcentration and DILution –transform original membership function µ(x) µn(x), n > 1 (concentration) and n < 1 (dilution).and n 1 (dilution).

Page 38: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Operations on Linguistic Valuesg

Concentration: CON A A( ) 2

D IL A A( ) . 0 5Dilation:

NOT, AND, OR:

Page 39: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Constructing composite linguistic termsg p g

• Let us suppose the X as [0,100] and define the MFs of old and young asold and young as

C it MF b t t d• Composite MFs can be constructed as

Page 40: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Operations on Linguistic Valuesg

Contrast intensification:2

2

2 , 0 ( ) 0.5( )

2( ) , 0.5 ( ) 1A

A

A xINT A

A x

Page 41: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Linguistic Variable Modifiers

• Examples: VERY (µ2(x)), EXTREMELY (µ3(x)), 0 5SOMEWHAT, MORE OR LESS (µ0.5(x))

µ (temperature)ld

cold

not cold

µ (temperature)cold

1

co dsomewhat coldvery cold

temperature

Page 42: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Linguistic Variable Modifiers

• INTensify – µint(x) =nn( x ); x A

1 nn( x ); x A

y µint( )

Aa = {x| µ(x) a} is the a-cut of µ(x). • For example, let n = 2, a = 0.5. The fuzzy sets Tall

1 n ( x ); x A

and POSITIVELY Tall are illustrated below:

1

0.5

positively tall

tall

Page 43: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Linguistic Variable Modifiersg

• AROUND, ABOUT, APPROXIMATE – Broaden µ(x).( )• BELOW, ABOVE – (see illustration below)

1below tall above talltall 1

tall

0.5 0.5about tall

tall tall

Page 44: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

OrthogonalityOrthogonality• A term set T = t1,…,tn for a linguistic variable x on the

universe X is orthogonal if:

• where ti’s are convex and normal fuzzy sets defined on iX that make up T

Page 45: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy If-Then RulesFuzzy If Then Rules

• Many of fuzzy applications are based on fuzzy y y pp yif-then rules

• It expresses what happen if a fuzzy set is true• The fuzzy sets and fuzzy rules combine to form

a fuzzy system. F l t ti t l• For example: automatic control

Page 46: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Rulesy

• Human knowledge builds fuzzy rules. ▫ Consider the decision to bring an umbrella to work

under the following circumstances: 70% chance of rain70% chance of rain. An umbrella keeps you dry. If it rains you will get wet. If you get wet you will be uncomfortable at work If you get wet, you will be uncomfortable at work. If you have an umbrella you will be dry.

▫ Through this knowledge, you reason to bring an b ll t kumbrella to work.

▫ The knowledge of the percentage of rain and what an umbrella is used for led you to make rules that guided u b e a s used o ed you to a e u es t at gu dedyou through your reasoning.

Page 47: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy If-Then RulesFuzzy If Then Rules

• General format:

If x is A then y is By

• Examples:▫ If pressure is high, then volume is small.▫ If the road is slippery, then driving is dangerous.

If t t i d th it i i▫ If a tomato is red, then it is ripe.▫ If the speed is high, then apply the brake a little.

Page 48: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy If-Then RulesFuzzy If Then Rules

Two ways to interpret “If x is A then y is B”:

A coupled with B A entails B

Two ways to interpret If x is A then y is B :

A coupled with B A entails Byy

B B

xxAA

xx

Page 49: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy If-Then RulesFuzzy If Then Rules• Two ways to interpret “If x is A then y is B”:▫ A coupled with B: (A and B)

R A B A B x y x yA B ( ) ( )|( , )~

▫ A entails B: (not A or B) Material implication:

y yA B ( ) ( )|( , )

ate a p cat o Propositional calculus: Extended propositional calculus: Generalization of modus ponens:

wherewhere

Page 50: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy If-Then RulesFuzzy If Then Rules• Although the four formulas are different, they all reduced to

the family identity A B == ̚ AUB when A and B arethe family identity A B == AUB when A and B are propositions in the sense of two-valued (0 or 1) logic

• Based on various fuzzy T-norm and T-conorm (S-norm), we may have the following for R = A B

• where f, called the fuzzy implication function, performs the rule task

Page 51: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy If-Then Rules (coupled)Fuzzy If Then Rules (coupled)• Mamdani type (min product):

• Larsen type (algebraic product):yp ( g p )

• Bounded product:

• Drastic product:

Page 52: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy If-Then RulesFuzzy If Then Rules• Fuzzy implication function:

x y f x y f a b( ) ( ( ) ( )) ( )

• A coupled with B

R A Bx y f x y f a b( , ) ( ( ), ( )) ( , )

Page 53: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy If-Then Rules (entails)Fuzzy If Then Rules (entails)• Zadeh’s arithmetic rule:

• Zadeh’s max-min rule :

f• Boolean fuzzy implication:

• Goguen’s fuzzy implication (algebraic product for T-norm):

Page 54: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy If-Then RulesFuzzy If Then Rules

A entails B

Page 55: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy reasoningy g

• Fuzzy reasoning (or approximate reasoning)Fuzzy reasoning (or approximate reasoning) is an inference procedure

• It derives conclusions from a set of fuzzy if-ythen rules and known facts

Page 56: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Compositional Rule of Inference

• Similar idea was used for max-min operationp• Suppose we have a curve y = f(x)• When we are given x = a, then we can infer that y = b = f(a)

A li i ld b ll i b i l d• A generalization would be allowing a to be an interval and f(x) to be an interval-values function

• We should first construct cylindrical extension of a andWe should first construct cylindrical extension of a and then find its intersection I with the interval-values curve

• The projection of I onto the y-axis yields the interval y = b

Page 57: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Compositional Rule of Inference

• Derivation of y = b from x = a and y = f(x):• Derivation of y = b from x = a and y = f(x):yy

bb

f( ) y = f(x)

a

y = f(x) y = f(x)

a and b: pointsy = f(x) : a curve

axx

a and b: intervals

a

y = f(x) : a curve y = f(x) : an interval-valuedfunction

Page 58: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Compositional Rule of Inference

• Going one step further f is a fuzzy relation on X×Y and A is g p ya fuzzy set of X

• We would like to find the resulting fuzzy set B(A) i li d i l t i ith b A• c(A) is a cylindrical extension with base A

• The intersection of c(A) and f forms I• By projecting I = c(A)Ոf onto the y-axis, y is inferred as aBy projecting I c(A)Ոf onto the y axis, y is inferred as a

fuzzy set B on the y-axis

Page 59: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Compositional Rule of Inference

• Let μA , μc(A) , μB and μf be the MFs of A, c(A), B, and fμA , μc(A) , μB μf , ( ), ,• μc(A) is related to μA through

h• Then,

• By projecting c(A)Ոf onto the y-axis, we have

• If both A and f have finite universe of discourse, the above formula reduces to the min-max compositionformula reduces to the min max composition

• B is represented as

Page 60: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Compositional Rule of Inference

• a is a fuzzy set and y = f(x) is a fuzzy relation:y y ( ) y

Page 61: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy reasoningy g

• The basic rule of inference is modus ponensp• We can infer the truth of B from the truth of A and the

implication A Bld lik t fi d th lti f t B• would like to find the resulting fuzzy set B

• Example:• A: the apple is redA: the apple is red• B: the apple is ripe• If it is true that “the apple is red”, it is also true that “the

l i i ”apple is ripe”

Page 62: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Reasoningy g

Fact: x is A’R l if i A th i BRule: if x is A, then y is B--------------------------------------------------Conclusion: y is B’Conclusion: y is B

where A’ is close to A and B’ is close to B.When A, B, A’, and B’ are fuzzy sets of appropriate

universe, the inference procedure is called approximate reasoning (or fuzzy reasoning orapproximate reasoning (or fuzzy reasoning, or generalized modus ponens (GMP))

Page 63: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Defintion of fuzzy reasoningy g

• Let A, A’ and B be fuzzy sets of X, X’ and Y, respectively, y , , p y• Assume A B is expressed as a fuzzy relation R on X×Y• Then, the fuzzy set B induced by “x is A” and the fuzzy rule

“if i A th i B” i d fi d b“if x is A, then y is B” is defined by

• Or equivalently

Page 64: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Reasoningy g

• Single rule with single antecedentg gFact: x is A’Rule: if x is A, then y is B--------------------------------------------------Conclusion: y is B’G hi R t ti• Graphic Representation:

Aw

A’ B

X

w

Y

B’A’

x is A’

B’

YX y is B’

Page 65: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Reasoningy g

• In this case, we have (assuming ˄ for the relation A B)

• Indeed• Indeed,• first we find the degree of match w as the maximum of μA’(x)˄μA(x)

• Then, the MF of resulting B’ is equal to the MF of B clipped , g q ppby w

• Note that w represents a measure of degree of belief for the antecedent part of a ruleThis measure gets propagated by the if then rules and the• This measure gets propagated by the if-then rules and the resulting degree of belief of MS for the consequent part (B’) should be no greater than w

Page 66: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Reasoningy g• Single rule with multiple antecedent

Fact: x is A’ and y is B’Fact: x is A’ and y is B’Rule: if x is A and y is B, then z is C---------------------------------------------------------Conclusion: z is C’

• Graphic Representation:p pA B T-norm

wA’ B’ C2

ZX Y

Z

C’A’ B’

C

ZX Yx is A’ y is B’ z is C’

Page 67: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Reasoningy g

• Based on Mamdani’s rule:

The resulting C’ is expressed as• The resulting C is expressed as

• Thus,

Page 68: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Reasoningy g

• w1 and w2 are the maxima of the MFs of AՈA’ and BՈB’• w1 denotes the degree of compatibility between A and A’• w1 and w2 is called the firing strength or degree of

fulfillment of the fuzzy rulefulfillment of the fuzzy rule

Page 69: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Reasoningy g

• Decomposition method for calculating C’

Proof• Proof

Page 70: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Reasoning

• Multiple rules with multiple antecedent

y g

p pFact: x is A’ and y is B’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

-------------------------------------------------------C l i i C’Conclusion: z is C’

• Graphic Representation: (next slide)

Page 71: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzy Reasoningy g

• Graphics representation:p pA1 B1

w1

A’ B’ C1

A2 B2

X Y

w1

A’ B’ C2

Z

T normX Y

w2

Z

T-norm

C’A’ B’

ZX Yx is A’ y is B’ z is C’

Page 72: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Four steps of fuzzy reasoningp y g

• Degrees of compatibility:Compare the known facts with the antecedents of fuzzy▫ Compare the known facts with the antecedents of fuzzy rule to find the degree of compatibility with respect to each antecedent MF

• Firing strength:▫ Combine degree of compatibility with respect to antecedent

MFs in a rule using fuzzy AND or OR operators to form a g y pfiring strength that indicates the degree to which the antecedent part of the rule is satisfied

Page 73: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Four steps of fuzzy reasoningp y g

• Qualified (induced) MFs: Apply the firing strength to the consequent MF of a rule to▫ Apply the firing strength to the consequent MF of a rule to generate a qualified consequent MF

• Overall output MF: ▫ Aggregate all the qualified consequent MFs to obtain an

overall output MF

Page 74: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Examplep• Comparing crisp logic inference and fuzzy logic inference

C i Ali i 22 ldCrisp logic

Ali is 22 years oldDina is 3 years older than Ali . Dina is (22 + 3) years old

Translation –Age(Ali) = 22; (Age(Dina),Age(Ali)) = Age(Dina)–Age(Ali) = 3; Age(Dina) = Age(Ali) + 3 = 22 + 3 = 25

Fuzzy logic

Ali is Young Dina is much older than Ali . Dina is (Young o Much older)

Translation –Age(Ali) = Young (Young is a fuzzy set); Age(Dina),Age(Ali)) =

M h ld ( l ti ) A (Di ) Y M h ld

Dina is (Young o Much_older)

Much_older (a relation); Age(Dina) = Young o Much_older – a composite relation!

Page 75: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Examplep

• µAge(Dina)(x) = {µyoung(y) µmuch_older(x,y) }The ni erse of disco rse (s pport) is "Age"The universe of discourse (support) is "Age" which may be quantified into several overlapping fuzzy (sub)sets: Young, Mid-age, pp g y ( ) g, g ,Old with the following definitions:

Young Mid-age Oldµ(Age)

Age20 35 505

Page 76: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Examplep

• Much_older is a relation which is defined as:

µmuch_older(x,y) = ,

0

200)(201

,201

yxyx

yx

.0 yx

µ (x,y)much_older

x 1020

3040

0 1020

3040 y

Page 77: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Examplep

• For each fixed x, find µAge(Dina)(x) = max(min(µyoung(y),µmuch_older(x,y)):

µ (x)Age(Dana)

0.8

1.0Age(Dana)

0.4

0.6

0

0.2

0 5 10 15 20 25 30 35 40 45xx

Page 78: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example: controlp

Page 79: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example: fuzzy controlp y

Page 80: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example: fuzzy controlp y

DefuzzilierFuzzifier Inference CrispValues

CrispValuesFuzzifier

EngineValues

Membership Functions

Fuzzy (IF THEN) RulesFuzzy VariablesLinguistic Variables

Page 81: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example: fuzzy control

i1 1 2 2IF is AND is THEN is , for 1, 2,...,i i ix A x A y B i l

p y

For example, Mamdani rule (we will see in the next chapter !):

Fuzzy

X (real number)

Fuzzy Value

FuzzifierAND/ORFuzzy

ValuesDOF

C tiMembership Functions

Method of

Connectives

Output Bl k

Fuzzy Value

Y(Fuzzy set) Defuzzifier

Y1Y2

Defuzzification

Defuzzified outputBlockValue

Yn

output (real number)

Page 82: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example: fuzzy control

IF theta is POSAND theta dot is POS NEG

ZEROPOS_

THEN force is NEGChange Detectors

Fuzzifier(POS)

thetaOutput Center of Gravity( )

ANDD f ifiD f ifi

theta_dot Fuzzifier(NEG)

forceOutput Block

(NEG)

Center of Gravity

DefuzzifierDefuzzifier(NEG)

Rule #2 force

Output

Rule #3 force

Page 83: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example: Robot obstacle avoidancep

Distance to obstacle ( d b i)

Angle of sensor i w

v(measured by sensor i)

Fuzzy-Logic-Controller

1

2

Page 84: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example: Robot obstacle avoidance

Membership Functions:

p

Close Near Far Neg Zero Pos

Membership Functions:

a) Distance measured by sensor (d)

b) Angle of sensor (th)

Zero VSlow Slow Fast Neg SNeg Zero SPos Pos

c) Forward velocity (V) d) Angular Velocity (W)

Page 85: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example: Robot obstacle avoidance

Fuzzy rules for the ith sensor:

p

1."IF distancei is Close And anglei is Pos Then V Is VSlow W is Neg "2."IF distancei is Close And anglei is Zero Then V Is Zero W is Neg "3."IF distancei is Close And anglei is Neg Then V Is VSlow W Is Pos "3. IF distancei is Close And anglei is Neg Then V Is VSlow W Is Pos 4."IF distancei is Near And anglei is Pos Then V Is Slow W Is SNeg"5."IF distancei is Near And anglei is Zero Then V Is VSlow W Is SNeg"6."IF distancei is Near And anglei is Neg Then V Is Slow W Is Spos"i g i g p7."IF distancei is Far And anglei is Pos Then V Is Fast W Is Zero"8."IF distancei is Far And anglei is Zero Then V Is Fast W Is Zero"9."IF distancei is Far And anglei is Neg Then V Is Fast W Is Zero"

Page 86: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example: Inverted Pendulum p

eCONTROLLER

ede/dt CONTROLLERde/dt

eHLeVLeI cossin

U

wLH

eeeemLmgVeHLeVLeI

)i()cossin(

cossin

2

2

wMHUeeeemLwmH

)sincos( 2

This can be hard.

Page 87: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Defining the Linguistic Variablesg g

• Variables for e, de/dt, U.• Seven values for each linguistic variable

(N ti L Al t Z P iti S ll)(Negative Large, Almost Zero, Positive Small)• Must choose scale appropriately. (E.g., for e,

a=pi/4 is a reasonable choice.)a pi/4 is a reasonable choice.)

NL NM AZNS PS PLPMNL NM AZNS PS PLPM

0 a/3 2a/3 a-a/3-2a/3-a

Page 88: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Fuzzification

• Account for uncertainty in measurement.• Measurement (x) is converted to fuzzy set

A(x). (This is a different set for each x).• For some controllers, this is skipped.

A( ) A( )

x x

Chosen based on uncertainty in measurement

A(x) A(x)

x x

No fuzzification

Page 89: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Inference Rules

e

NM NS AZ PS PM

NS NS AZ I i NS NS AZAZ NM AZ PMPS AZ PS

de/dtInterior valuesU

• These seven rules handle many cases.

PS AZ PS

• “If angle is PS and rate of change is NS, then drive applied to vehicle is AZ.”

Page 90: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Mamdani Inference (will see soon!)

• For each rule of form“If X is A, then Y is B,” (A, B are fuzzy sets), , ( , y )

• Input A’ and output B’ are fuzzy sets (or real numbers).

B’(x) = min(r, B(x)) where )'max( AAr

• Then to collect output of all rules, take fuzzy union.

Page 91: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Mamdani Inference

r

Rule 1

Rule 2

r

Rule 2

Given Fact ConclusionA’

Given Fact Conclusion

Page 92: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Mamdani Inference

r

Rule 1

Rule 2

r

Rule 2

Given Fact ConclusionGiven Fact Conclusion

Page 93: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Defuzzification (will see soon!)( )

• Result of inference is a fuzzy set on the possible actions.

• Need a crisp decision to actually perform.• Many methods of converting.• Center of mass method:

Page 94: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Example: Greenhouse climate controlby Anantharaman Sriraman (2003)

Inputs:• Difference in temperature between inside greenhouse & optimum

must be maintained in greenhouse [ 10 to +10 ºC]

by Anantharaman Sriraman (2003)

must be maintained in greenhouse [-10 to +10 ºC]• Difference in temperature between outside greenhouse & optimum

must be maintained in greenhouse [-20 to +20 ºC]• Difference in R-Humidity between inside greenhouse & optimum

must be maintained in greenhouse [0 to 100 %]g [ ]• Difference in R-Humidity between outside greenhouse & optimum

must be maintained in greenhouse [0 to 100 %]• Sunlight incident on the greenhouse roof [0 to 20 W/m2]• Seasonal Cloudiness which reduces the sun’s radiation [0 to 100 %]• Wind speed [0 to 100 mph]• Wind speed [0 to 100 mph]• Wind direction with respect to the direction of the ventilation system

of the greenhouse • Measurement error of the sensing system (-4 to 4)• Change in Error of the measurement of the sensing system (-1 to 1)Change in Error of the measurement of the sensing system ( 1 to 1)

Outputs:• Thermal system (0 to 100 %)• Ventilation & humidification system (0 to 100 %)• Thermal shade system (0 to 100 %)• Thermal shade system (0 to 100 %)• CO2 generation system (0 to 100 %)• Forced ventilation system (0 to 100 %)• Performance of the system (0 to 100 %)

Page 95: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Input Membership FunctionInput Membership Function

Page 96: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Input Membership FunctionInput Membership Function

Page 97: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Input Membership FunctionInput Membership Function

Page 98: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Output Membership FunctionOutput Membership Function

Page 99: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Output Membership FunctionOutput Membership Function

Page 100: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Rules-1

Page 101: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Rules-2

Page 102: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Rules-3 & 4

Page 103: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Rules 5 & 6

Page 104: Lectures 4&5: Fuzzy Rules and Fuzzy Reasoning

Readingg

• J-S R Jang and C-T Sun Neuro-FuzzyJ S R Jang and C T Sun, Neuro Fuzzy and Soft Computing, Prentice Hall, 1997 (Chapter 3)(Chapter 3).