Introduzione alla logica sfumata Introduction to Fuzzy Logic
Insieme sfumato Fuzzy SetDominio di definizione; definition space: x X RL’insieme sfumato è definito dalla funzione di appartenenza; Fuzzy set defined by its membership function: A(x) 0 A(x) 1 ,x X
Insieme vuoto; Empty set (x)=0 per xX ;
Insieme universo; Univers set S: S(x) =1 per xX
Insieme unione; Union set: AB AB (x)=max[A(x);B(x)]Insieme intersezione; Intersection set: AB AB(x)=min[A(x);B(x)]Insieme complementare; complement set: A* di of A : A(x)+A*(x)=1=
S(x)
x
100
X=(0<x<10)Fuzzy sets:: (x)=0 per xXS: S(x)=1 per xX
A insieme sfumato generico A(x) = 01 per xX
A* insieme complementare di A: A*(x) =1-A(x)Vettore sfumato; Fuzzy vector: C(x)= (c1,c2,…,cM) = (c1(x), c2(x),…, cM(x))
S(x)=1
(x)=0
A(x)
F(x)1
B(x)A*(x)
Per Insiemi Booleani; For Boolean Sets:Principio di esclusione; Exclusion principle:
AA* = S; AA* =
AA* : AA* (x) = max[A(x),A*(x)]≤ 1
AA* : AA* (x) = min[A(x),A*(x)] ≥0
Gli insiemi sfumati non godono del principio di esclusione;Exclusion principle is not valid for Fuzzy sets
A A* S AA*
A(xi)
x1 xi xM
A
y1
yj
yM
B(yj)
B
C(B)
C(xi,yj)
C(A)
Insiemi sfumati di insiemi sfumati (funzioni sfumate a più valori) Fuzzy sets of fuzzy sets: (multivalued fuzzy functions)
C2(x)
Vettore sfumato c =(c1 , c2) nel piano delle sue funziomi di appartenenza
Fuzzy vector c =(c1 , c2) in the plane of the membership functions
S=(1,1)
=(0,0)
(1,0)
(0,1)
A(2/3,1/4)
C1(x)
C(x)
QuantizzatoresfumataFuzzifier
ElaboratorelinguisticoLinguisticprocessor
QuantificatoreDefuzzier
Segnali analogici Analog signals
Struttura di un sistema per l’ elaborazione sfumataFuzzy set processor
Segnale analogico Analog signal
Antecedenti: variabili linguistiche a più valori (simboli) Antecedents: Multivalued linguistic variables (symbols)
variabile linguistica a più valori (simbolo): ConseguenteMultivalued linguistic variable (symbol): Consequent
QuantizzatoresfumatoFuzzifier
ElaborazionelinguisticaLinguisticprocessing
Segnali analogici Analog signals
Antecedenti: variabili linguistiche a più valori (simboli) Antecedents: Multivalued linguistic variables (symbols)
Massimo degliingressiMax of input
Riconoscitore basato sulla logica sfumataFuzzy recognition system
grado di apparteneza:conseguentemembership value: consequent
Classe riconosciutaSelected class
Vm T VM x
1
0
binario booleanobinario sfumato
0(x) 1(x)
i(x); i=0,1 (appartenenza alla variabile binaria)
X
Fig. 2 Funzioni di appartenenza alla variabile binaria ( codificatore binario booleano e codificatore binario sfumato)
x
= {aP
100
A ,aM
,aG}
aP(x) aG(x)aM(x)
ai(x), i= P,M,G
1
Funzioni di appartenenza di una grandezza sfumata a tre valori (piccolo:P,medio: M,grande: G)Membership functions of a three valued fuzzy variable (small:P,medium:M,large: G)
AaMP aP
aM aGB
bP
bG
cP cP
cPcM
cM cG
cG cMG
C={cP,cM,cG,cMG}A={aMP,aP,xM,aG} B={bP,bG}
C= f(A,B)
Esempio di trasformazione degli antecedenti Ae B nel conseguente CExample of the mapping of antecedents A,B into the conequent C
Riconoscimento di vocali con logica sfumataFuzzy vowel recognition
F2
F1
F2
QS; F
E
QS;F
F1
A
O
U
I
argmaxI…EElab.
Ling.
F1 MP P M GF2
B
A
U O
U E
A A
E I
V={I,U,O,A,E}F1={MP, P,M,G} F2={B,A}
Trasformazioni di funzioni logiche a tre valoriBasic three valued logic variable transformation
C= OR(A,B)
A -10 1B
-1
1
0
A -10 1B
-1
1
0
C= AND(A,B)
A -10 1
B-11 0
-1 0 1
0 0 1
1 1 1
-1 -1 -1
-1 0 0
-1 0 1
B= NOT(A)
y
P(y) G(y)M(y)
i(y),
1
P(y) = .8M(y) = .3
G(y) = .1
y= (i yi Ai)/(i Ai) con i = P,M,G
AP AM
AG
yP yM yG
Quantificazione con il metodo dei centroidiMethod of the centroids for fuzzy quantification
QuantificatoreDefuzzifier(MLP)
x
e
+ _
xQuantizzatore sfumatoFuzzifier
x^
Realizzazione del Quantificatore con un Percettrone MultistratoImplementation of the Defuzzifier using a Multi LayerPperceptron
DCT
l(i,j)
FuzzifierLinguisticProcessor
argmax[mHI,mMH,mML,mLO]
T
L
Bclass
S
S
c(m,n)T’
L’
Input: Image luminance I(i,j)
Preprocessed input pattern: DCT Transforms
Input pattern: Total (T’)and low frequency (L’) energies:
T’ = |c(m,n)|-|c(0,0)|, m,n = 0-7
L’ = |c(m,n)|-|c(0,0)|, m,n = 0-3
Antecedents:Fuzzy Total Energy: T={VS, SM, ML, LG}
Fuzzy Low Frequency Energy: L={SM, LG}
Conseguents: Visibility Block Classification: B={LO,ML,MH,HI}
Classificatore sfumato delle trasformate DCT di blocchi d’ immagineImage DCT Block fuzzy Classifier
L
SM LG
SM, LG
1000
T
VS LG
VS, SM, ML, LG
SM ML
1000
1
1
Funzioni di appartenenza per la codifica sfumata di T ed LMembership functions used for T and L fuzzification
TL LGML
HI
HI
ML
LO
LG
SM
VS SM
MH
HI
ML
LO
Trasformazione linguistica dell’ attivita’ dei blocchi DCTLinguistic transformation of the DCT blocks
xControllore
sfumatoFuzzy
controller
inseguitore(motore)
t
(e)/t
e
e’
Errore di posizione; position error: (e=x-y)
Antecedenti; antecedents:
Errore; error: e={N,Z,P},
Derivata dell’ errore; error derivative: e’={N,Z,P},
Velocita’ al tempo n-1; speed at time n-1: vp={N,Z,P}
Conseguente; consequent: Velocita’; speed:v={N,Z,P}
Controllore PID sfumato per motoriFuzzy PID motor controller
y+ _
cs
qs
e’
vp
e
v
Apprendimento dei classificatori sfumatiLearning of the fuzzy classifiers
a) Metodo del gradiente per l’addestramento dei quantizzatori sfumati; Gradient method for the learning of the fuzzifier
Problema della derivazione delle funzioni discontinue; issues of the differentation of discontinous functions) max(x,a)/x = 1 if x>a else max(x,a)/x = 0
b) Addestramentodi tutti i blocchi (CS, Trasf. Linguistico, QS) Learning of all the blocks (Fuzzifier, Ling. mapping, Defuzzzifier) Si utilizza l’architettura ANFIS; we use the ANFIS architecture
(Adaptive Network-based Fuzzy Inference System;
Sistema d’inferenza sfumato basato su una rete adattativa )
Problema: date P coppie di addestramento (xp,zp; p=1÷P) della z=z(x)Estrapolare (inferire) la z(x) come combinazione pesata di M interpolatori lineari : z=iwi(pix+ri)
x
zz(x)
x2
z2
xp
zp
xP
zP
x1
z1
Introduzione all’architettura ANFIS,Introduction to the ANFIS architecture
x0= -r/p
z0= wr
Problem: P learning pairs (xp,zp; p=1÷P) of a z=z(x) are given.Infer the z(x)
as a weighted linear combination of M linear interpolator: z=iwi(pix+ri)
x
xl
xm
xh
y
xl
xm
xh
m1
m2
mi
m8
m9
:mi
z+
w1
w2
wi
w8
w9
wifiAND
fi=pix +qiy +ri
xy
Architettura ANFIS; ANFIS architecture
QSF
x
xl
xm
xh
y
xl
xm
xh
m1
m2
mi
m8
m9
:mi
z+
w1
w2
wi
w8
w9
wifiAND
fi=pix +qiy +ri
xy
QS F
Quantif.Defuzzifier
(OR)
X /
+
L1(x)
X /
X /
x z
+
+
L3(x)
L2(x)
A3
A2
A1
w3
w1
w2w2
w1
w3
QuantizzatorisfumatiFuzzifiers
Normalizzatori dei minterminiMinterm normalizers
QuantificatoriDefuzzifiersGeneratori dei
MinterminiMinterm generators
1
2
3
IF (A1 AND A2) THEN (w1=12) w1= w1/(w1+ w2+w3)
Dettagli dell’architettura ANFIS; details of the ANFIS architecture
x
Li(x)= pix+ri
Quantificatore; Defuzzifier: z=iwi(pix+ri)
In the specific case z(x)= w1 L1(x)+w2L2(x)+w3L3(x)
Rappresentazione matematica di ANFIS Mathematical respresentation of ANFIS
Quantizzatori sfumati; Fuzzifiers: i(x)= exp((x-ci)/ai)2,… (i=1÷K)
Generatore dei mintermini (AND aritmetico o logico); minterm generators: mhk =h(x)k(x),… (h;k=1÷K; mhk=mkh)
Normalizzatore dei pesi; weights normalizer: wj= wi/(w1+…+ wi+…+wI),…. With i=1÷I, I=K(K-1)/2)
Interpolatori lineari; Linear interpolators: Li(x)= pix+ri
x
z
1(x)
2(x) 3(x)i(x)
z(x)
x
w2L2(x)
L2(x)
L3(x)
Metodo: K funzioni di appartenenza degli ingressi; K membership functionsIl numero dei tratti lineari che vengono pesati con pesi funzione dell’ingresso sono Numero d’interpolatori lineari; number of linear interpolators; I≤ K(K-1)/2Nell’esempio; in the example K=2, I=3: z(x) ~ w1(x) L1(x)+w2(x)L2(x)+w3(x)L3(x)
w3L3(x)
w1L1(x)
L1(x)
Parametri; parametersParametri dei quantizzatori sfumati; Fuzzifier parameters: ai,ci (i=1÷K)
Parametri delle rette interpolatrici; linear interpolator parameters: pi,ri (i=1÷K(K-1)/2))
Coppie d’addestramento; training pairs: (xp,zp; p=1÷P) P>>K2
Addestramento ibrido; Hybrid Learning:1) pi e ri ottimizzati con metodo dei minimi quadrati LSE (sistema lineare sovradimensionato
di P equazioni); pi and ri optimized using LSE method (overdimensioned linear system of P equations)
2) ai e ci ottimizzati con il metodo del gradiente e retropropagazione dell’errore EBP per
ogni coppia d’addestramento; ai and ci optimized using the gradient method and EBP for
each training pair.
Riferimento: Jyh-Shing Roger Jang: ANFIS: Adaptive_Network-Based Fuzzy Inference System, IEEE Transactions on Systems, Man, and Cybernetics, Vol. 23 No. 3 1993 pp. 665-684