Fuzzy Inference and It’
s
Applications
模糊推論與應用
國立臺南大學 黃國禎
數位學習科技系 教授
資訊教育研究所 所長
理工學院 院長
Fuzzy set and Fuzzy Logic
why “
Fuzzy Subset”?
Ordinary set -- the foundation of present day
mathematics.(S)
S : a set
e5 : an element
But in real world , the relation is usually “
fuzzy”!
John is 170 cm John : an element } , , , { 2 3 5 6 5 S e e e e e } | { x x is tall or
S = {x|x is tall} 180cm 高的人 S ? Yes 179cm 高的人 S ? Yes (179 和180只差 1cm) 178cm 高的人 S ? Yes (178 和179 只差 1cm) • • • 170cm 高的人 S ? Yes (170 和171 只差 1cm) 169cm 高的人 S ? Yes No (169 和170 只差 1cm) • • • 120cm 高的人 S ? Yes (120 和121 只差 1cm) Why? 既然170是, 為何169不是?
S ={x|x is tall} 假如找100個人投票,互相推選屬於S和不屬於S的人 150cm 160cm 170cm 180cm 0 0 1 0.5
John is 180cm John S with degree 1.0 John is 165cm John S with degree 0.5 John is 150cm John S with degree 0
ordinary set is a particular case of the
theory of fuzzy subset.
let E be a set and A be a subset of E
A
E
Characteristic function
(x)
x)
= 1
if x
A(yes)
x)
= 0
if x
A(no)
e.g. E={x1,x2,x3,x4,x5}
let A = {x2,x3,x5}
x
1) = 0,
x
2) = 1,
x
3)= 1
x
4) = 0,
x
5) = 1
A different representation
A = {(x1,0),(x2,1),(x3,1),(x4,0),(x5,1)} AA= 0 A A= E IF x A , x A (x)= 1, A(x)= 0 consider A ={x2,x3,x5}A(x1) = 1, A(x2) = 0, A(x3) = 0 A(x4) = 1, A(x5) = 0
Given two subsets A and B (x) = 1, if x A = 0, if x A (x) = 1, if x B = 0, if x AB(x)= 1, if x AB = 0, if x AB AB(x)= (x) •(x) 0 1 0 1 0 0 0 1 Boolean product
Union AB (x)= 1, if x AB = 0, if x AB AB (x)= (x) (x) Boolean sum e.g. E = {x1,x2,x3,x4,x5} two subsets A and B
A={x2,x3,x5}, B={x1,x3,x5} AB = {(x1,0 1),(x2,1 0), (x3,1 1),(x4,0 0),(x5,1 1)} = {(x1,1),(x2,1),(x3,1),(x4,0),(x5,1)} 0 1 0 1 0 1 1 1
•The concept of Fuzzy Subset
x
iof E
或多或少
是A的元素
A = {(x1|0.2),(x2|0),(x3|0.3),(x4|1),(x5|0.8)}
Fuzzy Subset x1屬於A的 程度 (可能由0~1.0)
A E A is a Fuzzy Subset of E x2A A E x1, x2, x3 0.2 0 0.3 membership 通常是主觀的認定,但至少 表達了Xis之間的相對程度
Zadehs definition of Fuzzy subset
Let E be a set, denumerable or not, let x be an element of E. Then Fuzzy subset A of E is a set of ordered pairs {(x|(x)},
xE.
Where (x) : grade of membership of x in A
(x) takes its values in a set M (membership set)
x M
IF M={0,1}
fuzzy subsetof A will be a nonfuzzy subset (or ordinary set)
mapping
E.g.
Let N be the set of natural numbers
N = {0,1,2,3,4,5,6,...}
consider the fuzzy set A of
small
natural
numbers
A = {(0/1),(1/0.8),(2/0.6),(3/0.4),(4/0.2),(5/0),(6/0),...}
用傳統的ordinary set很難表達
A = {(0,1),(1,1),(2,1),(3,1),(4,1),(5,0),(6,0),...}S- Function
S (x; )= 0 for x 2[(x- )/()]2 for x 1- 2[(x- )/()]2 for x 1 for x 1 0.5 0 Membership Function
A membership Function for the Fuzzy Set TALL
1.0 0.9 0.5 6.5 Height in Feet6 7
TALLS (x;
)=
0 for x 2[(x- 5)/(7)]2 = [(x- 5) 2/2] for 5x 1- 2[(x- 7)/(7)]2 =1-[(x- 7) 2 /2] for 6x 1 for xclose(x; 1
1
2
(
x )
with crossover points x = 1.0 0.5 x
Close- Function
close(x; E = { x|x= 價格合理的牛排 ?} 220NT 120 =220NT =120NT 0.5 1.0 220NT 100 340 close(x;
x
for
x
S
x
for
x
S
x
)
,
,
;
(
1
)
,
,
;
(
)
,
;
(
2 2function
0.5 1 x價格合理的牛排 220 ) 420 , 320 , 220 ; ( 1 220 ) 220 , 120 , 20 ; ( ) 200 , 220 ; ( x for x S x for x S x
0.5 1 220NT 120 320 Fuzzy Database systems
找一個停車容易,且價格合理的餐廳 以停車為優先考慮 E = {x|x = 離火車站近的餐館}
Km
d1 d2 d5 d4 d3Fuzzy Logic
Binary Logic: The logic associated with the Boolean theory of set Fuzzy Logic : The Logic associated with the same manner with the
theory of fuzzy subsets
dialogue
A(x) : membership function of the element x in the fuzzy subset A
M = [0,1]
Let A, B be two fuzzy subsets of E and x is an element of E a = A(x) , b = A(x) a,b,...M = [0,1]
)
(
)
(
1
)
,
(
)
,
(
b
a
b
a
b
a
a
a
b
a
MAX
b
a
b
a
MIN
b
a
Commutativity
Associativity
~ ~ ~ ~ ~ ~ ~ ~a
b
b
a
a
b
b
a
)
(
)
(
)
(
)
(
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~c
b
a
c
b
a
c
b
a
c
b
a
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~)
(
1
1
1
)
(
)
(
)
(
)
(
)
(
)
(
a
a
a
a
a
a
a
a
c
a
b
a
c
b
a
c
a
b
a
c
b
a
Distributivity
DeMorgan s Law
~ ~ ~ ~ ~ ~ ~ ~b
a
b
a
b
a
b
a
50 0.00 54 0.08 58 0.32 60 0.50 64 0.82 68 0.98 70 1.00
Tall Not Short
50 0.00 54 0.08 58 0.32 60 0.50 64 0.82 68 0.98 70 1.00
Tall Not Tall 50 0.00 54 0.08 58 0.32 60 0.50 64 0.82 68 0.98 70 1.00
Complementation
50 1.00 54 0.92 58 0.68 60 0.50 64 0.18 68 0.02 70 0.00Not Tall Not Short Middle-Sized 50 1.00 54 0.92 58 0.68 60 0.50 AND 64 0.18 68 0.02 70 0.00 50 0.00 54 0.08 58 0.32 60 0.50 64 0.82 68 0.98 70 1.00 50 0.00 54 0.08 58 0.32 60 0.50 64 0.18 68 0.02 70 0.00
Linguistic Hedge Operation- Scalar
Ura(x) = rUa(x) r=0.7 r=0.5 r=0.3 Uar(x) = ((Ua(x))r
r = 0.5 r = 2
r = 4
UA =supUA(X)
NORM(A) A
Ucon(A) = UA2(X)
A CON(A)
UDIL(A)(X) = UA0.5(X) DIL A
UINT(A)(X) = 2(UA(X)) 2 0 UA(X) 0.5 1-2(1-UA(X))2 0.5 UA(X) 1.0
INT(A) A Very A = CON(A)
More Or less A = DIL(A)
Slightly A = NORM(A and not (very A))
Sort of A = NORM(not (CON(A)
2and DIL(A))
Pretty A = NORM(INT(A) and not INT(CON(A)))
Rather A = NORM(INT(A))
True
Very true
More or less true
Completely true
False
Very False
More or less false
Completely false
Unknown
Undefined
Fuzzy Proposition
“
Mr.Wang is young.” is true.
“
Mr.Wang is young.”
is very true.
Tall
Height Degree of membership 50 0.0 54 0.1 58 0.3 60 0.5 64 0.8 68 0.9 70 1.00VERY Tall
Height Degree of membership 50 0.0 54 0.01 58 0.09 60 0.25 64 0.64 68 0.81 70 1.00~
A~
A 1 0.5 0 X Figure 5-12 Fuzzy Complement A A = min ( A(X), A(X)) 0.5 A A E~ ~
~
~~
~~
A A A A = max ( (X), (X) 0.5 ~
~ ~
Maximum and Moments Methods
R1: IF MIX is too-wet
THEN Add sand and coarse aggregate R2: IF MIX is Workable
THEN Leave alone R3: IF MIX is too-stiff
THEN Decrease sand and coarse aggregate .
cement water
sand
Fuzzy Production Rule Antecedents for Concrete Mixture Process
TOO STIFF WORKABLE TOO WET
3 4 5 6 7 8 9
Concrete Slump (inches)
1.0 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0 Membership Grade
IF Concrete-slump = 6
THEN MIX = 0.0/Too-stiff + 1.0/workable + 0.0/Too-wet IF Concrete-slump = 7
THEN MIX = 0.0/Too-stiff + 0.3/workable + 0.0/Too-wet
IF Concrete-slump = 4.8
THEN MIX = 0.05/Too-stiff + 0.2/workable +0.0/Too-wet
.
.
.
R1: IF MIX is too-wet
THEN Add sand and coarse aggregate
R2: IF MIX is Workable
THEN Leave alone
R3: IF MIX is too-stiff
THEN Decrease sand and coarse
aggregate
Fuzzy Production Rule Consequence for Concrete Mixture Process Control
Membership Grade
DECREASE SAND AND COARSE AGGREGATE
-20 -10 0 +10 +20
Change in sand and Coarse Aggregate (%)
1.0 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0
Fuzzy Inference
Rule 1 : If the car is in short distance and is at a low speed Then keep the speed
Rule 2 : If the car is in short distance and is at a high speed Then decrease the speed
Rule 3 : If the car is in long distance and is at a low speed Then increase the speed
Rule 4 : If the car is in long distance and is at a high speed Then keep the speed
Short distances long distances low speed high speed decrease speed keep speed increase speed
low speed 10 20 30 30 50 70 -10 0 10 10 20 30 30 50 70 -10 0 10 10 20 30 10 20 30 30 50 70 30 50 70 -10 0 10 -10 0 10 Mass Center -10 0 10 Distance: 15m Speed: 60KM/h
short distance low speed keep the speed
short distance High speed
decrease the speed
long distance
long distance High speed keep the speed increase the speed 0.8 0.4 0.75 0.3 0.3 (0.4*0+0.75*(-10)+0.3*10+0.3*0)/ (0.4 +0.75+0.3+0.3))=-2.57 0.8 0.8 0.3 0.3 0.75 0.75 0.4 0.4 miles miles miles miles meter meter meter meter % % % %