28
16/3/2015 1 Fuzzy Logic and Fuzzy System Source: https://www.cs.tcd.ie/Khurshid.Ahmad/Teaching/Lectures_on_Fuzzy_Logic/CS4001_FuzzySets _Systems_Properties_Lect_2.pdf 1 Fuzzy Operators: t-norms and t-conorms t-norms and t-conorms are binary operators that generalize intersection and union operations, respectively. t-norm: it is a binary operation T: [0,1] x [0,1] [0,1] which satisfies the following properties: Commutativity:T(a,b) = T(b,a) Associativity:T(a, T(b,c)) = T(T(a,b), c) Identity element: T(a,1) = T(1,a) = a Monotonicity: if a ≤ c and b ≤ d then T(a,b) ≤ T(c,d) These operators represent the intersection of two fuzzy sets. Some examples of t-norms are minimum min(a,b), product prod(a,b) = a•b and Lukasiewicz W(a,b)=max(0,a+b-1). 2

Fuzzy Inference Systems

Embed Size (px)

DESCRIPTION

Fuzzy System

Citation preview

Page 1: Fuzzy Inference Systems

16/3/2015

1

Fuzzy Logic and Fuzzy System

Source: https://www.cs.tcd.ie/Khurshid.Ahmad/Teaching/Lectures_on_Fuzzy_Logic/CS4001_FuzzySets

_Systems_Properties_Lect_2.pdf

1

Fuzzy Operators: t-norms and t-conorms

t-norms and t-conorms are binary operators that generalize

intersection and union operations, respectively.

t-norm: it is a binary operation T: [0,1] x [0,1] → [0,1] which

satisfies the following properties:

Commutativity: T(a,b) = T(b,a)

Associativity: T(a, T(b,c)) = T(T(a,b), c)

Identity element: T(a,1) = T(1,a) = a

Monotonicity: if a ≤ c and b ≤ d then T(a,b) ≤ T(c,d)

These operators represent the intersection of two fuzzy sets.

Some examples of t-norms are minimum min(a,b), product

prod(a,b) = a•b and Lukasiewicz W(a,b)=max(0,a+b-1).

2

Page 2: Fuzzy Inference Systems

16/3/2015

2

Fuzzy Operators: t-norms and t-conorms

t-norm

3

Fuzzy Operators: t-norms and t-conorms

t-conorm: it is a binary operation S: [0,1] x [0,1] → [0,1] which

satisfies the following properties:

Commutativity: S(a,b) = S(b,a)

Associativity: S(a, S(b,c)) = S(S(a,b), c)

Identity element: S(a,0) = S(0,a) = a

Monotonicity: if a ≤ c and b ≤ d then S(a,b) ≤ S(c,d)

These operators represent the union of two fuzzy sets.

Some examples of t-conorms are maximum max(a,b), probabilístic

sum or sum-product sum-prod (a,b) = a+b - a•b and

Lukasiewicz W*(a,b)=min(1,a+b).

4

Page 3: Fuzzy Inference Systems

16/3/2015

3

Fuzzy Operators: t-norms and t-conorms

t-conorm

5

Example: Air-conditioning system

In order to understand how two fuzzy subsets are mapped

onto each other to obtain a cross product, consider the

example of an air-conditioning system.

Air-conditioning involves the delivery of air which can be

warmed or cooled and have its humidity raised or lowered.

An air-conditioner is an instrument for controlling, especially

lowering, the temperature and humidity of an enclosed space.

An air-conditioner typically has a fan which

blows/cools/circulates fresh air and has cooler and the cooler

is under thermostatic control.

Generally, the amount of air being compressed is proportional

to the ambient temperature.

6

Page 4: Fuzzy Inference Systems

16/3/2015

4

Example: Air-conditioning system

The rules governing the air-conditioner are as follows:

RULE#1: IF TEMP is COLD THEN SPEED is MINIMAL

RULE#2: IF TEMP is COOL THEN SPEED is SLOW

RULE#3: IF TEMP is PLEASENT THEN SPEED is MEDIUM

RULE#4: IF TEMP is WARM THEN SPEED is FAST

