15
Fuzzy logic Fuzzy logic Developing Developing Fuzzy Expert Systems Fuzzy Expert Systems Aleksandar Raki Aleksandar Raki ć ć rakic rakic @etf.rs @etf.rs

Fuzzy Logic 4 Swapnil

Embed Size (px)

DESCRIPTION

fuzzy controller

Citation preview

Page 1: Fuzzy Logic 4 Swapnil

Fuzzy logicFuzzy logic

DevelopingDeveloping

Fuzzy Expert SystemsFuzzy Expert SystemsAleksandar RakiAleksandar Rakićć

[email protected]@etf.rs

Page 2: Fuzzy Logic 4 Swapnil

2

Fuzzy Expert System Fuzzy Expert System Development Process Development Process

1. Specify the problem; define linguistic variables.

2. Determine fuzzy sets.

3. Bring out 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.

Page 3: Fuzzy Logic 4 Swapnil

3

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

• Air-conditioner Fan Speed

Example: Air ConditionerExample: Air Conditioner

Page 4: Fuzzy Logic 4 Swapnil

4

2. Determine Fuzzy Sets

Fuzzy sets can have a variety of shapes.Fuzzy sets can have a variety of shapes.

However, a triangle or a trapezoid can often provide However, a triangle or a trapezoid can often provide an adequate representation of the expert an adequate representation of the expert knowledge, and at the same time, significantly knowledge, and at the same time, significantly simplifies the process of computation.simplifies the process of computation.

Fuzzy sets are defined both for input and output Fuzzy sets are defined both for input and output variables!variables!

Page 5: Fuzzy Logic 4 Swapnil

5

2. Determine Fuzzy Sets: TemperatureTemp Temp ((00C).C).

COLCOLDD

COOLCOOL PLEASAPLEASANTNT

WARWARMM

HOHOTT

00 Y*Y* NN NN NN NN

55 YY YY NN NN NN

1010 NN YY NN NN NN

12.512.5 NN Y*Y* NN NN NN

1515 NN YY NN NN NN

17.517.5 NN NN Y*Y* NN NN

2020 NN NN NN YY NN

22.522.5 NN NN NN Y*Y* NN

2525 NN NN NN YY NN

27.527.5 NN NN NN NN YY

3030 NN NN NN NN Y*Y*

Temp Temp ((00C).C).

COLCOLDD

COOLCOOL PLEASANPLEASANTT

WARMWARM HOTHOT

0< (T)<1

(T)=1 (T)=0

Example: Air ConditionerExample: Air Conditioner

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

Tru

th V

alu

e

Cold

Cool

Pleasent

Warm

Hot

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

Cold

Cool

Pleasent

Warm

Hot

Page 6: Fuzzy Logic 4 Swapnil

6

2. Determine Fuzzy Sets: Fan SpeedRev/secRev/sec

(RPM)(RPM)MINIMALMINIMAL SLOWSLOW MEDIUMMEDIUM FASTFAST BLASTBLAST

00 Y*Y* NN NN NN NN

1010 YY NN NN NN NN

2020 YY YY NN NN NN

3030 NN Y*Y* NN NN NN

4040 NN YY NN NN NN

5050 NN NN Y*Y* NN NN

6060 NN NN NN YY NN

7070 NN NN NN Y*Y* NN

8080 NN NN NN YY YY

9090 NN NN NN NN YY

100100 NN NN NN NN Y*Y*

Example: Air Conditioner

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

alu

e MINIMAL

SLOW

MEDIUM

FAST

BLAST

Page 7: Fuzzy Logic 4 Swapnil

7

3. Bring out and construct fuzzy rules

RULE 1: IF RULE 1: IF temp is is cold THEN THEN speed is is minimalRULE 2: IF RULE 2: IF temp is is cool THEN THEN speed is is slowRULE 3: IF RULE 3: IF temp is is pleasant THEN THEN speed is is mediumRULE 4: IF RULE 4: IF temp is is warm THEN THEN speed is is fastRULE 5: IF RULE 5: IF temp is is hot THEN THEN speed is is blast

Example: Air ConditionerExample: Air Conditioner

To accomplish this task, we might ask the expert to To accomplish this task, we might ask the expert to describe how the problem can be solved using the describe how the problem can be solved using the fuzzy linguistic variables defined previously.fuzzy linguistic variables defined previously.

Required knowledge also can be collected from other Required knowledge also can be collected from other sources such as books, computer databases, flow sources such as books, computer databases, flow diagrams and observed human behaviour. diagrams and observed human behaviour.

Page 8: Fuzzy Logic 4 Swapnil

8

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 To accomplish this task, we may choose one of two options:options:

to build our system using a programming language to build our system using a programming language such as C/C++ or Pascal, orsuch as C/C++ or Pascal, or

