C291-78 Tópicos Avanzados: Inteligencia Computacional...

76
C291-78 Tópicos Avanzados: Inteligencia Computacional I Dra. Ma. del Pilar Gómez Gil Primavera 2014 [email protected] 1 Ver: 08-Mar-2016 Introducción a la Lógica Difusa

Transcript of C291-78 Tópicos Avanzados: Inteligencia Computacional...

  • C291-78

    Tópicos Avanzados:

    Inteligencia Computacional I

    Dra. Ma. del Pilar Gómez Gil

    Primavera 2014 [email protected]

    1

    Ver: 08-Mar-2016

    Introducción a la Lógica Difusa

    mailto:[email protected]

  • Este material ha sido tomado de varias fuentes,

    y forma parte del “Tutorial en Lógica Difusa”

    impartido por el Dr. Juan Manuel Ramírez C.

    Coordinación de Electrónica, 2012

    2

  • FUZZY LOGIC

    In 1965 Lotfi Zadeh, published his famous paper “Fuzzy sets”.

    Zadeh extended the work on possibility theory into a formal system of mathematical logic, and introduced a new concept for applying natural language terms.

    This new logic for representing and manipulating fuzzy terms was called fuzzy logic.

    3

  • Introduction

    Many decision-making and problem-solving tasks are too complex to be understood quantitatively, however, people succeed by using knowledge that is imprecise rather than precise.

    Fuzzy set theory resembles human reasoning in its use of approximate information and uncertainty to generate decisions.

    4

  • Example: driving decisions

    5

  • Introduction (2)

    Since knowledge can be expressed in a more natural way by using fuzzy sets, many engineering and decision problems can be greatly simplified.

    It was specifically designed to mathematically represent uncertainty and vagueness and provide formalized tools for dealing with the imprecision intrinsic to many problems.

    Fuzzy theory may be seen as an extension to classical set theory, where a membership function is added to a set. This function is defined in

    ]1,0[

    6

  • Membership function

    (a) Boolean Logic. (b) Multi-valued Logic.

    0 1 10 0.2 0.4 0.6 0.8 100 1 10

    Fuzzy logic is a set of mathematical principles for knowledge representation based on degrees of membership.

    Unlike two-valued Boolean logic, fuzzy logic is multi-valued. It deals with degrees of membership and degrees of truth.

    Fuzzy logic uses the continuum of logical values between 0 (completely false) and 1(completely true). Instead of just black and white it accepts that things can be partly true and partly false at the same time.

    7

  • Membership function (2)

    A membership function

    represents the “degree” in that variable t is

    included in the concept represented by

    the tag A.

    )(tA

    8

  • Example:

    fuzzy variable “temperatura”

    Linguistic value/variable:

    temperatura

    Fuzzy subsets:

    {frío, fresco, normal, tibio, caliente}

    Membership functions:

    )}(),(),(),(),({ ttttt calientetibionormalfrescofrío

    9

  • Example:

    fuzzy variable “temperatura” (2)

    )(tA

    t

    The t-axis represents the universe of discourse

    Each colour line is a membership function

    10

  • The membership function of a

    “Crisp set”

    11

  • The membership function of a

    “Fuzzy set”

    12

  • Crisp sets and characteristic

    function

    Ax

    Axxf A

    if0,

    if 1,)(

    Let X be the universe of discourse and its elements be

    denoted as x. In the classical set theory, crisp set A of X

    is defined as function fA(x) called the characteristic

    function of A:

    fA(x) : X {0, 1}, where

    This set maps universe X to a set of two elements. For

    any element x of universe X, characteristic function fA(x) is

    equal to 1 if x is an element of set A, and is equal to 0 if x

    is not an element of A.

    13

  • Fuzzy sets and membership functions

    In the fuzzy theory, fuzzy set A of universe X is defined by function µA(x) called the membership function of set A

    µ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.

    This set allows a continuum of possible choices. For any element x of universe X, membership function µA(x) equals the degree to which x is an element of set A. This degree, a value between 0 and 1, represents the degree of membership, also called membership value, of element x in set A.

    14

  • Fuzzy Set Representation

    First, we determine the membership functions. In our

    “height” example, we can obtain fuzzy sets of tall, short and

    average men.

    The universe of discourse – the person’s heights – is

    represented by three sets: short, average and tall men. As you

    will see, a man who is 184 cm tall is a member of the average

    men set with a degree of membership of 0.1, and at the same

    time, he is also a member of the tall men set with a degree of

    0.4. (see graph on next page)

    15

  • Fuzzy Set Representation

    150 210170 180 190 200160

    Height, cmDegree ofMembership

    Tall Men

    150 210180 190 200

    1.0

    0.0

    0.2

    0.4

    0.6

    0.8

    160

    Degree ofMembership

    Short Average ShortTall

    170

    1.0

    0.0

    0.2

    0.4

    0.6

    0.8

    Fuzzy Sets

    Crisp Sets

    Short Average

    Tall

    Tall

    16

  • Fuzzy Set Representation

    Typical functions that can be used to represent a fuzzy set

    are sigmoid, gaussian and pi. However, these functions

    increase the time of computation. Therefore, in practice,

    most applications use linear fit functions.

    17

  • Funciones de membresía (1)

    Función de membresía triangular

    18

  • Función de membresía trapezoidal

    Funciones de membresía (2)

    19

  • Función de membresía gaussiana

    Funciones de membresía (3)

    20

  • Funciones de membresía sigmoide

    Funciones de membresía (4)

    21

  • Linguistic Variables and Hedges At the root of fuzzy set theory lies the idea of linguistic variables.

    A linguistic variable is a fuzzy variable. For example, the statement “John is tall” implies that the linguistic variable John takes the linguistic value tall.

    In fuzzy expert systems, linguistic variables are used in fuzzy rules. For example:

    IF wind is strong

    THEN sailing is good

    IF project_duration is long

    THEN completion_risk is high

    IF speed is slow

    THEN stopping_distance is short

    22

  • Linguistic Variables and Hedges

    The range of possible values of a linguistic variable represents the universe of discourse of that variable. For example, the universe of discourse of the linguistic variable speed might have the range between 0 and 220 km/h and may include such fuzzy subsets as very slow, slow, medium, fast, and very fast.

    A linguistic variable carries with it the concept of fuzzy set qualifiers, called hedges.

    Hedges are terms that modify the shape of fuzzy sets. They include adverbs such as very, somewhat, quite, more or less and slightly.

    23

  • Linguistic Variables and Hedges

    Short

    Very Tall

    Short Tall

    Degree ofMembership

    150 210180 190 200

    1.0

    0.0

    0.2

    0.4

    0.6

    0.8

    160 170

    Height, cm

    Average

    TallVery Short Very Tall

    24

  • Linguistic Variables and Hedges

    25

  • Linguistic Variables and Hedges

    26

  • Membership Functions

    For the sake of convenience, usually a fuzzy set is denoted as:

    A = A(xi)/xi + …………. + A(xn)/xn where A(xi)/xi (a singleton) is a pair “grade of

    membership” element, that belongs to a finite universe of discourse:

    A = {x1, x2, .., xn}

    27

  • Logic operators (1/2)

    28

    (Matlab, 2015)

  • Operations of Crisp Sets

    Intersection Union

    Complement

    Not A

    A

    Containment

    AA

    B

    BA BAA B

    29

  • Operations of Fuzzy Sets

    Complement

    0 x

    1

    ( x )

    0 x

    1

    Containment

    0 x

    1

    0 x

    1

    A B

    Not A

    A

    Intersection

    0 x

    1

    0 x

    A B

    Union

    0

    1

    A B

    A B

    0 x

    1

    0 x

    1

    B

    A

    B

    A

    ( x )

    ( x ) ( x )

    30

    Blue line is the

    resulting

    membership function

  • Logic operators (2/2)

    31

    (Matlab, 2015)

  • Complement Crisp Sets: Who does not belong to the set?

    Fuzzy Sets: How much do elements not belong to the set?

    If A is the fuzzy set, its complement A can be found as follows:

    A(x) = 1 A(x)

    The complement of a set is an opposite of this set. For example, if we have the set of tall men, its complement is the set of NOT tall men. When we remove the tall men set from the universe of discourse, we obtain the complement.

    32

  • Containment

    Crisp Sets: Which sets belong to which other sets?

    Fuzzy Sets: How much sets belong to other sets?

    Similar to a Chinese box, a set can contain other sets.

    The smaller set is called the subset. For example, the

    set of tall men contains all tall men; very tall men is a

    subset of tall men. However, the tall men set is just a

    subset of the set of men. In crisp sets, all elements of a

    subset entirely belong to a larger set. In fuzzy sets,

    however, each element can belong less to the subset

    than to the larger set. Elements of the fuzzy subset have

    smaller memberships in it than in the larger set.

    33

  • Intersection Crisp Sets: Which element belongs to both sets?

    Fuzzy Sets: How much of the element is in both sets?

    In classical set theory, an intersection between two sets contains the elements shared by these sets. For example, the intersection of the set of tall men and the set of fat men is the area where these sets overlap. In fuzzy sets, an element may partly belong to both sets with different memberships.

    A fuzzy intersection is the lower membership in both sets of each element. The fuzzy intersection of two fuzzy sets A and B on universe of discourse X:

    AB(x) = min [A(x), B(x)] = A(x) B(x),

    where xX

    34

  • Union

    Crisp Sets: Which element belongs to either set?

    Fuzzy Sets: How much of the element is in either set?

    The union of two crisp sets consists of every element that falls into

    either set. For example, the union of tall men and fat men contains

    all men who are tall OR fat.

    In fuzzy sets, the union is the reverse of the intersection. That is,

    the union is the largest membership value of the element in

    either set. The fuzzy operation for forming the union of two fuzzy

    sets A and B on universe X can be given as:

    AB(x) = max [A(x), B(x)] = A(x) B(x),

    where xX

    35

  • Crisp and Fuzzy –union and

    intersection

    36

    A B 𝑨 ∪ 𝑩 𝑨 ∩ 𝑩

    ¬𝑨 𝑨 ∪ ¬𝑨 = 𝑼 𝑨 ∩ ¬𝑨 = ∅

    m𝑎𝑥(𝜇𝐴, 𝜇𝐵) min(𝜇𝐴, 𝜇𝐵) m𝑎𝑥(𝜇𝐴, 𝜇¬𝐴) min(𝜇𝐴, 𝜇¬𝐴)

    0 0 0 = m𝑎𝑥(0,0)

    0 = m𝑖𝑛(0,0) 1 1 = m𝑎𝑥(0,1) 0 = m𝑖𝑛(0,1)

    0 1 1= m𝑎𝑥(0,1)

    0 = m𝑖𝑛(0,1)

    1 0 1= m𝑎𝑥(1,0)

    0 = m𝑖𝑛(1,0) 0 1 = m𝑎𝑥(1,0) 0 = m𝑖𝑛(1,0)

    1 1 1= m𝑎𝑥(1,1)

    1 = m𝑖𝑛(1,1)

  • Crisp and Fuzzy – containment

    (subset)

    37

    A B 𝑨 ∪ 𝑩 𝑨 ∩ 𝑩

    m𝑎𝑥(𝜇𝐴, 𝜇𝐵) min(𝜇𝐴, 𝜇𝐵)

    0 0 0 = m𝑎𝑥(0,0) 0 = m𝑖𝑛(0,0)

    0 1 1= m𝑎𝑥(0,1) 0 = m𝑖𝑛(0,1)

    1 0 1= m𝑎𝑥(1,0) 0 = m𝑖𝑛(1,0)

    1 1 1= m𝑎𝑥(1,1) 1 = m𝑖𝑛(1,1)

    If 𝐴 ⊆ 𝐵𝑡ℎ𝑒𝑛𝐴 ∪ 𝐵 = 𝐵 𝐴 ∩ 𝐵 = 𝐴,

    Example:

    A = “very tall”

    B = “Tall”

    You can’t be

    “very tall” and

    “not tall” at the

    same time!

  • Properties of Fuzzy Sets

    Equality of two fuzzy sets

    Inclusion of one set into another fuzzy set

    Cardinality of a fuzzy set

    An empty fuzzy set

    -cuts (alpha-cuts)

    38

  • Equality

    Fuzzy set A is considered equal to a fuzzy

    set B, IF AND ONLY IF (iff):

    A(x) = B(x), xX

    39

  • Inclusion

    Inclusion of one fuzzy set into another fuzzy set. Fuzzy

    set A X is included in (is a subset of) another fuzzy

    set, B X:

    A(x) B(x), xX

    Consider X = {1, 2, 3} and sets A and B

    A = 0.3/1 + 0.5/2 + 1/3;

    B = 0.5/1 + 0.55/2 + 1/3

    then A is a subset of B, or A B

    40

  • Cardinality Cardinality of a non-fuzzy set, Z, is the number of elements in Z.

    BUT the cardinality of a fuzzy set A, the so-called SIGMA COUNT, is expressed as a SUM of the values of the membership function of A, A(x):

    cardA = A(x1) + A(x2) + … A(xn) = ΣA(xi), for i=1..n

    Consider X = {1, 2, 3} and sets A and B

    A = 0.3/1 + 0.5/2 + 1/3;

    B = 0.5/1 + 0.55/2 + 1/3

    cardA = 1.8

    cardB = 2.05

    41

  • Empty Fuzzy Set

    A fuzzy set A is empty, IF AND ONLY IF:

    A(x) = 0, xX

    Consider X = {1, 2, 3} and set A

    A = 0/1 + 0/2 + 0/3

    then A is empty

    42

  • Alpha-cut

    An -cut or -level set of a fuzzy set A X is an

    ORDINARY SET A X, such that:

    A={A(x), xX}.

    Consider X = {1, 2, 3} and set A

    A = 0.3/1 + 0.5/2 + 1/3

    then A0.5 = {2, 3},

    A0.1 = {1, 2, 3},

    A1 = {3}

    43

  • Fuzzy Set Normality

    A fuzzy subset of X is called normal if there exists at least

    one element xX such that A(x) = 1.

    A fuzzy subset that is not normal is called subnormal.

    All crisp subsets except for the null set are normal. In fuzzy

    set theory, the concept of nullness essentially generalises to

    subnormality.

    The height of a fuzzy subset A is the large membership

    grade of an element in A

    height(A) = maxx(A(x))

    44

  • Fuzzy Sets Core and Support

    Assume A is a fuzzy subset of X:

    the support of A is the crisp subset of X consisting of

    all elements with membership grade:

    supp(A) = {x A(x) 0 and xX}

    the core of A is the crisp subset of X consisting of all

    elements with membership grade:

    core(A) = {x A(x) = 1 and xX}

    45

  • Fuzzy Set Math Operations

    aA = {aA(x), xX}

    Let a =0.5, and

    A = {0.5/a, 0.3/b, 0.2/c, 1/d}

    then

    Aa = {0.25/a, 0.15/b, 0.1/c, 0.5/d}

    Aa = {A(x)a, xX}

    Let a =2, and

    A = {0.5/a, 0.3/b, 0.2/c, 1/d}

    then

    Aa = {0.25/a, 0.09/b, 0.04/c, 1/d}

    46

  • Fuzzy Sets Examples

    Consider two fuzzy subsets of the set X,

    X = {a, b, c, d, e }

    referred to as A and B

    A = {1/a, 0.3/b, 0.2/c 0.8/d, 0/e}

    and

    B = {0.6/a, 0.9/b, 0.1/c, 0.3/d, 0.2/e}

    47

  • Fuzzy Sets Examples

    Support:

    supp(A) = {a, b, c, d }

    supp(B) = {a, b, c, d, e }

    Core:

    core(A) = {a}

    core(B) = {o}

    Cardinality:

    card(A) = 1+0.3+0.2+0.8+0 = 2.3

    card(B) = 0.6+0.9+0.1+0.3+0.2 = 2.1

    48

  • Fuzzy Sets Examples

    Complement:

    A = {1/a, 0.3/b, 0.2/c 0.8/d, 0/e}

    A = {0/a, 0.7/b, 0.8/c 0.2/d, 1/e}

    Union:

    A B = {1/a, 0.9/b, 0.2/c, 0.8/d, 0.2/e}

    Intersection:

    A B = {0.6/a, 0.3/b, 0.1/c, 0.3/d, 0/e}

    49

  • Fuzzy Sets Examples

    aA: for a=0.5 aA = {0.5/a, 0.15/b, 0.1/c, 0.4/d, 0/e}

    Aa: for a=2 Aa = {1/a, 0.09/b, 0.04/c, 0.64/d, 0/e}

    a-cut:

    A0.2 = {a, b, c, d}

    A0.3 = {a, b, d}

    A0.8 = {a, d}

    A1 = {a}

    50

  • Exercises

    For A = {0.2/a, 0.4/b, 1/c, 0.8/d, 0/e} B = {0/a, 0.9/b, 0.3/c, 0.2/d, 0.1/e}

    Draw the Fuzzy Graph of A and B Then, calculate the following: - Support, Core, Cardinality, and Complement for A and

    B independently - Union and Intersection of A and B - the new set C, if C = A2 - the new set D, if D = 0.5B - the new set E, for an alpha cut at A0.5

    51

  • Solutions A = {0.2/a, 0.4/b, 1/c, 0.8/d, 0/e} B = {0/a, 0.9/b, 0.3/c, 0.2/d, 0.1/e} Support

    Supp(A) = {a, b, c, d} Supp(B) = {b, c, d, e}

    Core

    Core(A) = {c} Core(B) = {}

    Cardinality

    Card(A) = 0.2 + 0.4 + 1 + 0.8 + 0 = 2.4 Card(B) = 0 + 0.9 + 0.3 + 0.2 + 0.1 = 1.5

    Complement

    Comp(A) = {0.8/a, 0.6/b, 0/c, 0.2/d, 1/e} Comp(B) = {1/a, 0.1/b, 0.7/c, 0.8/d, 0.9/e}

    52

  • Solutions A = {0.2/a, 0.4/b, 1/c, 0.8/d, 0/e} B = {0/a, 0.9/b, 0.3/c, 0.2/d, 0.1/e} Union

    AB = {0.2/a, 0.9/b, 1/c, 0.8/d, 0.1/e} Intersection

    AB = {0/a, 0.4/b, 0.3/c, 0.2/d, 0/e} C=A2

    C = {0.04/a, 0.16/b, 1/c, 0.64/d, 0/e}

    D = 0.5B

    D = {0/a, 0.45/b, 0.15/c, 0.1/d, 0.05/e}

    E = A0.5 E = {c, d}

    53

  • Inference Fuzzy Rules

    In 1973, Dr. Lotfi Zadeh published his second most influential paper. This

    paper outlined a new approach to analysis of complex systems, in which

    Zadeh suggested capturing human knowledge in fuzzy rules.

    A fuzzy rule can be defined as a conditional statement in the form:

    IF x is A

    THEN y is B

    where x and y are linguistic variables; and A and B are linguistic values

    determined by fuzzy sets on the universe of discourses X and Y,

    respectively.

    54

  • Classical Vs Fuzzy Rules A classical IF-THEN rule uses binary logic, for example,

    Rule: 1 Rule: 2

    IF speed is > 90 km/h IF speed is < 40 km/h

    THEN THEN

    stopping_distance> 40 m stopping_distance < 15 m

    The variable speed can have any numerical value between 0 and 150 km/h, and the variable stopping_distance can take any numerical value between 0 and 60 m. In other words, classical rules are expressed in the black-and-white language of Boolean logic.

    55

  • Classical Vs Fuzzy Rules

    A fuzzy IF-THEN rule uses fuzzy logic :

    Rule: 1 Rule: 2

    IF speed is fast IF speed is slow

    THEN stopping_distance is long THEN stopping_distance is short

    In fuzzy rules, the linguistic variable speed also has the range (the universe of discourse) between 0 and 150 km/h, but this range includes fuzzy sets, such as slow, medium and fast. The universe of discourse of the linguistic variable ‘stopping_distance’ can be between 0 and 60 m and may include such fuzzy sets as short, medium and long.

    56

  • Classical Vs Fuzzy Rules

    Fuzzy rules relate fuzzy sets.

    In a fuzzy system, all rules fire to some extent, or in other words they fire partially. If the antecedent is true to some degree of membership, then the consequent is also true to the corresponding degree.

    57

  • Firing Fuzzy Rules

    Tall men Heavy men

    180

    Degree ofMembership

    1.0

    0.0

    0.2

    0.4

    0.6

    0.8

    Height, cm

    190 200 70 80 100160

    Weight, kg

    120

    Degree ofMembership

    1.0

    0.0

    0.2

    0.4

    0.6

    0.8

    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 tall THEN weight is heavy

    58

  • Firing Fuzzy Rules

    Tall menHeavy men

    180

    Degree ofMembership

    1.0

    0.0

    0.2

    0.4

    0.6

    0.8

    Height, cm

    190 200 70 80 100160

    Weight, kg

    120

    Degree ofMembership

    1.0

    0.0

    0.2

    0.4

    0.6

    0.8

    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.

    59

  • Firing Fuzzy Rules

    A fuzzy rule can have multiple antecedents, for example:

    IF service is excellent

    OR food is delicious

    THEN tip is generous

    The consequent of a fuzzy rule can also include multiple parts, for instance:

    IF temperature is hot

    THEN hot_water is reduced;

    cold_water is increased

    60

  • 1a. Specify the problem

    Air-conditioning involves the delivery of air, which can be

    warmed or cooled and have its humidity raised or lowered.

    An air-conditioner is an apparatus for controlling, especially

    lowering, the temperature and humidity of an enclosed

    space. An air-conditioner typically has a fan which

    blows/cools/circulates fresh air and has a cooler. The cooler

    is controlled by a thermostat. Generally, the amount of air

    being compressed is proportional to the ambient

    temperature.

    1b. Define linguistic variables

    • Ambient Temperature

    • Air-conditioner Fan Speed

    Example: Air Conditioner

    61

  • 2. Determine Fuzzy Sets

    Example: Air Conditioner

    Fuzzy sets can have a variety of shapes. However, a triangle or a trapezoid can often provide an adequate representation of the expert knowledge, and at the same time, significantly simplifies the process of computation.

    62

  • 2. Determine Fuzzy Sets: Temperature Temp

    (0C).

    COL

    D

    COOL PLEASAN

    T

    WARM HO

    T

    0 Y* N N N N

    5 Y Y N N N

    10 N Y N N N

    12.5 N Y* N N N

    15 N Y N N N

    17.5 N N Y* N N

    20 N N N Y N

    22.5 N N N Y* N

    25 N N N Y N

    27.5 N N N N Y

    30 N N N N Y*

    Temp

    (0C).

    COLD COOL PLEASANT WARM HOT

    0

  • 64

    Temperature Fuzzy Sets

    0

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    0 5 10 15 20 25 30

    Temperature Degrees C

    Tru

    th V

    alu

    e Cold

    Cool

    Pleasent

    Warm

    Hot

    Temperature Fuzzy Sets

    0

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    0 5 10 15 20 25 30

    Temperature Degrees C

    Tru

    th V

    alu

    e Cold

    Cool

    Pleasent

    Warm

    Hot

    2. Determine Fuzzy Sets: Temperature (cont.)

    Example: Air Conditioner

  • 2. Determine Fuzzy Sets: Fan Speed Rev/sec

    (RPM)

    MINIMAL SLOW MEDIUM FAST BLAST

    0 Y* N N N N

    10 Y N N N N

    20 Y Y N N N

    30 N Y* N N N

    40 N Y N N N

    50 N N Y* N N

    60 N N N Y N

    70 N N N Y* N

    80 N N N Y Y

    90 N N N N Y

    100 N N N N Y*

    Example: Air Conditioner

    65

  • 2. Determine Fuzzy Sets: Fan Speed (cont.)

    Example: Air Conditioner

    Speed Fuzzy Sets

    0

    0.2

    0.4

    0.6

    0.8

    1

    0 10 20 30 40 50 60 70 80 90 100

    Speed

    Tru

    th V

    alu

    e MINIMAL

    SLOW

    MEDIUM

    FAST

    BLAST

    66

  • 3. Bring out and construct fuzzy rules

    Example: Air Conditioner

    RULE 1: IF temp is cold THEN speed is minimal

    RULE 2: IF temp is cool THEN speed is slow

    RULE 3: IF temp is pleasant THEN speed is medium

    RULE 4: IF temp is warm THEN speed is fast

    RULE 5: IF temp is hot THEN speed is blast

    To accomplish this task, we might ask the expert to describe how the problem can be solved using the fuzzy linguistic variables defined previously.

    Required knowledge also can be collected from other sources such as books, computer databases, flow diagrams and observed human behaviour.

    67

  • 4. Encode the fuzzy sets, fuzzy rules

    and procedures to perform fuzzy

    inference into the expert system

    To accomplish this task, we may choose an option:

    to build our system using a programming language such as C/C++ or Pascal, or

    to apply a fuzzy logic development tool such as MATLAB Fuzzy Logic Toolbox or Fuzzy Knowledge Builder.

    etc

    Example: Air Conditioner

    68

  • 5. Evaluate and tune the system

    Example: Air Conditioner

    The last, and the most laborious, task is to evaluate and tune the system. We want to see whether our fuzzy system meets the requirements specified at the beginning.

    Evaluation of the system output is performed for test situations on the several representative values of input variables. Fuzzy Logic development tools often can generate surface to help us evaluate and analyze the system’s performance.

    Tuning of the system consists of reviewing, adding and/or changing the membership functions and rules in order to increase the performance of the system.

    69

  • 5a. Evaluate the system

    Consider a temperature of 16oC, use the system

    to compute the optimal fan speed.

    Example: Air Conditioner

    RECALL: Operation of a fuzzy expert system:

    Fuzzification: determination of the degree of membership of crisp inputs in appropriate fuzzy sets.

    Inference: evaluation of fuzzy rules to produce an output for each rule.

    Aggregation: combination of the outputs of all rules.

    Defuzzification: computation of crisp output

    70

  • • Fuzzification

    Affected fuzzy sets: COOL and PLEASANT

    COOL(T) = – T / 5 + 3.5

    = – 16 / 5 + 3.5

    = 0.3

    PLSNT(T) = T /2.5 - 6

    = 16 /2.5 - 6

    = 0.4

    Temp=16 COLD COOL PLEASANT WARM HOT

    0 0.3 0.4 0 0

    Example: Air Conditioner

    71

  • • Inference

    Example: Air Conditioner

    RULE 1: IF temp is cold THEN speed is minimal

    RULE 2: IF temp is cool THEN speed is slow

    RULE 3: IF temp is pleasant THEN speed is medium

    RULE 4: IF temp is warm THEN speed is fast

    RULE 5: IF temp is hot THEN speed is blast

    RULE 2: IF temp is cool (0.3) THEN speed is slow (0.3)

    RULE 3: IF temp is pleasant (0.4) THEN speed is medium (0.4) 72

  • • Aggregation

    speed is slow (0.3) speed is medium (0.4) +

    Example: Air Conditioner

    73

  • • Defuzzification

    COG = 0.125(12.5) + 0.25(15) + 0.3(17.5+20+…+40+42.5) + 0.4(45+47.5+…+52.5+55) + 0.25(57.5)

    0.125 + 0.25 + 0.3(11) + 0.4(5) + 0.25

    = 45.54rpm

    Example: Air Conditioner

    74

  • Centroid of area zCOA

    where A(z) is the aggregated output MF.

    ,dz)z(

    zdz)z(

    z

    Z

    A

    Z

    A

    COA

  • Input – Output Plot

    0

    0.2

    0.4

    0.6

    0.8

    1

    0

    0.2

    0.4

    0.6

    0.2

    0.3

    0.4

    0.5

    0.6

    number_of_serversmean_delay

    nu

    mb

    er_

    of_

    spa

    res

    0 5 10 15 20 25 300

    10

    20

    30

    40

    50

    60

    70

    80

    90

    100

    temp

    fan-s

    peed

    Example: Air Conditioner

    one input – one output

    gives nonlinear transfer

    characteristic More general example:

    two inputs – one output gives

    3D transfer surface 76