13 Fuzzy Logic (Us)

Embed Size (px)

Citation preview

  • 8/14/2019 13 Fuzzy Logic (Us)

    1/40

    Artificial Intelligence

    Fuzzy logicFall 2008

    professor: Luigi Ceccaroni

  • 8/14/2019 13 Fuzzy Logic (Us)

    2/40

    Uncertainty

    - Modeling with uncertainty requires morethan probability theory.

    - There are problems where boundaries are

    gradual.Examples: What is the boundary of Spain? What is

    the area of Spain?

    When does a tumor begin its formation? What is the habitat of rabbits? What is the depth of the sea 30 km east of

    Barcelona?

  • 8/14/2019 13 Fuzzy Logic (Us)

    3/40

  • 8/14/2019 13 Fuzzy Logic (Us)

    4/40

    Representing vagueness: Fuzzysets and fuzzy logic

    The linguistic term tall does not refer to asharp demarcation of objects into twoclasses.

    There are degrees of tallness.

    Fuzzy set theorytreats Tallas a fuzzypredicate and says that the truth value ofTall(Carla) is a number between 0 and 1,rather than being just true orfalse.

  • 8/14/2019 13 Fuzzy Logic (Us)

    5/40

  • 8/14/2019 13 Fuzzy Logic (Us)

    6/40

    Examples

    In classical sets, either an element belongsor it does not. Examples: Set of integers a real number is an integer or not. You are either in an airplane or not. Your bank-account balance is 142 or not. The Bible is either the word of God, or it is not. Either Christ was divine, or he was not.

    Fuzzy sets are sets that have gradations ofbelonging. Examples:

    BIGNear

    Tall

  • 8/14/2019 13 Fuzzy Logic (Us)

    7/40

    Degrees of truth: example

    The temperature is pleasant.

    Variable: temperature Universe of values (U) ordomain: real

    The distribution indicates thedegree of truth of thelinguistic term pleasant.

    1

    00 20 30 40 C

  • 8/14/2019 13 Fuzzy Logic (Us)

    8/40

    Degrees of truth: example

    The temperature is low.

    The temperature is high.

    0

    1

    5 10 15 20 25 30 35 C

    low

    0

    1

    5 10 15 20 25 30 35 C

    high

  • 8/14/2019 13 Fuzzy Logic (Us)

    9/40

    Possibility function

    A : U [0, 1]

    The possibility function, orcharacteristic

    function, is often represented as atrapezoidalortriangularapproximation,which can be characterized by theabscises of the vertexes.

    1

    00 20 30 40

    1

    0 0 20 30 40

    (0, 20, 30, 40)

  • 8/14/2019 13 Fuzzy Logic (Us)

    10/40

    Degrees of fever: Fever is Low(37,37,37.6,38) Fever is Medium (37.6,38, 38.5,39)

    Fever is High (38.5,39,43,43)

    0

    37

    38

    39

    43

    1.0

    0.7

    0.3

    0.0

    temperature

    fever(temperature)

    low medium high

    Practical representation of fuzzysets

  • 8/14/2019 13 Fuzzy Logic (Us)

    11/40

    [Temperature is Gelada]

    [Temperature is Molt Freda]

    [Temperature is Freda]

    [Temperature is Fresca]

    [Temperature isAgradable] [Temperature is Calorosa]

    [Temperature is MoltCalorosa]

    0 5 10 15 20 25 30 35

    1

    0

    G MF F FS A C MC

    Each variable has a domain and a set oflabels or linguistic terms. Each label corresponds to a characteristicfunction defined over the domain.

    Practical representation of fuzzysets

  • 8/14/2019 13 Fuzzy Logic (Us)

    12/40

    -10 -7,5 0 -7,5 10

    BM BP GI PP PM

    -5 -1 0 1 5

    PN GZ PP

    s[VC isPoc Positiva]s[VC is Gaireb Zero]

    s[VC isPoc Negativa]

    Control variable

    s[T Puja Molt]s[T Puja Poc]s[T Gaireb Igual]

    s[T Baixa Poc]s[T Baixa Molt]

    Variation of temperature

    Practical representation of fuzzysets

  • 8/14/2019 13 Fuzzy Logic (Us)

    13/40

    13

    Fuzzy logic: connectives

    Fuzzy logical connectives are defined asfunctions in the [0,1] interval, whichgeneralize classic connectives:

    Intersection of sets P Q T-norm (P,Q)Union of sets P Q T-conorm (P,Q)Complement of a set P Negation function (P)

    Inclusion of sets P Q Implication function (P,Q)

    13

  • 8/14/2019 13 Fuzzy Logic (Us)

    14/40

    14

    Fuzzy negation

    Negation function N : [0,1] [0,1]

    Properties

    N(0) = 1 and N(1) = 0 boundary conditions N(p) N(q) if p q monotony N(N(p)) = p involution

    Examples N(x) = 1-x Nw(x) = (1-xw)1/w w > 0 Yager family Nt(x) = (1-x) / (1+t*x) t > -1 Sugeno family

    14

  • 8/14/2019 13 Fuzzy Logic (Us)

    15/40

    15

    Fuzzy conjunction

    T-Norms T : [0,1] x [0,1] [0,1]

    Properties T(p,q) = T(q,p)

    commutability T(p,T(q,r)) = T(T(p,q),r) associativity T(p,q) (r,s) if p r q s monotony T(0,p) = T(p,0) = 0 absorbing element T(1,p) = T(p,1) = p neutral element

    Examples T(x,y) = min (x,y) minimum T(x,y) = x*y algebraic product T(x,y) = max (0, x+y-1) bounded difference15

  • 8/14/2019 13 Fuzzy Logic (Us)

    16/40

  • 8/14/2019 13 Fuzzy Logic (Us)

    17/40

    17

    Relations between T-norms andT-conorms

    De Morgan laws:

    N(T(x,y)) = S(N(x),N(y))

    N(S(x,y)) = T(N(x),N(y))

    T(x,y) = min (x,y) S(x,y) = max (x,y) T(x,y) = x*y S(x,y) = x+y - x*y T(x,y) = max (0, x+y-1) S(x,y) = min (x+y,1)

    T(x,y) = x*y / (x+y-x*y) S(x,y) = (x+y -2x*y) / (1-x*y)

    17

  • 8/14/2019 13 Fuzzy Logic (Us)

    18/40

    18

    Fuzzy connectives over thesame universe

    If F [X is A] and G [X is B] withpossibility distributions A and B definedover the same universe U:

    F G [X is A B] with AB(u) = T(A(u) ,B(u)) T-norm

    F G [X is A B] with A B(u) = S(A(u) ,B(u)) T-conorm

    F [X is A] with A(u) = N(A(u)) Negation function

    18

  • 8/14/2019 13 Fuzzy Logic (Us)

    19/40

    Fuzzy connectives over thesame universe

  • 8/14/2019 13 Fuzzy Logic (Us)

    20/40

    20

    Fuzzy connectives overdifferent universes

    If F [X is A] and G [Y is B] withpossibility distributions A defined over U iB defined over V, UV:

    F G [X is A] [Y is B] with AB(u,v) = T(A(u) ,B(v)) T-norm

    F G [X is A] [Y is B] with A B(u,v) = S(A(u) ,B(v)) T-conorm

    Functions are defined in two differentdimensions.

    20

  • 8/14/2019 13 Fuzzy Logic (Us)

    21/40

    Fuzzy connectives over differentuniverses

  • 8/14/2019 13 Fuzzy Logic (Us)

    22/40

    Fuzzy connectives over differentuniverses: conjunction

  • 8/14/2019 13 Fuzzy Logic (Us)

    23/40

    Fuzzy connectives over differentuniverses: conjunction

  • 8/14/2019 13 Fuzzy Logic (Us)

    24/40

    Fuzzy connectives over differentuniverses: disjunction

  • 8/14/2019 13 Fuzzy Logic (Us)

    25/40

    Fuzzy connectives over differentuniverses: disjunction

  • 8/14/2019 13 Fuzzy Logic (Us)

    26/40

  • 8/14/2019 13 Fuzzy Logic (Us)

    27/40

    27

    Fuzzy inference with crisp data:connectives

    Interpretation of connectives:

    Negation: N(x) = 1-x Conjunction: fuzzy intersection = T-norms (T) Disjunction: fuzzy union = T-conorms (S)

    27

  • 8/14/2019 13 Fuzzy Logic (Us)

    28/40

    1. Evaluation of the antecedent of the rules

    2. Evaluation of the conclusions of the

    rules3. Combination of the conclusions of the

    rules

    4. Defuzzification

    Fuzzy inference with crispdata: phases

  • 8/14/2019 13 Fuzzy Logic (Us)

    29/40

    The membership degree of each atom of the antecedent iscalculated and combined according to the interpretationof the connectives.

    Phase 1: Evaluation of rulesantecedents

    -10 -7,5 0 -7,5 10

    BM BP GI PP PM

    0 5 10 15 20 25 30

    1 G MF F FS A CMC

    26 8,5

    min

    0,2

    0,4 0,40,2

    Ex.: R1: If T = MC and T = PM then ...

    Input: T = 26C, T = 8.5C

  • 8/14/2019 13 Fuzzy Logic (Us)

    30/40

    The fuzzy set of the conclusion is truncated with thevalue coming from antecedent calculations.

    Phase 2: Evaluation of rulesconclusions

    0,2

    -5 -1 0 1 5

    PN

    R1. If ... then VC = PN

    Control Variable

    0,2

    -5 -1 0 1 5

    Control Variable

    Control variable

    s [Poc Positiva]

    s [Gaireb Zero]s [Poc Negativa]

  • 8/14/2019 13 Fuzzy Logic (Us)

    31/40

    Phase 3: Combination of rulesconclusions

    Conclusions are

    always

    disjunctively combined.

    0,2

    -5 -1 0 1 5

    Control Variable

    -5 -1 0 1 5

    min

    0,4

    0,8

    0,4

    -5 -1 0 1 5

    R1

    R2

    R3...

    R40,6

    -5 -1 0 1 5

  • 8/14/2019 13 Fuzzy Logic (Us)

    32/40

    Defuzzification

    xD

    (x) x

    xD (x)

    Phase 4: defuzzification

    -5 -1 0 1 5 -5 1.5 0 1 5

    mass center

  • 8/14/2019 13 Fuzzy Logic (Us)

    33/40

    33

  • 8/14/2019 13 Fuzzy Logic (Us)

    34/40

    Inferncia difusa amb dadesdifuses

    Tenim una base de regles on els toms sonetiquetes difuses [X = A]

    Si Temperatura = Agradable llavors Gir = Una mica a ladreta

    Volem fer inferncia: amb encadenament cap endavant; a partir detiquetes difuses per les variables.

  • 8/14/2019 13 Fuzzy Logic (Us)

    35/40

    Inferncia difusa amb dadesdifuses: Fases

    Avaluaci de la relaci expressada en cadaregla (grau o funci dimplicaci)

    I(x,y)

    3. Avaluaci de la funci de pertinena delantecedent

    A(x)

    Composici inferencial (Modus ponens) de laimplicaci i lantecedent

    CI(x,y) = f(I(x,y), A(x))

  • 8/14/2019 13 Fuzzy Logic (Us)

    36/40

    Inferncia difusa amb dadesdifuses: Implicaci

    Funcions dimplicaci, I : [0,1] x [0,1] [0,1]

    PropietatsI(p,q) s creixent respecte a la primera variable i

    decreixent respecte a la segona variableI(0,p) = 1I(1,p) = pI(p,I(q,r)) = I(q,I(p,r)) (intercanvi dantecedents)R-implicacions / S-implicacions

    S-implicacionsa b = a bI(x,y) = S(N(x),y)Exemples de S-implicacionsI(x,y) = mx (1-x,y)I(x,y) = 1-x+x*yI(x,y) = mn (1-x+y,1)

  • 8/14/2019 13 Fuzzy Logic (Us)

    37/40

    Les inferncies en lgica difusa utilitzen el modus ponens com a

    regla bsica:

    Si [X s A] llavors [Y s B ]

    [X s A]

    [Y s B ]

    La combinaci de funcions de possibilitat es realitza mitjanantla funci generadora de modus ponens.

    Inferncia difusa amb dadesdifuses: Modus ponens

  • 8/14/2019 13 Fuzzy Logic (Us)

    38/40

    Emprant algunes de les definicions anteriors dimplicaci i el modusponens, s possible definir el procs dinferncia difusa:

    p (p q) q

    Donades les certeses dun antecedent i de la implicaci, la determinacide la certesa del conseqent es realitza en base a una funci generadoradel modus ponens que denominem mod().

    La funci mod() t una srie de propietats, algunes de les quals sn lessegents:a) mod(u, imp(u, v)) v

    b) mod(1, 1) = 1

    c) mod(0, u) = v

    d) u v mod(u, w) mod(v, w)

    a) La funci mod() t com a

    cota superior la certesa delconseqent.

    b) Aquest s el lmit boole del

    modus ponens

    c) Dun antecedent

    completamentfals es pot concloure qualsevolcosa.

    d) La funci mod() ha de ser

    montona creixent amb lacertesa

    de lantecedent.

    Modus ponens

  • 8/14/2019 13 Fuzzy Logic (Us)

    39/40

    Funciones generadoras del modus ponens que resultan de lasdefiniciones de la funcin implicacin presentadasanteriormente:

    Modus ponens

  • 8/14/2019 13 Fuzzy Logic (Us)

    40/40

    La lgica difusa gaudeix de lavantatge de poder fer inferncies

    sense tenir exactament lantecedent duna regla:

    Si [X s A] llavors [Y s B]

    [X s A]

    [Y s B ]

    Sha de calcular com es modifica la conclusi, ja que no tenim elmateix antecedent de la regla. Aix es fa mitjanant la

    transformaci de la funci de possibilitat de A en la de A

    Generalitzaci del modus ponens