RULE#5: IF TEMP is HOT THEN SPEED is BLAST

The rules can be expressed as a cross product:

CONTROL = TEMP × SPEED

Where: TEMP = {COLD, COOL, PLEASANT , WARM, HOT}

SPEED = {MINIMAL, SLOW , MEDIUM, FAST , BLAST}

7

Example: Air-conditioning system

A graphical representation of the two linguistic variables Speed

and Temperature

8

Page 5: Fuzzy Inference Systems

16/3/2015

5

Example: Air-conditioning system

A fuzzy patch is defined by a fuzzy rule

A patch is a mapping of two membership functions, it is a

product of two geometrical objects, line segments, triangles,

squares etc.

Geometrically a patch is an area

that represents the causal

association between the cause

(the inputs) and the effect (the

outputs).

The size of the patch indicates

the vagueness implicit in the rule

as expressed through the

membership functions of the

inputs and outputs.

9

Knowledge Representation & Reasoning

Once we have found that the knowledge of a specialism

can be expressed through linguistic variables and rules of

thumb, that involve imprecise antecedents and

consequents, then we have a basis of a knowledge-base.

In this knowledge-base ‘facts’ are represented through

linguistic variables and the rules follow fuzzy logic.

10

Page 6: Fuzzy Inference Systems

16/3/2015

6

IF-THEN Fuzzy Rule

In a fuzzy system, knowledge base of either knowledge-based

system or rule based system is represented as a set of

production rules, namely IF-THEN fuzzy rules.

IF < Fuzzy Proposition 1> THEN < Fuzzy Prosotion 2>.

Proposition 1: antecedent or premise,

Proposition 2: consequent or conclusion.

Fuzzy proposition is a proposition of which the degree of truth

is indicated by a number within the interval [0,1]

Premise of fuzzy rule may consist of more than one part.

All part of the premise are counted simultaneously and then, solved for

obtaining a single number by using fuzzy operator in a Fuzzy set.

11

IF-THEN Fuzzy Rule

Fuzzy rule base:

RU(k) = IF x1 is A1

k and .. and xn is Ank THEN y is Bk

where

Aik and Bk are fuzzy sets in Ui R and V R, respectively (U

& V is physical domain), i =1, 2,…n,

x = (x1, x2,…, xn)T U and y V are the input and output

variable (linguistic) of fuzzy system, respectively.

12

Page 7: Fuzzy Inference Systems

16/3/2015

7

IF-THEN Fuzzy Rule

General scheme for determining the conclusion of M Rule

Rule 1 : IF x1 is A11 and x2 is A2

1 and.. and xn is An1 THEN y is B1

Rule 2 : IF x1 is A12 and x2 is A2

2 and.. and xn is An2 THEN y is B2

…………………………………………………………………………………

Rule M : IF x1 is A1M and x2 is A2

M and.. and xn is AnM THEN y is BM

Fact : x1 is A1’ and x2 is A2’ and.. and xn is An’

----------------------------------------------------------------------------------------------

Conclusion : y is B’

13

Fuzzy Inference Systems

Kecerdasan Komputasional

14

Page 8: Fuzzy Inference Systems

16/3/2015

8

Fuzzy Inference System (FIS)

A Fuzzy Inference System (FIS) is a way of mapping an input

space to an output space using fuzzy logic.

15

Fuzzy Inference System (FIS)

Fuzzifier: Converts the crisp input to a linguistic variable using

the membership functions stored in the fuzzy knowledge base.

Inference engine: Using If-Then type fuzzy rules converts

the fuzzy input to the fuzzy output.

16

Page 9: Fuzzy Inference Systems

16/3/2015

9

Fuzzy Inference System (FIS)

Defuzzifier: Converts the fuzzy output of the inference engine

to crisp using membership functions analogous to the ones

used by the fuzzifier.

Nonlinearity: In the case of crisp inputs & outputs, a fuzzy

inference system implements a nonlinear mapping from its

input space to output space.

Five commonly used defuzzifying methods:

Centroid of area (COA)

Bisector of area (BOA)

