Date post: | 02-Jun-2018 |
Category: |
Documents |
Upload: | girish-patil |
View: | 230 times |
Download: | 0 times |
of 54
8/11/2019 Week7 Fuzzy Logic Tutorial
1/54
October 2005 0
Fuzzy Expert SystemsCS364 Artificial Intelligence
8/11/2019 Week7 Fuzzy Logic Tutorial
2/54
October 2005 1
Recap
Example: Air Conditioner
Example: Cart Pole ProblemCase Study: Building a Fuzzy Expert System
Summary
Fuzzy Expert Systems
8/11/2019 Week7 Fuzzy Logic Tutorial
3/54
October 2005 2
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 proceduresto perform fuzzy inference into the expert system.
5. Evaluate and tune the system.
Process of developing a fuzzy expert system:
8/11/2019 Week7 Fuzzy Logic Tutorial
4/54
October 2005 3
Fuzzification: definition of fuzzy sets, anddetermination of the degree of membership of crisp
inputs in appropriate fuzzy sets.
Recap
Inference: evaluation of fuzzy rules to producean output for each rule.
Composition: aggregation or combination ofthe outputs of all rules.
Defuzzification: computation of crisp output
Operation of a fuzzy expert system:
8/11/2019 Week7 Fuzzy Logic Tutorial
5/54
October 2005 4
Recap
Example: Air Conditioner
Example: Cart Pole ProblemCase Study: Building a Fuzzy Expert System
Summary
Fuzzy Expert Systems
8/11/2019 Week7 Fuzzy Logic Tutorial
6/54
October 2005 5
Example: Air Conditioner
1a. Specify the problem Air-conditioning involves the delivery of air, which can bewarmed or cooled and have its humidity raised or lowered.
An air-conditioner is an apparatus for controlling, especiallylowering, the temperature and humidity of an enclosedspace. An air-conditioner typically has a fan whichblows/cools/circulates fresh air and has a cooler. The cooleris controlled by a thermostat. Generally, the amount of airbeing compressed is proportional to the ambient
temperature.
1b. Define linguistic variables Ambient Temperature
Air-conditioner Fan Speed
8/11/2019 Week7 Fuzzy Logic Tutorial
7/54October 2005 6
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 )
8/11/2019 Week7 Fuzzy Logic Tutorial
8/54
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
t h V a
l u e Cold
CoolPleasentWarm
Hot
a
8/11/2019 Week7 Fuzzy Logic Tutorial
9/54
October 2005 8
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 N20 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 N70 N N N Y* N
80 N N N Y Y
90 N N N N Y
100 N N N N Y*
8/11/2019 Week7 Fuzzy Logic Tutorial
10/54
October 2005 9
Example: Air Conditioner
2. Determine Fuzzy Sets: Fan Speed Speed Fuzzy Sets
0
0.2
0.4
0.60.8
1
0 10 20 30 40 50 60 70 80 90 100
Speed
T r u
t h V a
l u e MINIMALSLOWMEDIUMFASTBLAST
8/11/2019 Week7 Fuzzy Logic Tutorial
11/54
October 2005 10
Example: Air Conditioner
3. Elicit and construct fuzzy rules
RULE 1: IF temp is cold THEN speed is minimalRULE 2: IF temp is cool THEN speed is slow
RULE 3: IF temp is pleasant THEN speed is mediumRULE 4: IF temp is warm THEN speed is fastRULE 5: IF temp is hot THEN speed is blast
8/11/2019 Week7 Fuzzy Logic Tutorial
12/54
October 2005 11
Example: Air Conditioner
3. Encode into an Expert System 4. Evaluate and tune the system
Consider a temperature of 16 oC, use the system
to compute the optimal fan speed.
Operation of a Fuzzy Expert System
Fuzzification
Inference Composition Defuzzification
8/11/2019 Week7 Fuzzy Logic Tutorial
13/54
October 2005 12
Example: Air Conditioner
FuzzificationAffected 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
8/11/2019 Week7 Fuzzy Logic Tutorial
14/54
October 2005 13
Example: Air Conditioner
Inference
RULE 1: IF temp is cold THEN speed is minimalRULE 2: IF
temp is
cool THEN
speed is
slowRULE 3: IF temp is pleasant THEN speed is mediumRULE 4: IF temp is warm THEN speed is fastRULE 5: IF temp is hot THEN speed is blast
8/11/2019 Week7 Fuzzy Logic Tutorial
15/54
October 2005 14
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
8/11/2019 Week7 Fuzzy Logic Tutorial
16/54
October 2005 15
Example: Air Conditioner Composition
speed is slow (0.3) speed is medium (0.4)+
8/11/2019 Week7 Fuzzy Logic Tutorial
17/54
October 2005 16
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
= 45.54rpm
8/11/2019 Week7 Fuzzy Logic Tutorial
18/54
October 2005 17
Recap
Example: Air Conditioner
Example: Cart Pole ProblemCase Study: Building a Fuzzy Expert System
Summary
Fuzzy Expert Systems
8/11/2019 Week7 Fuzzy Logic Tutorial
19/54
October 2005 18
Example: Cart Pole Problem
The problem is to balance an upright pole, with a mass m at itshead and mass M at its base. A weightless shaft connects these
two masses. The base can be moved on a horizontal axis. Thetask is to determine the FORCE ( F ) necessary to balance the pole.The calculation of the force F involves the measurement of theangle and the angular velocity, w of the pole .
M
m
g
w
8/11/2019 Week7 Fuzzy Logic Tutorial
20/54
October 2005 19
n b n m n s a z p s p m p b
n b p s p b
n m p m
n s n m n s p s
a z n b n m n s a z p s p m p b
p s n s p s p m
p m n m
p b n b n s
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
w
8/11/2019 Week7 Fuzzy Logic Tutorial
21/54
October 2005 20
Example: Cart Pole ProblemThe 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 ifw=
w) =1 ifw=
w) = if
w>=
w
8/11/2019 Week7 Fuzzy Logic Tutorial
22/54
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 computethe force F necessary to balance the pole using the Centre ofGravity in the Defuzzification task.
(a) Based on the fuzzy sets table draw three graphs showingthe fuzzy sets ( nb , nm , ns , az , ps , pm , pb ) for each , w, and F individually.
8/11/2019 Week7 Fuzzy Logic Tutorial
23/54
October 2005 22
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 pmIF is pb AND w is az THEN F is pb
8/11/2019 Week7 Fuzzy Logic Tutorial
24/54
October 2005 23
Example: Cart Pole ProblemFuzzification
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.55045
11/22.5 = /5
= 0.22
1
w: az 1/11.25 = /6.25 = 0.56
8/11/2019 Week7 Fuzzy Logic Tutorial
25/54
October 2005 24
Example: Cart Pole ProblemInference
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
8/11/2019 Week7 Fuzzy Logic Tutorial
26/54
October 2005 25
Example: Cart Pole ProblemComposition
ps
pb
Defuzzification
3 0.2 (4 5 6) 0.56 (7 8) 0.225.30
0.2 0.56 0.56 0.56 0.22 0.22SoG
= =
C
8/11/2019 Week7 Fuzzy Logic Tutorial
27/54
October 2005 26
Recap
Example: Air Conditioner
Example: Cart Pole ProblemCase Study: Building a Fuzzy Expert System
Summary
Fuzzy Expert Systems
8/11/2019 Week7 Fuzzy Logic Tutorial
28/54
October 2005 27
A service centre keeps spare parts and repairs failed ones. A customerbrings a failed item and receives a spare of the same type. Failedparts 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 FuzzyExpert System
Step 1: Specify the problem and definelinguistic variables
There are four main linguistic variables : average waiting time (meandelay) m, repair utilisation factor of the service centre , number ofservers s , and initial number of spare parts n.
8/11/2019 Week7 Fuzzy Logic Tutorial
29/54
October 2005 28
Linguistic variables and their rangesLinguistic Variable: Mean Delay , m
Linguistic Value Notation Numerical Range (normalised)Very Short
ShortMedium
VS
SM
[0, 0.3]
[0.1, 0.5][0.4, 0.7]Linguistic Variable: Number of Servers , s
Linguistic Value Notation Numerical Range (normalised)SmallMediumLarge
SML
[0, 0.35][0.30, 0.70]
[0.60, 1]
Linguistic Variable: Repair Utilisation Factor ,Linguistic Value Notation Numerical Range
LowMediumHigh
LMH
[0, 0.6][0.4, 0.8][0.6, 1]
Linguistic Variable: Number of Spares , nLinguistic Value Notation Numerical Range (normalised)
Very SmallSmallRather SmallMediumRather LargeLargeVery Large
VSS
RSMRLL
VL
[0, 0.30][0, 0.40]
[0.25, 0.45][0.30, 0.70][0.55, 0.75]
[0.60, 1][0.70, 1]
Linguistic Variable: Mean Delay , m
Linguistic Variable: Number of Servers , s
Linguistic Variable: Repair Utilisation Factor ,
Linguistic Variable: Number of Spares , n
8/11/2019 Week7 Fuzzy Logic Tutorial
30/54
October 2005 29
Step 2: Determine fuzzy sets
Fuzzy sets can have a variety of shapes.However, a triangle or a trapezoid can oftenprovide an adequate representation of the expert
knowledge, and at the same time, significantlysimplifies the process of computation.
8/11/2019 Week7 Fuzzy Logic Tutorial
31/54
October 2005 30
Fuzzy sets of M ean Delay m
0.10
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)
SVS M
Degree of Membership
8/11/2019 Week7 Fuzzy Logic Tutorial
32/54
October 2005 31
Fuzzy sets of Number of Servers s
0.10
1.0
0.0
0.2
0.40.6
0.8
0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
M LS
Degree of Membership
Number of Servers (normalised)
8/11/2019 Week7 Fuzzy Logic Tutorial
33/54
October 2005 32
Fuzzy sets of Repair Util isation F actor
0.10
1.0
0.0
0.2
0.40.6
0.8
0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1epair Utilisation Factor
M HL
Degree of Membership
8/11/2019 Week7 Fuzzy Logic Tutorial
34/54
October 2005 33
Fuzzy sets of Number of Spares n
0.10
1.0
0.0
0.2
0.40.6
0.8
0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
S RSVS M RL L VL
Degree of Membership
Number of Spares (normalised)
8/11/2019 Week7 Fuzzy Logic Tutorial
35/54
October 2005 34
Step 3: Elicit and construct fuzzy rules
To accomplish this task, we might ask the expertto describe how the problem can be solved usingthe fuzzy linguistic variables defined previously.
Required knowledge also can be collected fromother sources such as books, computerdatabases, flow diagrams and observed human
behaviour.
8/11/2019 Week7 Fuzzy Logic Tutorial
36/54
8/11/2019 Week7 Fuzzy Logic Tutorial
37/54
October 2005 36
The rule table
Rule m s n Rule m s n Rule m s n1 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 M5 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 M9 M L L VS 18 M L M S 27 M L H RS
8/11/2019 Week7 Fuzzy Logic Tutorial
38/54
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)
8/11/2019 Week7 Fuzzy Logic Tutorial
39/54
8/11/2019 Week7 Fuzzy Logic Tutorial
40/54
October 2005 39
Step 4: Encode the fuzzy sets, fuzzy rulesand procedures to perform fuzzyinference into the expert system
To accomplish this task, we may choose one oftwo options: to build our system using aprogramming language such as C/C++ or Pascal,or to apply a fuzzy logic development tool suchas MATLAB Fuzzy Logic Toolbox or FuzzyKnowledge Builder.
8/11/2019 Week7 Fuzzy Logic Tutorial
41/54
October 2005 40
Step 5: Evaluate and tune the system
The last, and the most laborious, task is toevaluate and tune the system. We want to seewhether our fuzzy system meets therequirements specified at the beginning.
Several test situations depend on the meandelay, number of servers and repair utilisationfactor.
The Fuzzy Logic Toolbox can generate surface tohelp us analyse the systems performance.
8/11/2019 Week7 Fuzzy Logic Tutorial
42/54
October 2005 41
Three-dimensional plots for Rule Base 1
00.2
0.40.6
0.81
00.2
0.4
0.6
0.2
0.3
0.4
0.5
0.6
number_of_serversmean_delay
n u m b e r
_ o f_ s p a r e s
8/11/2019 Week7 Fuzzy Logic Tutorial
43/54
October 2005 42
Three-dimensional plots for Rule Base 1
00.2
0.40.6
0.81
0
0.2
0.4
0.6
0.2
0.3
0.4
0.5
0.6
utilisation_factormean_delay
n u m b e r_ o f_ s p a r e s
8/11/2019 Week7 Fuzzy Logic Tutorial
44/54
October 2005 43
Three-dimensional plots for Rule Base 2
00.2
0.40.6
0.81
0
0.2
0.4
0.6
0.15
0.2
0.25
0.3
0.35
number_of_serversmean_delay
n u m b e r
_ o f_ s p a r e s
8/11/2019 Week7 Fuzzy Logic Tutorial
45/54
October 2005 44
Three-dimensional plots for Rule Base 2
00.2
0.40.6
0.81
0
0.2
0.4
0.6
0.2
0.3
0.4
utilisation_factormean_delay
n u m b e r_ o f_ s p a r e s
0.5
8/11/2019 Week7 Fuzzy Logic Tutorial
46/54
October 2005 45
However, even now, the expert might not be
satisfied with the system performance.
To improve the system performance, we mayuse additional sets Rather Small and Rather Large on the universe of discourse Number ofServers , and then extend the rule base.
Tune the system.
8/11/2019 Week7 Fuzzy Logic Tutorial
47/54
8/11/2019 Week7 Fuzzy Logic Tutorial
48/54
Th di i l l f R l B 3
8/11/2019 Week7 Fuzzy Logic Tutorial
49/54
October 2005 48
Three-dimensional plots for Rule Base 3
00.2
0.40.6
0.81
0
0.2
0.4
0.6
0.15
0.2
0.25
0.3
0.35
number_of_serversmean_delay
n u m b e r_ o f_ s p a r e s
Th di i l l f R l B 3
8/11/2019 Week7 Fuzzy Logic Tutorial
50/54
October 2005 49
Three-dimensional plots for Rule Base 3
00.2
0.40.6
0.81
0
0.2
0.4
0.6
0.2
0.3
0.4
utilisation_factormean_delay
n u m b e r_ o f_ s p a r e s
0.5
8/11/2019 Week7 Fuzzy Logic Tutorial
51/54
October 2005 50
Tuning fuzzy systems
1. Review model input and output variables, and ifrequired redefine their ranges.
2. Review the fuzzy sets, and if required defineadditional sets on the universe of discourse.
The use of wide fuzzy sets may cause the fuzzysystem to perform roughly.
3. Provide sufficient overlap between neighbouring
sets. It is suggested that triangle-to-triangle andtrapezoid-to-triangle fuzzy sets should overlapbetween 25% to 50% of their bases.
8/11/2019 Week7 Fuzzy Logic Tutorial
52/54
October 2005 51
4. Review the existing rules, and if required add newrules to the rule base.
5. Examine the rule base for opportunities to writehedge rules to capture the pathological behaviourof the system.
6. Adjust the rule execution weights. Most fuzzylogic tools allow control of the importance of rulesby changing a weight multiplier.
7. Revise shapes of the fuzzy sets. In most cases,fuzzy systems are highly tolerant of a shapeapproximation.
8/11/2019 Week7 Fuzzy Logic Tutorial
53/54
October 2005 52
Recap
Example: Air Conditioner
Example: Cart Pole Problem
Case Study: Building a Fuzzy Expert System
Summary
Fuzzy Expert Systems
8/11/2019 Week7 Fuzzy Logic Tutorial
54/54
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