• No results found

Week7 Fuzzy Logick Tutorial

N/A
N/A
Protected

Academic year: 2021

Share "Week7 Fuzzy Logick Tutorial"

Copied!
54
0
0

Loading.... (view fulltext now)

Full text

(1)

Fuzzy Expert Systems

(2)

October 2005 1

 Recap

 Example: Air Conditioner

 Example: Cart Pole Problem

 Case Study: Building a Fuzzy Expert System

 Summary

(3)

1. Specify the problem; define linguistic variables.

Recap

2. Determine fuzzy sets.

3. Elicit and construct fuzzy rules.

4. Encode the fuzzy sets, fuzzy rules and procedures

to perform fuzzy inference into the expert system.

5. Evaluate and tune the system.

(4)

October 2005 3

Fuzzification:

definition of fuzzy sets, and

determination of the degree of membership of crisp

inputs in appropriate fuzzy sets.

Recap

Inference:

evaluation of fuzzy rules to produce

an output for each rule.

Composition:

aggregation or combination of

the outputs of all rules.

Defuzzification:

computation of crisp output

Operation of a fuzzy expert system:

(5)

 Recap

 Example: Air Conditioner

 Example: Cart Pole Problem

 Case Study: Building a Fuzzy Expert System

 Summary

(6)

October 2005 5

Example: Air Conditioner

1a. Specify the problem

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 apparatus 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 a cooler. The cooler is controlled by a thermostat. Generally, the amount of air being compressed is proportional to the ambient

temperature.

1b. Define linguistic variables

• Ambient Temperature

(7)

Example: Air Conditioner

2. Determine Fuzzy Sets: Temperature

Temp (0C).

COLD COOL PLEASANT WARM HOT

0 Y* N N N N 5 Y Y N N N 10 N Y N N N 12.5 N Y* N N N 15 N Y N N N 17.5 N N Y* N N 20 N N N Y N 22.5 N N N Y* N 25 N N N Y N 27.5 N N N N Y 30 N N N N Y* Temp (0C).

COLD COOL PLEASANT WARM HOT

0<(T)<1

(T)=1

(8)

October 2005 7

Example: Air Conditioner

2. Determine Fuzzy Sets: Temperature

Temperature Fuzzy Sets

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 5 10 15 20 25 30 Temperature Degrees C T r u th Val u e Cold Cool Pleasent Warm Hot Temperature Fuzzy Sets

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 5 10 15 20 25 30 Temperature Degrees C T ru th Val u e Cold Cool Pleasent Warm Hot

(9)

Example: Air Conditioner

2. Determine Fuzzy Sets: Fan Speed

Rev/sec (RPM)

MINIMAL SLOW MEDIUM FAST BLAST

0 Y* N N N N 10 Y N N N N 20 Y Y N N N 30 N Y* N N N 40 N Y N N N 50 N N Y* N N 60 N N N Y N 70 N N N Y* N 80 N N N Y Y 90 N N N N Y 100 N N N N Y*

(10)

October 2005 9

Example: Air Conditioner

2. Determine Fuzzy Sets: Fan Speed

Speed Fuzzy Sets

0 0.2 0.4 0.6 0.8 1 0 10 20 30 40 50 60 70 80 90 100 Speed Tru th V a lue MINIMAL SLOW MEDIUM FAST BLAST

(11)

Example: Air Conditioner

3. Elicit and construct fuzzy rules

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

(12)

October 2005 11

Example: Air Conditioner

3. Encode into an Expert System

4. Evaluate and tune the system

Consider a temperature of 16

o

C, use the system

to compute the optimal fan speed.

Operation of a Fuzzy Expert System

• Fuzzification

• Inference

• Composition

• Defuzzification

(13)

Example: Air Conditioner

• Fuzzification

 Affected fuzzy sets: COOL and PLEASANT

COOL

(T) = – T / 5 + 3.5

= – 16 / 5 + 3.5

= 0.3

PLSNT

(T) = T /2.5 - 6

= 16 /2.5 - 6

= 0.4

Temp=16

COLD

COOL

PLEASANT

WARM

HOT

0

0.3

0.4

0

0

(14)

October 2005 13

Example: Air Conditioner

• Inference

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

(15)

Example: Air Conditioner

RULE 2: IF temp is cool (0.3) THEN speed is slow (0.3)

RULE 3: IF temp is pleasant (0.4) THEN speed is medium (0.4)

• Inference

