1 chap 4: fuzzy expert systems part 2 asst. prof. dr. sukanya pongsuparb dr. srisupa palakvangsa na...
TRANSCRIPT
1
Chap 4: Fuzzy Expert SystemsPart 2
Asst. Prof. Dr. Sukanya PongsuparbDr. Srisupa Palakvangsa Na AyudhyaDr. Benjarath Pupacdi
SCCS451 Artificial IntelligenceWeek 10
2
Fuzzy Logic
Unclear
The formal systematic study of the principles of valid inference and correct reasoning
a form of multi-valued logic derived from fuzzy set theory to deal with reasoning that is approximate rather than precise. (Wikipedia)
a theoretical system used in mathematics, computing and philosophy to deal with statements which are neither true nor false (dictionary.cambridge.org)
3
Classical (Crisp) Set
fA (x) called the characteristic function of APrinciple of Dichotomy: a classic set theory imposes a sharp boundary
fA(x): X {0, 1}, where
Ax
Axxf A if0,
if 1,)(
4
Fuzzy Set
A(x): X [0, 1]where
A(x) = 1 if x is totally in A;A(x) = 0 if x is not in A;0 < A(x) < 1 if x is partly in A.
A(x) : membership function of set Amembership value (0<= degree <=1): shows the degree of membershipBasic idea: an element belongs to a fuzzy set with a certain degree of membershipfuzzy set is a set with fuzzy boundaries
5
Linguistic Variables
IF <antecedent> THEN <consequent>
valueobject valueobject
Examples:• IF wind is strong THEN sailing is good• IF speed is slow THEN stopping_distance is short• IF project_duration is long THEN completion_risk is high
Linguistic variable Linguistic value
* linguistic variable == fuzzy variable
6
Hedges
Andy quite likes Thai foodhedges
Mary looks very much like her mother
Jim has been to several attractions in Thailand
Hedges: terms that modify the shape of fuzzy sets e.g. very, somewhat, quite, more or less, and slightly
7
Representation of hedges in fuzzy logicHedge Mathematical
ExpressionHedge MathematicalExpression Graphical Representation
Very very
More or less
Indeed
Somewhat
2 [A ( x )]2
A ( x )
A ( x )
if 0 A 0.5
if 0.5 < A 1
1 2 [1 A ( x )]2
[A ( x )]4 Concentration
dilation
dilation
intensification
8
Operations of fuzzy sets
The classical set theory developed in the late 19th century by Georg Cantor describes how crisp sets caninteract. These interactions are called operations:
- Complement- Containment- Intersection- Union
9
Operations of fuzzy sets
Complement
0x
1
( x )
0x
1
Containment
0x
1
0x
1
A B
Not A
A
Intersection
0x
1
0x
A B
Union0
1
A BA B
0x
1
0x
1
B
A
B
A
( x )
( x )
( x )
10
Set Properties
The properties of set used in crisp sets can also be used in fuzzy setsFrequently used properties:-
CommutativityAssociativelyDistributivityIdempotencyIdentityInvolutionTransitivityDe Morgan’s Laws
11
How can we combine “fuzziness”to our rules ???
12
Fuzzy Rules
Classical IF-THEN ruleRule 1:IF speed is > 100THEN stopping distance is
longRule 2:IF speed is < 70THEN stopping distance is
short
Fuzzy IF-THEN ruleRule 1:IF speed is fastTHEN stopping distance is
longRule 2:IF speed is slowTHEN stopping distance is
shortFuzzy Rules: If the antecedent is true to some degree of membership, then the consequent is also true to that same degree.
13
Tall men Heavy men
180
Degree ofMembership1.0
0.0
0.2
0.4
0.6
0.8
Height, cm
190 200 70 80 100160
Weight, kg
120
Degree ofMembership1.0
0.0
0.2
0.4
0.6
0.8
How to reason?
These fuzzy sets provide the basis for a weight estimation model. The model is based on a relationship between a man’s height and his weight:
IF height is tallTHEN weight is heavy
14
How to reason? (cont.)
The value of the output or a truth membership grade of the rule consequent can be estimated directly from a corresponding truth membership grade in the antecedent. This form of fuzzy inference uses a method called monotonic selection.
Tall menHeavy men
180
Degree ofMembership1.0
0.0
0.2
0.4
0.6
0.8
Height, cm
190 200 70 80 100160
Weight, kg
120
Degree ofMembership1.0
0.0
0.2
0.4
0.6
0.8
15
How about multiple antecedents?
16
Multiple Antecedents
ExamplesIF project_duration is longAND project_staffing is largeAND project_funding is inadequateTHEN risk is high
IF service is excellentOR food is deliciousTHEN tip is generous
17
Multiple Consequences
ExampleIF temperature is hotTHEN hot_water is reduced;
cold_water is increased
18
Fuzzy Inference
Fuzzy inference: a process of mapping from a given input to an output, using the theory of fuzzy setsExamples of inference techniques
Mamdani-Style InferenceSugeno-Style Inference
19
Mamdani-Style Inference
Linguistic variables and linguistic values must be identified
Rule 1:IF project_funding is adequateOR project_staffing is smallTHEN risk is lowRule 2:IF project_funding is marginalAND project_staffing is largeTHEN risk is normalRule 3:IF project_funding is inadequateTHEN risk is high
Rule 1:IF x is A3OR y is B1THEN z is C1Rule 2:IF x is A2AND y is B2THEN z is C2Rule 3:IF x is A1THEN z is C3
20
Mamdani-Style Inference (cont.)
There are four stepsFuzzificationRule EvaluationAggregation of the Rule OutputsDefuzzification
21
Mamdani-Style Inference (cont.)
1) FuzzificationTake crisp inputsDetermine the degree of inputs
Crisp Inputy1
0.1
0.71
0y1
B1 B2
Y
Crisp Input
0.20.5
1
0
A1 A2 A3
x1
x1 X
(x = A1) = 0.5
(x = A2) = 0.2
(y = B1) = 0.1
(y = B2) = 0.7
22
Mamdani-Style Inference (cont.)
2) Rule Evaluation Take fuzzified inputsApply them to the antecedents of the fuzzy rules
AB(x) = min [A(x), B(x)], where xXAB(x) = max [A(x), B(x)] , where xX
Rule 1:IF x is A3 (0.0)OR y is B1 (0.1)THEN z is C1C1(z) = max [A3(x), B1(y)] = max[0.0, 0.1] = 0.1
Rule 2:IF x is A2 (0.2)AND y is B2 (0.7)THEN z is C2C2(z) = min[A2(x), B2(y)] = min[0.2, 0.7] = 0.2
23
Mamdani-Style Inference (cont.)
24
Mamdani-Style Inference (cont.)
The result of the antecedent evaluation can be applied to the membership function of the consequent. – functions can be clipped or scaled
Degree ofMembership1.0
0.0
0.2
Z
Degree ofMembership
Z
C2
1.0
0.0
0.2
C2
25
Mamdani-Style Inference (cont.)
Correlation Minimum (clipping): cut the consequent membership function at the level of the antecedent truthCorrelation Product (scaling): multiplying all membership degrees of the rule consequent by the rule antecedent
26
Mamdani-Style Inference (cont.)
3) Aggregation of the rule outputs Combine all outputs into a single fuzzy set
00.1
1C1
Cz is 1 (0.1)
C2
0
0.2
1
Cz is 2 (0.2)
0
0.5
1
Cz is 3 (0.5)
ZZZ
0.2
Z0
C30.5
0.1
27
Mamdani-Style Inference (cont.)
4) Defuzzification Centroid technique (or centre of gravity – COG): find the point where a vertical line would slice the aggregate set into two equal masses
b
aA
b
aA
dxx
dxxx
COG
( x )
1.0
0.0
0.2
0.4
0.6
0.8
160 170 180 190 200
a b
210
A
150X
28
Mamdani-Style Inference (cont.)
4) Defuzzification (cont.)A reasonable estimate can be obtained by calculating it over a sample of points.
29
Mamdani-Style Inference (cont.)
1.0
0.0
0.2
0.4
0.6
0.8
0 20 30 40 5010 70 80 90 10060
Z
Degree ofMembership
67.4
4.675.05.05.05.02.02.02.02.01.01.01.0
5.0)100908070(2.0)60504030(1.0)20100(
COG
30
Fuzzy Inference
Examples of inference techniquesMamdani-Style InferenceSugeno-Style Inference
31
Sugeno-Style Inference
uses a single spike (singleton) as the member function of the rule consequentSingleton: a fuzzy set with a membership function that is unity at a single particular point on the universe of discourse and zero everywhere elseFormat of rules:-
IF x is AAND y is BTHEN z is f(x,y)
where x, y and z are linguistic variables; A and B fuzzy sets on universe of discourses X and Y respectively; f(x,y) a mathematical function
32
Sugeno-Style Inference (cont.)
Four steps of Sugeno1. Fuzzification -> similar to Mamdani Style2. Rule Evaluation
IF x is AAND y is BTHEN z is k
the output is constant which makes all outputs to be spikes3. Aggregation of the Rule Outputs -> similar to
Mamdani Style
33
Sugeno-Style Inference (cont.)
34
Sugeno-Style Inference (cont.)
4. Defuzzification: use weighted average (WA)
z is k1 (0.1) z is k2 (0.2) z is k3 (0.5) 0
1
0.1Z 0
0.5
1
Z0
0.2
1
Zk1 k2 k3 0
1
0.1Zk1 k2 k3
0.20.5
655.02.01.0
805.0502.0201.0
)3()2()1(
3)3(2)2(1)1(
kkk
kkkkkkWA
0 Z
Crisp Outputz1
z1
35
Mamdani VS Sugeno
MamdaniCapture expert knowledgeExpress knowledge in more human-like mannerNot computationally efficient
SugenoComputationally effectiveWork well with optimisation and adaptive techniquesSuitable for control problems and dynamic nonlinear systems
36
Building Fuzzy Expert Systems
1. Specify the problem and define linguistic variables.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.
37
Building Fuzzy Expert Systems (cont.)
Case studyA service centre keeps spare parts and repairs failed ones.A customer brings a failed item and receives a spare of the same typeFailed parts are repaired, placed on the shelf, and thus become spares.The objective here is to advise a manager of the service centre on certain decision policies to keep the customers satisfied
38
Building Fuzzy Expert Systems (cont.)
1) Specify the problem and define linguistic variablesaverage waiting time (mean delay) mrepair utilisation factor of the service centre number of servers sinitial number of spare parts n
39
Building Fuzzy Expert Systems (cont.)
Linguistic Variable: Mean Delay, mLinguistic Value Notation Numerical Range (normalised)
Very ShortShortMedium
VSSM
[0, 0.3][0.1, 0.5][0.4, 0.7]
Linguistic Variable: Number of Servers, sLinguistic 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
40
Building Fuzzy Expert Systems (cont.)
2) Determine Fuzzy Setsfuzzy sets can have a variety of shapesa triangle or a trapezoid are widely used due to the simplification of the computational processKey point – to maintain sufficient overlap in adjacent fuzzy sets for the fuzzy system to respond smoothly
41
Building Fuzzy Expert Systems (cont.)
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 1Mean Delay (normalised)
SVS M
Degree of Membership
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
M LS
Degree of Membership
Number of Servers (normalised)
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 1Repair Utilisation Factor
M HL
Degree of Membership
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
S RSVS M RL L VL
Degree of Membership
Number of Spares (normalised)
42
Building Fuzzy Expert Systems (cont.)
3) Elicit and construct fuzzy rulesKnowledge acquisition such as
Ask expertsBooksFlow diagramsObservation
Rule construction
43
Building Fuzzy Expert Systems (cont.)
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)
44
Building Fuzzy Expert Systems (cont.)
Rule m s n Rule m s n Rule m s n
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
45
Building Fuzzy Expert Systems (cont.)
VS VS VSVS VS VSVS VS VS
VL L M
HS
VS VS VSVS VS VSVS VS VSM
VS VS VSVS VS VSS S VSL
s
LVS S M
m
MH
VS VS VS
LVS S M
S
m
VS VS VSM
S S VSL
s
S VS VS
MVS S M
m
VS S M
m
S
RS S VSM
M RS SL
s
S
M M SM
RL M RSL
s
46
Building Fuzzy Expert Systems (cont.)
4) Encode the fuzzy sets, fuzzy rules and procedures to perform fuzzy inference into the expert system.
Possible methodsDIY by using programming languages e.g. C, C++fuzzy logic development tool such as MATLAB Fuzzy Logic Toolbox or Fuzzy Knowledge Builder
47
Building Fuzzy Expert Systems (cont.)
5) Evaluate and tune the systemTo check if the system meets the requirementsUse tools to analyse the system performance
48
Building Fuzzy Expert Systems (cont.)
Tuning systemsReview model input and output variables e.g. redefine their rangesReview the fuzzy sets e.g. define additional sets on the universe of discourseProvide sufficient overlap between neighbouring setsReview the existing rules e.g. modify rules, rewrite hedge rulesAdjust the rule execution weightsRevise shapes of the fuzzy sets.
49
Applications of Fuzzy Logic
Air ConditioningDigital Image Processing e.g. edge detectionAutomobile and other vehicle subsystems, such as automatic transmissions, ABS and cruise control (e.g. Tokyo monorail)Home appliances e.g. rice cookers, washing machines, dish washers