Mean of maximum (MOM)

Smallest of maximum (SOM)

Largest of maximum (LOM)

17

Fuzzy Inference System (FIS)

Defuzzifying methods:

( )

,( )

A

ZCOA

A

Z

z zdz

zz dz

( ) ( ) ,BOA

BOA

z

A A

z

z dz z dz

*

,

{ ; ( ) }

ZMOM

Z

A

zdz

zdz

where Z z z

Centroid of area (COA)

Bisector of area (BOA)

Mean of maximum (MOM)

18

Page 10: Fuzzy Inference Systems

16/3/2015

10

Mamdani Fuzzy models

Introduced by Professor Ebrahim Mamdani of London University in

1975,

Original Goal: Control a steam engine & boiler combination by a set

of linguistic control rules obtained from experienced human

operators.

There are two main methods to evaluate rules:

Clipping

Scaling

19

20

Inference in Mamdani fuzzy models

The most common method of correlating the rule consequent with the truth value of the rule antecedent is to cut the consequent membership function at the level of the antecedent truth. This method is called clipping (alpha-cut).

Since the top of the membership function is sliced, the clipped fuzzy set loses some information.

However, clipping is still often preferred because it involves less complex and faster mathematics, and generates an aggregated output surface that is easier to defuzzify.

Page 11: Fuzzy Inference Systems

16/3/2015

11

21

Inference in Mamdani fuzzy models

While clipping is a frequently used method, scaling

offers a better approach for preserving the original shape

of the fuzzy set.

The original membership function of the rule consequent

is adjusted by multiplying all its membership degrees by

the truth value of the rule antecedent.

This method, which generally loses less information, can

be very useful in fuzzy expert systems.

22

Inferencing in Mamdani fuzzy models

Degree ofMembership

1.0

0.0

0.2

Z

Degree ofMembership

Z

C2

1.0

0.0

0.2

C2

clipping scaling

Page 12: Fuzzy Inference Systems

16/3/2015

12

Mamdani Fuzzy models

Max-Min Composition

23

Mamdani Fuzzy models

Max-Product Composition

24

Page 13: Fuzzy Inference Systems

16/3/2015

13

Mamdani Fuzzy models

Example

R1 : If X is small then Y is small

R2 : If X is medium then Y is medium

R3 : If X is large then Y is large

X = input [10, 10]

Y = output [0, 10]

Max-min composition and centroid defuzzification were used.

Overall input-output curve

25

26

Sugeno Fuzzy Inference

Mamdani-style inference requires us to find the centroid of a two-dimensional shape by integrating across a continuously varying function. In general, this process is not computationally efficient.

Michio Sugeno suggested to use a single spike, a singleton, as the membership function of the rule consequent.

A singleton, or more precisely a fuzzy singleton, is a fuzzy set with a membership function that is unity at a single particular point on the universe of discourse and zero everywhere else.

Page 14: Fuzzy Inference Systems

16/3/2015

14

Sugeno Fuzzy Models

Also known as TSK fuzzy model

Takagi, Sugeno & Kang, 1985

Goal: Generation of fuzzy rules from a given input-output data

set.

Fuzzy Rules of TSK Model:

If x is A and y is B then z = f(x, y)

Fuzzy Sets

f(x, y) is very often a polynomial

function w.r.t. x and y.

Crisp function

27

Sugeno Fuzzy Models

Example

R1: if X is small and Y is small then z = x +y +1

R2: if X is small and Y is large then z = y +3

R3: if X is large and Y is small then z = x +3

R4: if X is large and Y is large then z = x + y + 2

28

Page 15: Fuzzy Inference Systems

16/3/2015

15

Sugeno Fuzzy Models

R1: If X is small then Y = 0.1X + 6.4

R2: If X is medium then Y = 0.5X + 4

R3: If X is large then Y = X – 2

X = input [10, 10]

29

Sugeno Fuzzy Models

R1: If X is small then Y = 0.1X + 6.4

R2: If X is medium then Y = 0.5X + 4

R3: If X is large then Y = X – 2

X = input [10, 10]