(16)

October 2005 15

Example: Air Conditioner

• Composition

(17)

Example: Air Conditioner

• Defuzzification

COG = 0.125(12.5) + 0.25(15) + 0.3(17.5+20+…+40+42.5) + 0.4(45+47.5+…+52.5+55) + 0.25(57.5) 0.125 + 0.25 + 0.3(11) + 0.4(5) + 0.25

(18)

October 2005 17

 Recap

 Example: Air Conditioner

 Example: Cart Pole Problem

 Case Study: Building a Fuzzy Expert System

 Summary

(19)

Example: Cart Pole Problem

The problem is to balance an upright pole, with a mass m at its

head and mass M at its base. A weightless shaft connects these two masses. The base can be moved on a horizontal axis. The

task is to determine the FORCE (F) necessary to balance the pole. The calculation of the force F involves the measurement of the

angle θ and the angular velocity, w of the pole .

M

m

g

(20)

October 2005 19 nb nm ns az ps pm pb nb ps pb nm pm ns nm ns ps az nb nm ns az ps pm pb ps ns ps pm pm nm pb nb ns

Example: Cart Pole Problem

θ

nb: negative big, nm: negative medium, ns: negative small az: approximately zero

ps: positive small, pm: positive medium, pb: positive big

IF is negative medium and w is approximately zero

THEN F is negative medium

θ

(21)

Example: Cart Pole Problem

The fuzzy sets for θ, and F are based on the linear equation

μ(x)=ax + b, and are defined based on the following table:

w (w)=1 if w= (w)=1 if w= (w)=0 if w>= w

(22)

October 2005 21

Example: Cart Pole Problem

(b) Consider the case when the input variables are: θ = 50, = -5. Use the rule base, execute each of the four tasks to compute the force F necessary to balance the pole using the Centre of

Gravity in the Defuzzification task.

(a) Based on the fuzzy sets table draw three graphs showing the fuzzy sets (nb, nm, ns, az, ps, pm, pb) for each θ, w, and F individually.

(23)

Example: Cart Pole Problem

Fuzzification

i) Determine where θ and the angular velocity fall in the table θ: pm, pb

w: az

ii) Formulate possible rules from linguistic values obtained IF θ is pm AND w is az THEN F is pm

(24)

October 2005 23

Example: Cart Pole Problem

Fuzzification

iii) Compute membership functions

-11.25 -5 0 10 22.5 45 50 67.5  45 50 67.5 1 1  1/22.5 =  /17.5  = 0.78 θ: pm θ: pb 67.5 50 45  1 1/22.5 =  /5  = 0.22  1 w: az 1/11.25 = /6.25  = 0.56

(25)

Example: Cart Pole Problem

Inference

The two premises in RULE 1 are conjunctive  minimum of the two: min{0.78, 0.56}=0.56 1 IF θ is pm AND w is az THEN F is pm

2 IF θ is pb AND w is az THEN F is pb

The two premises in RULE 2 are conjunctive  minimum of the two: min{0.22, 0.56}=0.22

(26)

October 2005 25

Example: Cart Pole Problem

Composition

ps pb

Defuzzification

3 0.2 (4 5 6) 0.56 (7 8) 0.22 5.30 0.2 0.56 0.56 0.56 0.22 0.22 SoG =         =      C

(27)

 Recap

 Example: Air Conditioner

 Example: Cart Pole Problem

 Case Study: Building a Fuzzy Expert System

 Summary

(28)

October 2005 27

A service centre keeps spare parts and repairs failed ones. A customer brings a failed item and receives a spare of the same type. Failed

parts are repaired, placed on the shelf, and thus become spares. The objective is to advise a manager of the service centre on certain decision policies to keep the customers satisfied.

Case Study: Building a Fuzzy

Expert System

Step 1: Specify the problem and define

linguistic variables

There are four main linguistic variables: average waiting time (mean delay) m, repair utilisation factor of the service centre , number of servers s, and initial number of spare parts n.

(29)

Linguistic variables and their ranges

Linguistic Variable: Mean Delay, m

Linguistic Value Notation Numerical Range (normalised) Very Short Short Medium VS S M [0, 0.3] [0.1, 0.5] [0.4, 0.7] Linguistic Variable: Number of Servers, s

Linguistic Value Notation Numerical Range (normalised) Small Medium Large S M L [0, 0.35] [0.30, 0.70] [0.60, 1] Linguistic Variable: Repair Utilisation Factor,

