程序代写代做代考 CM3112 Artificial Intelligence

CM3112 Artificial Intelligence
Fuzzy logic:
Implicative model of approximate reasoning
Steven Schockaert
SchockaertS1@cardiff.ac.uk
School of Computer Science & Informatics Cardiff University

Modus ponens X is A
if X is A then Y is B Y is B
temperature > 25o
if temperature > 25o then driving time to the beach > 60 minutes
driving time to the beach > 60 minutes

Modus ponens
Y
B
AX
“if X is A then Y is B” puts a restriction on the possible elements in X × Y
Note in particular that we can model this restriction as a relation R from X to Y, in which case B= A∘R

Generalised modus ponens temperature is rather high
if temperature is high then driving time to the beach is long driving time to the beach is quite long
X is A’
fuzzy set A’
if X is A then Y is B fuzzy relation R Y is B’ B’= A’∘R

max T (A(x), R(x, y)) = B(y)
y
T (A(x), R(x, y)  B(y) Modelling if-then rules as fuzzy relations
R(x, y)  IT (A(x), B(y))
It can be shown that this view leads to the following choice for R:
R(x, y) = IT (A(x), B(y))
3

max T (A(x), R(x, y)) = B(y)
y
T (A(x), R(x, y)  B(y) Modelling if-then rules as fuzzy relations
R(x, y)  IT (A(x), B(y))
It can be shown that this view leads to the following choice for R:
R(x, y) = IT (A(x), B(y))
Instead of a residual implicator, it is also possible to use an S-implicator,
but this changes the nature of the rule
‣ With a residual implicator, we are modelling truth-qualifying rules
the more X is A the more it is true that Y is B Example: “If the temperature is high, you need to drink a lot”
‣3
With an S-implicator, we are modelling uncertainty-qualifying rules
the more X is A the more it is certain that Y is B Example: “If the temperature is cold, I come to work by car”


C
D A
B
Modelling if-then rules as fuzzy relations
B⇥(y),
I(T (A1(x), B1(y)), I(B2(y), C2(z)),
In practice:
I(T (A2(x), C2(z)), AruleifXisAthenYisB istheninterpretedasyisBis
n
x,y
= min(Sx0 (x0), Sy0 (y0), min I(T (Ai(x0),
n
i=1
‣ inputs are usually precise
we may have more than one input
‣ C (z) = supmin(S
(x),S (y),minI(T(A (x), x0 y0 i=1 i
‣ we may have more than one rule ⇥
X is Su
Y is Sv
if X is A1 and Y is B1 then Z is C1 if X is A2 and Y is B2 then Z is C2 …
if X is An and Y is Bn then Z is Cn Z is C’
n i=1
= min I(T (Ai(x0), Bi(y0)), Ci(z))
singleton fuzzy set
Su(x) = 0
otherwise
⇤1 if x = u

max T (A(x), R(x, y)) = B(y) y
Modelling if-then rules as fuzzy relations
T (A(x), R(x, y)  B(y) Inthiscase,weevaluRat(ext,hye)resuIlta(sA:(x),B(y))
T
choice of t-norm doesn’t matter, since all
R(x, y) = IT (A(x), B(y))
but one argument are taken from {0,1}
0n
C (z) = maxmin(Su(x),Sv(y),minI(T(Ai(x),Bi(y)),Ci(z)))
x,y i=1 n
= min I(T (Ai(x), Bi(y)), Ci(z)) i=1
3

max T (A(x), R(x, y)) = B(y) y
Modelling if-then rules as fuzzy relations
T (A(x), R(x, y)  B(y) Inthiscase,weevaluRat(ext,hye)resuIlta(sA:(x),B(y))
T
choice of t-norm doesn’t matter, since all
R(x, y) = IT (A(x), B(y))
but one argument are taken from {0,1}
0n
C (z) = maxmin(Su(x),Sv(y),minI(T(Ai(x),Bi(y)),Ci(z)))
x,y i=1 n
= min I(T (Ai(x), Bi(y)), Ci(z)) i=1
Implicator used to model the rule (could be different for each rule)
t-norm used to combine the different conditions in the antecedent (could be different for each rule)
3

max T (A(x), R(x, y)) = B(y) y
Modelling if-then rules as fuzzy relations
T (A(x), R(x, y)  B(y) Inthiscase,weevaluRat(ext,hye)resuIlta(sA:(x),B(y))
T
choice of t-norm doesn’t matter, since all
R(x, y) = IT (A(x), B(y))
but one argument are taken from {0,1}
0n
C (z) = maxmin(Su(x),Sv(y),minI(T(Ai(x),Bi(y)),Ci(z)))
x,y i=1 n
= min I(T (Ai(x), Bi(y)), Ci(z)) i=1
Usually the minimum is used to combine the rules
Implicator used to model the rule (could be different for each rule)
t-norm used to combine the different conditions in the antecedent (could be different for each rule)
3

max T (A(x), R(x, y)) = B(y) y
Modelling if-then rules as fuzzy relations
T (A(x), R(x, y)  B(y) Inthiscase,weevaluRat(ext,hye)resuIlta(sA:(x),B(y))
T
R(x, y) = IT (A(x), B(y))
0n
C (z) = maxmin(Su(x),Sv(y),minI(T(Ai(x),Bi(y)),Ci(z)))
x,y i=1 n
= min I(T (Ai(u), Bi(v)), Ci(z)) i=1
activation level of the rule
consequent of the rule
3

Example
if oil price if oil price if oil price if oil price if oil price if oil price if oil price if oil price if oil price
is cheap and temperature is cold then heating is high
is cheap and temperature is warm then heating is high
is cheap and temperature is hot then heating is medium
is medium and temperature is cold then heating is high
is medium and temperature is warm then heating is medium is medium and temperature is hot then heating is low
is expensive and temperature is cold then heating is medium is expensive and temperature is warm then heating is low
is expensive and temperature is hot then heating is low

Example
cheap
medium expensive
cold
warm hot

oC
low
medium high
%

Example
cheap medium expensive
cold warm hot

oC
input: oil price = €65 temperature = 18oC
Cheap(65) = 0.4 Medium(65) = 0.6
Cold(18) = 0.2 Warm(18) = 0.8

Example
if oil price is cheap and temperature is cold then heating is high
if oil price is cheap and temperature is warm then heating is high
if oil price is cheap and temperature is hot then heating is medium
if oil price is medium and temperature is cold then heating is high
if oil price is medium and temperature is warm then heating is medium if oil price is medium and temperature is hot then heating is low
if oil price is expensive and temperature is cold then heating is medium if oil price is expensive and temperature is warm then heating is low
if oil price is expensive and temperature is hot then heating is low
0.4 x 0.2 = 0.08 0.4 x 0.8 = 0.32 0.4 x 0 = 0 0.6 x 0.2 = 0.12 0.6 x 0.8 = 0.48
0.6 x 0 = 0 0 x 0.2 = 0 0 x 0.8 = 0
0 x 0 = 0
Cheap(65) = 0.4, Medium(65) = 0.6, Cold(18) = 0.2, Warm(18) = 0.8

Example
We have conclusion “high” with activation level 0.32 “medium” with activation level 0.48
C’(x) = min(IT(0.32,High(x)), IT(0.48,Medium(x)))

Example
IT(0.32,High(x)) with T = TM

Example
IT(0.32,High(x)) with T = TP

Example
IT(0.32,High(x)) with T = TW

Example
IT(0.48,Medium(x)) with T = TM

Example
IT(0.48,Medium(x)) with T = TP

Example
IT(0.48,Medium(x)) with T = TW

Example
C’(x) = min(IT(0.32,High(x)), IT(0.48,Medium(x))) with T = TM

Example
C’(x) = min(IT(0.32,High(x)), IT(0.48,Medium(x))) with T = TP

Example
C’(x) = min(IT(0.32,High(x)), IT(0.48,Medium(x))) with T = TW

Defuzzification
In the end, the application needs a precise value
oil = 65 temp = 18
fuzzy inference
heating = 75
defuzzification

S (x) = ⇤
C
C
u
0 otherwise C⇥ =maxT1(T2(Ai(u),Bi(v)),
Defuzzification
Usually the centre of gravity of the fuzzy set C’ is used:
n i=1
inputs
fuzzy inference
C’
n
C⇥ =minI(T(Ai(u),Bi(v)),
i=1
⌅ab xC⇥(x)dx
⌅b C⇥(x)dx a
5
defuzzification