If we have smooth membership functions (fuzzy rules) the overall input-

output curve becomes a smoother one.

30

Page 16: Fuzzy Inference Systems

16/3/2015

16

Sugeno Fuzzy Models

Reasoning Scheme

31

32

Sugeno Rule Evaluation

A3

1

0 X

1

y10 Y

0.0

x1 0

0.1

1

Z

1

0 X

0.2

0

0.2

1

Z

A2

x1

IF x is A1 (0.5) z is k3 (0.5)Rule 3:

A11

0 X 0

1

Zx1

THEN

1

y1

B2

0 Y

0.7

B10.1

0.5 0.5

OR(max)

AND(min)

OR y is B1 (0.1) THEN z is k1 (0.1)Rule 1:

IF x is A2 (0.2) AND y is B2 (0.7) THEN z is k2 (0.2)Rule 2:

k1

k2

k3

IF x is A3 (0.0)

A3

1

0 X

1

y10 Y

0.0

x1 0

0.1

1

Z

1

0 X

0.2

0

0.2

1

Z

A2

x1

IF x is A1 (0.5) z is k3 (0.5)Rule 3:

A11

0 X 0

1

Zx1

THEN

1

y1

B2

0 Y

0.7

B10.1

0.5 0.5

OR(max)

AND(min)

OR y is B1 (0.1) THEN z is k1 (0.1)Rule 1:

IF x is A2 (0.2) AND y is B2 (0.7) THEN z is k2 (0.2)Rule 2:

k1

k2

k3

IF x is A3 (0.0)

Page 17: Fuzzy Inference Systems

16/3/2015

17

33

Sugeno Aggregation of the Rule Outputs

z is k1 (0.1) z is k2 (0.2) z is k3 (0.5)

0

1

0.1

Z 0

0.5

1

Z0

0.2

1

Zk1 k2 k3 0

1

0.1

Zk1 k2 k3

0.20.5

34

Sugeno Defuzzification

655.02.01.0