Linguistic Value Notation Numerical Range Low Medium High L M H [0, 0.6] [0.4, 0.8] [0.6, 1] Linguistic Variable: Number of Spares, n

Linguistic Value Notation Numerical Range (normalised) Very Small Small Rather Small Medium Rather Large Large VS S RS M RL L [0, 0.30] [0, 0.40] [0.25, 0.45] [0.30, 0.70] [0.55, 0.75] [0.60, 1] Linguistic Variable: Mean Delay, m

Linguistic Variable: Number of Servers, s

Linguistic Variable: Repair Utilisation Factor,

(30)

October 2005 29

Step 2: Determine fuzzy sets

Fuzzy sets can have a variety of shapes.

However, a triangle or a trapezoid can often

provide an adequate representation of the expert

knowledge, and at the same time, significantly

(31)

Fuzzy sets of Mean Delay m

0.1 0 1.0 0.0 0.2 0.4 0.6 0.8 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Mean Delay (normalised) S

VS M

Degree of Membership

(32)

October 2005 31

Fuzzy sets of Number of Servers s

0.1 0 1.0 0.0 0.2 0.4 0.6 0.8 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 M L S Degree of Membership

(33)

Fuzzy sets of Repair Utilisation Factor

0.1 0 1.0 0.0 0.2 0.4 0.6 0.8 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Repair Utilisation Factor

M H

L Degree of

(34)

October 2005 33

Fuzzy sets of Number of Spares n

0.1 0 1.0 0.0 0.2 0.4 0.6 0.8 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 S RS VS M RL L VL Degree of Membership

(35)

Step 3: Elicit and construct fuzzy rules

To accomplish this task, we might ask the expert

to describe how the problem can be solved using

the fuzzy linguistic variables defined previously.

Required knowledge also can be collected from

other sources such as books, computer

databases, flow diagrams and observed human

behaviour.

(36)

October 2005 35

(37)

The rule table

Rule m sn Rule m sn Rule m sn

1 VS S L VS 10 VS S M S 19 VS S H VL 2 S S L VS 11 S S M VS 20 S S H L 3 M S L VS 12 M S M VS 21 M S H M 4 VS M L VS 13 VS M M RS 22 VS M H M 5 S M L VS 14 S M M S 23 S M H M 6 M M L VS 15 M M M VS 24 M M H S 7 VS L L S 16 VS L M M 25 VS L H RL 8 S L L S 17 S L M RS 26 S L H M 9 M L L VS 18 M L M S 27 M L H RS

(38)

October 2005 37

Rule Base 1

1. If (utilisation_factor is L) then (number_of_spares is S) 2. If (utilisation_factor is M) then (number_of_spares is M) 3. If (utilisation_factor is H) then (number_of_spares is L)

4. If (mean_delay is VS) and (number_of_servers is S) then (number_of_spares is VL) 5. If (mean_delay is S) and (number_of_servers is S) then (number_of_spares is L) 6. If (mean_delay is M) and (number_of_servers is S) then (number_of_spares is M) 7. If (mean_delay is VS) and (number_of_servers is M) then (number_of_spares is RL) 8. If (mean_delay is S) and (number_of_servers is M) then (number_of_spares is RS) 9. If (mean_delay is M) and (number_of_servers is M) then (number_of_spares is S) 10.If (mean_delay is VS) and (number_of_servers is L) then (number_of_spares is M) 11.If (mean_delay is S) and (number_of_servers is L) then (number_of_spares is S) 12.If (mean_delay is M) and (number_of_servers is L) then (number_of_spares is VS)

(39)

Cube FAM of Rule Base 2

VS VS VS VS VS VS VS VS VS VL L M H S VS VS VS VS VS VS VS VS VS M VS VS VS VS VS VS S S VS L s L VS S M m MH   VS VS VS L VS S M S m VS VS VS M S S VS L s S VS VS M VS S M m VS S M m S RS S VS M M RS S L s S M M S M RL M RS L s

(40)

October 2005 39

Step 4: Encode the fuzzy sets, fuzzy rules

and procedures to perform fuzzy

inference into the expert system

To accomplish this task, we may choose one of

two options: to build our system using a

programming language such as C/C++ or Pascal,

or to apply a fuzzy logic development tool such

as

MATLAB Fuzzy Logic Toolbox

or Fuzzy

(41)

Step 5: Evaluate and tune the system