to apply a fuzzy logic development tool such asto apply a fuzzy logic development tool such asMATLAB Fuzzy Logic ToolboxMATLAB Fuzzy Logic Toolbox or Fuzzy Knowledge or Fuzzy Knowledge Builder.Builder.

Page 9: Fuzzy Logic 4 Swapnil

9

5. Evaluate and tune the system The last, and the most laborious, task is to evaluate and The last, and the most laborious, task is to evaluate and

tune the system. We want to see whether our fuzzy tune the system. We want to see whether our fuzzy system meets the requirements specified at the system meets the requirements specified at the beginning. beginning.

Evaluation of the systemEvaluation of the system output is performed for test output is performed for test situations on the several representative values of input situations on the several representative values of input variables. Fuzzy Logic development tools often can variables. Fuzzy Logic development tools often can generate surface to help us evaluate and analyze the generate surface to help us evaluate and analyze the system’s performance.system’s performance.

Tuning of the systemTuning of the system consists of reviewing, adding consists of reviewing, adding and/or changing the membership functions and rules in and/or changing the membership functions and rules in order to increase the performance of the system.order to increase the performance of the system.

Page 10: Fuzzy Logic 4 Swapnil

10

5a. Evaluate the system

Consider a temperature of 16oC, use the system to compute the optimal fan speed.

Example: Air ConditionerExample: Air Conditioner

RECALL: Operation of a fuzzy expert system: Fuzzification: determination of the degree of

membership of crisp inputs in appropriate fuzzy sets. Inference: evaluation of fuzzy rules to produce an

output for each rule. Aggregation: combination of the outputs of all rules. Defuzzification: computation of crisp output

Page 11: Fuzzy Logic 4 Swapnil

11

• 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

Example: Air ConditionerExample: Air Conditioner

Page 12: Fuzzy Logic 4 Swapnil

12

• InferenceRULE 1: IFRULE 1: IF temp is is cold THEN THEN speed is is minimalRULE 2: IF RULE 2: IF temp is is cool THEN THEN speed is is slowRULE 3: IF RULE 3: IF temp is is pleasant THEN THEN speed is is mediumRULE 4: IF RULE 4: IF temp is is warm THEN THEN speed is is fastRULE 5: IF RULE 5: IF temp is is hot THEN THEN speed is is blast

Example: Air ConditionerExample: 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)

Page 13: Fuzzy Logic 4 Swapnil

13

• Aggregation

Example: Air ConditionerExample: Air Conditioner

• Defuzzification

speed is slow (0.3) speed is medium (0.4)+

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) = 45.54rpm 0.125 + 0.25 + 0.3(11) + 0.4(5) + 0.25

Page 14: Fuzzy Logic 4 Swapnil

14

Input – Output PlotInput – Output Plot

00.2

0.40.6

0.81

0

0.2

0.4

0.6

0.2

0.3

0.4

0.5

0.6

number_of_serversmean_delayn

um

be

r_o

f_sp

are

s

0 5 10 15 20 25 300

10

20

30

40

50

60

70

80

90

100

temp

fan-

spee

d

Example: Air Example: Air ConditionerConditioner

one input – one outputone input – one outputgives nonlinear transfer gives nonlinear transfer

characteristiccharacteristicMore general example:More general example:

two inputs – one two inputs – one output gives 3D output gives 3D transfer surfacetransfer surface

Page 15: Fuzzy Logic 4 Swapnil

15

5b. Tune fuzzy system to improve performance

Review model input and output variables, and if required Review model input and output variables, and if required redefine their ranges.redefine their ranges.

Review the fuzzy sets, and if required define additional sets Review the fuzzy sets, and if required define additional sets on the universe of discourse. The use of wide fuzzy sets may on the universe of discourse. The use of wide fuzzy sets may cause the fuzzy system to perform roughly.cause the fuzzy system to perform roughly.

Provide sufficient overlap between neighbouring sets. It is Provide sufficient overlap between neighbouring sets. It is suggested that triangle-to-triangle and trapezoid-to-triangle suggested that triangle-to-triangle and trapezoid-to-triangle fuzzy sets should overlap between 25% to 50% of their fuzzy sets should overlap between 25% to 50% of their bases.bases.

Review the existing rules, and if required add new rules to Review the existing rules, and if required add new rules to the rule base.the rule base.

Examine the rule base for opportunities to write hedge rules Examine the rule base for opportunities to write hedge rules to capture the pathological behaviour of the system.to capture the pathological behaviour of the system.

Adjust the rule execution weights. Most fuzzy logic tools Adjust the rule execution weights. Most fuzzy logic tools allow control of the importance of rules by changing a weight allow control of the importance of rules by changing a weight multiplier.multiplier.

Revise shapes of the fuzzy sets. In most cases, fuzzy Revise shapes of the fuzzy sets. In most cases, fuzzy systems are highly tolerant of a shape approximation.systems are highly tolerant of a shape approximation.