805.0502.0201.0

)3()2()1(

3)3(2)2(1)1(

kkk

kkkkkkWA

Weighted Average (WA)

0 Z

Crisp Output

z1

z1

Page 18: Fuzzy Inference Systems

16/3/2015

18

Tsukamoto Fuzzy models

The consequent of each fuzzy if-then rule is represented by a fuzzy

set with a monotonical membership function.

As a result, the inferred output of each rule is defined as a crisp

value induced by the rule’s firing strength.

The overall output is taken as the weighted average of each rule’s

output

A monotonically

increasing function

A monotonically

decreasing function

A function that is

not monotonic 35

Tsukamoto Fuzzy models

Reasoning procedure for a two-input two-rule system

Tsukamoto fuzzy model aggregate each rule’s output

by the method of weighted average and thus avoids

the time-consuming process of defuzzification

36

Page 19: Fuzzy Inference Systems

16/3/2015

19

Single-input Tsukamoto fuzzy model

IF X is small then Y is C1

IF X is medium then Y is C2

IF X is large then Y is C3

Overall input-output

curve, Figure (d):

fi is the output of each rule induced by the firing strength Wi and MF for Ci.

37

Fuzzy Control:

Mamdani & Takagi-Sugeno Controllers

The term control is generally defined as a mechanism used to guide mechanism used to guide or regulate the operation of a machine, apparatus or constellations of machines and apparatus

Example:

Consider the problem of controlling an air-conditioner. The rules that are used to control the air conditioner can be expressed as a cross product:

CONTROL = TEMP × SPEED

Where the set of linguistic values of the term sets is given as

TEMP = COLD + COOL + PLEASANT + WARM + HOT

SPEED = MINIMAL + SLOW + MEDIUM + FAST + BLAST

38

Page 20: Fuzzy Inference Systems

16/3/2015

20

Fuzzy sets

Temperature Fuzzy Sets

Speed Fuzzy Sets

39

Fuzzy sets

The analytically expressed membership for the reference fuzzy subsets for the

temperature are

Cold: cold(T) = (T/10) + 1, 0 T 10

Cold: cool(T) = T/12.5, 0 T 12.5

cool(T) = (T/5) + 3.5, 12.5 T 17.5

Pleasant: plea(T) = (T/2.5) 6, 15 T 17.5

plea(T) = (T/2.5) + 8, 17.5 T 20

Warm: warm(T) = (T/5) 3.5, 17.5 T 22.5

warm(T) = (T/5) 3.5, 22.5 T 27.5

Hot: hot(T) = (T/2.5) 11, 25 T 30

hot(T) = 1, T 30

40

Page 21: Fuzzy Inference Systems

16/3/2015

21

Mamdani Controller

Recall that the rules governing the air-conditioner are as

follows:

RULE#1: IF TEMP is COLD THEN SPEED is MINIMAL

RULE#2: IF TEMP is COOL THEN SPEED is SLOW

RULE#3: IF TEMP is PLEASANT THEN SPEED is MEDIUM

RULE#4: IF TEMP is WARM THEN SPEED is FAST

RULE#5: IF TEMP is HOT THEN SPEED is BLAST

41

Zero-order Takagi-Sugeno Controller

Recall that the rules governing the air-conditioner are as follows:

RULE#1: IF TEMP is COLD THEN SPEED =k1

RULE#2: IF TEMP is COOL THEN SPEED = k2

RULE#3: IF TEMP is PLEASENT THEN SPEED =k3

RULE#4: IF TEMP is WARM THEN SPEED =k4

RULE#5: IF TEMP is HOT THEN SPEED =k5

where ki is a constant, I = 1, 2,…, 5

42

Page 22: Fuzzy Inference Systems

16/3/2015

22

First-order Takagi-Sugeno Controller

Recall that the rules governing the air-conditioner are as

follows:

RULE#1: IF TEMP is COLD THEN SPEED =j1+k1*T

RULE#2: IF TEMP is COOL THEN SPEED = j2+k2*T

RULE#3: IF TEMP is PLEASENT THEN SPEED =k3

RULE#4: IF TEMP is WARM THEN SPEED = j4+ k4 *T

RULE#5: IF TEMP is HOT THEN SPEED =k5

43

Zero-order Takagi-Sugeno Controller

Zero-order speed control just takes one SINGLETON value at fixed values

of the velocity; for all other values the membership function is defined as

zero

Minimal: Minimal(V) = 1, V = 0; Slow: Slow(V) = 1, V = 30

Medium: Med(V) = 1, V = 50; Fast: Fast(V) = 1, V = 70

Blast: Blast(V) = 1, V = 100

44

Page 23: Fuzzy Inference Systems

16/3/2015

23

Zero-order Takagi-Sugeno Controller

Let the temperature be 5 degrees centigrade:

Fuzzification: 5 degrees means that it can be COOL and COLD;

Inference: Rules 1 and 2 will fire:

Composition:

The temperature is ‘COLD’ with a truth value of µCOLD=0.5

the SPEED will be k1

The temperature is ‘COOL’ with a truth value of µCOOL =0.4

the SPEED will be k2

Defuzzification: CONTROL speed is

(µCOLD*k1+ µCOOL*k2)/(µCOLD+ µCOOL)

= (0.5*0+0.4*30)/(0.5+0.4)=13.33 RPM

45

Example

Fuzzification: Consider that the temperature is 16oC and

we want our knowledge base to compute the speed.

The fuzzification of the the crisp temperature gives the

following membership for the Temperature fuzzy set:

cold cool Pleasant warm hot

Temp = 16 0 0.3 0.4 0 0

Fire rule (#)

Yes/no

(#1)

no

(#2)

yes

(#3)

yes

(#4)

no

(#5)

no

46

Page 24: Fuzzy Inference Systems

16/3/2015

24

Example

INFERENCE: Consider that the temperature is 16oC and

we want our knowledge base to compute the speed.

Rule #2 & 3 are firing and are essentially the fuzzy patches

made out of the cross products of

COOL x SLOW

PLEASANT x MEDIUM

47

Example

COMPOSITION: The COOL and PLEASANT sets have

an output of 0.3 and 0.4 respectively.

The singleton values for SLOW and MEDIUM have to be given

an alpha-level cut for these output values respectively

48

Page 25: Fuzzy Inference Systems

16/3/2015

25

Example

DEFUZZIFICATION: The problem of finding a single,

crisp value is no longer a problem for a Takagi-Sugeno

controller. All we need is the weighted average of the

singleton values of SLOW & MEDIUM.

Recall the Centre of Area computation for the Mamdani

controller

49

Example

DEFUZZIFICATION: For Takagi-Sugeno, the computation for

η is restricted to the singleton values of the SPEED linguistic

variable – we do not need to sum over all values of the

variable y

50

Page 26: Fuzzy Inference Systems

16/3/2015

26

Example

DEFUZZIFICATION:

Recall the case of the Mamdani equivalent of the fuzzy air-conditioner –

where we had fuzzy sets for the linguistic variables SLOW and MEDIUM:

The ‘Centre of Area’ (COA) computations involved a weighted sum over

all values of speed between 12.5 and 57.5 RPM

In the Takagi-Sugeno case we only had to consider values for speeds

30RPM and 50 RPM.

51

Speed Slow Medium Output of

Rules Weighted

Speed

12.5 0.125 0 0.125 1.5625

15 0.25 0 0.25 3.75

17.5 0.3 0 0.3 5.25

20 0.3 0 0.3 6

22.5 0.3 0 0.3 6.75

25 0.3 0 0.3 7.5

27.5 0.3 0 0.3 8.25

30 0.3 0 0.3 9

32.5 0.3 0 0.3 9.75

35 0.3 0 0.3 10.5

37.5 0.3 0 0.3 11.25

40 0.3 0 0.3 12

42.5 0.3 0.25 0.3 12.75

45 0.25 0.4 0.4 18

47.5 0.125 0.4 0.4 19

50 0 0.4 0.4 20

52.5 0 0.4 0.4 21

55 0 0.4 0.4 22

57.5 0 0.25 0.25 14.375

Sum 5.925 218.6875

The speed is 36.91 RPM

( )

,( )

A

ZCOA

A

Z

z zdz

zz dz

52

Page 27: Fuzzy Inference Systems

16/3/2015

27

Example

DEFUZZIFICATION: For Mean of Maxima for the Mamdani

controller, we had to have an alpha-level cut of 0.4, and the

summation ran between 45-57.5 RPM, leading to a speed of 50

RPM.

We get the same result for Takagi-Sugeno controllers:

η= (0.4*50)/0.4=50 RPM

Comparing the results of two model – Mamdani and Takagi-

Sugeno:

Controller Takagi-Sugeno

(RPM)

Mamdani

(RPM)

Centre of area 41.43 36.91

Mean of Maxima 50 50

53

Key difference between a Mamdani-type fuzzy system and the

Takagi-Sugeno-Kang System?

Zero-order Sugeno fuzzy model can be viewed as a special case of

the Mamdani fuzzy inference system in which each rule is specified

by fuzzy singleton or a pre-defuzzified consequent.

In Sugeno’s model, each rule has a crisp output, the overall input is

obtained by a weighted average – this avoids the time-consuming

process of defuzzification required in a Mandani model.

The weighted average operator is replaced by a weighted sum to

reduce computation further. (Jang, Sun, Mizutani (1997:82)).

54

Page 28: Fuzzy Inference Systems

16/3/2015

28

Mamdani method is widely accepted for capturing expert

knowledge. It allows us to describe the expertise in more

intuitive, more human-like manner. However, Mamdani-type

fuzzy inference entails a substantial computational burden.

On the other hand, Sugeno method is computationally

effective and works well with optimisation and adaptive

techniques, which makes it very attractive in control problems,

particularly for dynamic nonlinear systems.

55

References

http://www.bindichen.co.uk/post/AI/fuzzy-inference-

system.html

https://www.cs.tcd.ie/Khurshid.Ahmad/Teaching/Lectures_

on_Fuzzy_Logic/CS4001_FuzzySets_Systems_Properties

_Lect_2.pdf

56