The last, and the most laborious, task is to

evaluate and tune the system. We want to see

whether our fuzzy system meets the

requirements specified at the beginning.

Several test situations depend on the mean

delay, number of servers and repair utilisation

factor.

The Fuzzy Logic Toolbox can generate surface to

help us analyse the system’s performance.

(42)

October 2005 41

Three-dimensional plots for Rule Base 1

0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.2 0.3 0.4 0.5 0.6 number_of_servers mean_delay num ber_of _s pare s

(43)

Three-dimensional plots for Rule Base 1

0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.2 0.3 0.4 0.5 0.6 utilisation_factor mean_delay num ber_of _s pare s

(44)

October 2005 43

Three-dimensional plots for Rule Base 2

0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.15 0.2 0.25 0.3 0.35 number_of_servers mean_delay num ber_of _s pare s

(45)

Three-dimensional plots for Rule Base 2

0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.2 0.3 0.4 utilisation_factor mean_delay num ber_of _s pare s 0.5

(46)

October 2005 45

However, even now, the expert might not be

satisfied with the system performance.

To improve the system performance, we may

use additional sets

Rather

Small and

Rather

Large

on the universe of discourse Number of

Servers, and then extend the rule base.

(47)

Modified fuzzy sets of Number of Servers s

0.1 0 1.0 0.0 0.2 0.4 0.6 0.8 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Number of Servers (normalised)

RS M RL L

S Degree of Membership

(48)

October 2005 47

Cube FAM of Rule Base 3

VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS VS S S VS S S VS VL L M VL RL RS M M S RL M RS L M RS H S M RL L RS s L VS S M m MH   VS VS VS VS VS VS VS VS VS S S VS S S VS L VS S M S M RL L RS m s S VS VS S VS VS RS S VS M RS S M RS S M VS S M m VS S M m S M RL L RS s S M RL L RS s

(49)

Three-dimensional plots for Rule Base 3

0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.15 0.2 0.25 0.3 0.35 number_of_servers mean_delay num ber_of _s pare s

(50)

October 2005 49

Three-dimensional plots for Rule Base 3

0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.2 0.3 0.4 utilisation_factor mean_delay num ber_of _s pare s 0.5

(51)

Tuning fuzzy systems

1. Review model input and output variables, and if

required redefine their ranges.

2. Review the fuzzy sets, and if required define

additional sets on the universe of discourse.

The use of wide fuzzy sets may cause the fuzzy

system to perform roughly.

3. Provide sufficient overlap between neighbouring

sets. It is suggested that triangle-to-triangle and

trapezoid-to-triangle fuzzy sets should overlap

between 25% to 50% of their bases.

(52)

October 2005 51

4. Review the existing rules, and if required add new

rules to the rule base.

5. Examine the rule base for opportunities to write

hedge rules to capture the pathological behaviour

of the system.

6. Adjust the rule execution weights. Most fuzzy

logic tools allow control of the importance of rules

by changing a weight multiplier.

7. Revise shapes of the fuzzy sets. In most cases,

fuzzy systems are highly tolerant of a shape

(53)

 Recap

 Example: Air Conditioner

 Example: Cart Pole Problem

 Case Study: Building a Fuzzy Expert System

 Summary

(54)

October 2005 53

Summary

• Process of developing a fuzzy expert system

• Operation of a fuzzy expert system

• Examples: Air Conditioner; Cart Pole Problem

• Case Study: Building a Fuzzy Expert System

References

Related documents

The implementation consists in putting into practice the previously designed program (Anguera, Chacón, &amp; Sánchez, 2008). Here the following aspects must be assessed: a)

Two possible events are meant to resume the activity of waiting tasks: an I/O operation on a SCSI or network device performed by other tasks or the expiration of their timer. When

In order to present that close analysis the specific work the breast care nurse participants offered as the nature and scope of their work associated with sexuality and body image

F The CFO, a staff management function (not a line management function) is the executive responsible for overseeing the financial operations of an organization, which

Ye, Y.-W., Tang, C.-L.: New existence and multiplicity results of homoclinic orbits for a class of second order Hamiltonian systems. Yuan, R., Zhang, Z.: Homoclinic solutions for

3 In Zagreb, the delegation met with officials of the International Committee of the Red Cross (ICRC), the United Nations High Commissioner for Refugees (UNHCR) and

The usability test consists of two phases: Solving tasks and Debriefing.. In this test, the phases contained the