Artificial Intelligence - Get as PowerPoint

Document Sample
Artificial Intelligence - Get as PowerPoint Powered By Docstoc
					Introduction To Fuzzy Logic




     Dr. Emad A. El-Sebakhy

 Room: 22-316, Phone: 860-4263
Email: dodi05@ccse@kfupm.edu.sa
        What Is Fuzzy Logic ?
  Fuzzy logic is a powerful problem-solving
  methodology with a lot of applications in
  embedded control and information processing .


Fuzzy provides a remarkably simple way to draw definite
conclusions from vague, ambiguous or imprecise
information.

In a sense, fuzzy logic resembles human decision making
with its ability to work from approximate data and find
precise solutions.
       What Is Fuzzy Logic ?
   Unlike classical logic which requires a deep
    understanding of a system, exact equations, and
    precise numeric values.
   Fuzzy logic incorporates an alternative way of
    thinking, which allows modeling complex systems
    using a higher level of abstraction originating
    from our knowledge and experience.
   Fuzzy Logic allows expressing this knowledge with
    subjective concepts such as very hot, bright red,
    and a long time which are mapped into exact
    numeric ranges.
           What Is Fuzzy Logic ?
   Fuzzy Logic has been gaining increasing acceptance
    during the past few years. There are over two thousand
    commercially available products using Fuzzy Logic,
    ranging from washing machines to high speed trains.
   Nearly every application can potentially realize some of
    the benefits of Fuzzy Logic, such as performance,
    simplicity, lower cost, and productivity.
Fuzziness vs. Probability
    1. Fuzziness is deterministic uncertainty – probability is
       nondeterministic.
    2. Fuzziness describes event ambiguity – probability describes
       event occurrence. Whether an event occurs is random. The
       degree to which it occurs is fuzzy.
    3. Probabilistic uncertainty dissipates with increasing number of
       occurrences fuzziness does not.
            Why Use Fuzzy Logic ?
   An Alternative Design Methodology Which Is
    Simpler, And Faster
      Fuzzy Logic reduces the design development
       cycle
      Fuzzy Logic simplifies design complexity
      Fuzzy Logic improves time to market
   A Better Alternative Solution To Non-Linear
    Control
      Fuzzy Logic improves control performance
      Fuzzy Logic simplifies implementation
      Fuzzy Logic reduces hardware costs
          Some Historical Developments
Fuzzy systems have been around since the 1920s, when they where first
 proposed by Lukaciewicz. He proposed to modify traditional false (0) true
 (1) reasoning to include some truth such as 0.5.
Since then the approach has been further develop and systems have
 incorporated the methodologies:

     1965 - Fuzzy Set Theory (Prof. Lofti A. Zadeh, U. of Cal. at
      Berkely)
     1966 - Fuzzy Logic (Dr. Peter N. Morinos, Bell Labs.)

     1972 - Fuzzy measure (Prof. Michio Sugeno, TIT)

     1974 - Fuzzy logic controller (Prof. E.H. Mamdani, London
      Univ.)
     1980 - Control of cement0kiln with monitor capability
      (Denmark)
     1987 - Automatic train operation for Sendai Subway (Hitachi,
      Japan)
     1988 - Stock Trading Expert System (Yamaichi Security, Japan).
What is Fuzziness?
Fuzziness is deterministic uncertainty. It is concerned with the
degree to which events occurrence rather than the likelihood of
their occurrence. For example, the degree to which a person
is tall is a fuzzy event rather than a random event.


 Fuzzy Logic vs Boolean Logic

   Two fundamental assumptions of traditional logic:
     An element belongs to a set or its complement
     An element cannot belong to both a set and its complement --
      law of excluded middle
 Traditional logic is crisp.
 Fuzzy logic violates both the above assumptions.
         Fuzzy Logic generalizes
             Boolean Logic
   It is very useful that the Boolean Logic is included in
    the Fuzzy Logic
   If we think of x and y as “crisp” values 0 and 1, Fuzzy
    logic gets back to Boolean logic.
          Truth values   Boolean logic    Fuzzy logic
          X      Y       X AND Y X OR Y   MIN(X, Y) MAX(X, Y)
          0      0       0         0      0          0
          0      1       0         1      0          1
          1      0       0         1      0          1
          1      1       1         1      1          1
          0.2    0.7     -         -      0.2        0.7
          1      0.4     -         -      0.4        1
                    Fuzzy Vs. Crisp Values
    A crisp value is a precise number that represents the exact status
    of the associated phenomenon.

    Example: The fastest land mammal, cheetahs can accelerate from 0 to 70
    mph in 3 seconds. A Lamborghini Diablo sports car accelerates from 0 to 62
    mph in 4 seconds! Of course, you can use the car to go on an appointment.

    A fuzzy value is an ambiguous term that characterizes an
    imprecise or not very well understood phenomenon.

                                Example: Cheetahs can run very fast.

Fuzzy Set Theory provides the means for representing uncertainty
    using set theory.

     Example: Any velocity between 45 and 70 mph is a very fast velocity.
              Any velocity between 25 and 57 mph is a fast velocity.
                        Fuzzy Sets
      Sets   with fuzzy boundaries
                                        A = Set of tall people
          Crisp set A                      Fuzzy set A
1.0                               1.0
                                   .9
                                   .5                        Membership
                                                              function


               5’10’’   Heights               5’10’’ 6’2’’     Heights
                              Fuzzy Sets
      Fuzzy sets and set membership is the key to decision making when faced with
       uncertainty (Zadeh, 1965).

      Classical sets contain objects that satisfy precise properties.
      Fuzzy sets contain objects that satisfy imprecise properties of membership
       (membership of an object can be approximate).

       Example: The set of heights from 5 to 7 feet is crisp (classical set);
                  The set of heights in the region around 6 feet is fuzzy.
      A fuzzy set can be defined as a set of crisp values that can be group together
       with an associated fuzzy term.
       Example: A person between 5 ft and 6 ft belongs to the set of tall people.


NOTE: Because a crisp value can belong to a fuzzy set in one context and to
another set in a different context a crisp value can be associated to more
than one fuzzy set. For example, the set of tall people can overlap
with the set of non-tall people (an impossibility in the world of binary logic).
                        Fuzzy Sets
   Formal definition:
    A fuzzy set A in X is expressed as a set of ordered pairs:


                   A  {( x,  A ( x ))| x  X }

                           Membership              Universe or
       Fuzzy set
                            function          universe of discourse
                              (MF)


             A fuzzy set is totally characterized by a
                   membership function (MF).
                                Types of fuzzy sets
   There are basically two types of fuzzy sets: normal and subnormal.

           (x)                                          (x)
                       A
       1                                             1
                                     Height of the                      A             Height of the
                                     fuzzy set                                        fuzzy set
       0                                x            0                                      x
                  Normal fuzzy set                              Subnormal fuzzy set



    A normal fuzzy set is one whose                      A subnormal fuzzy set is one whose
    membership function has at least                     membership function doesn’t have
    one element x in the universe                        an element x in the universe
    whose membership is unity.                           whose membership is unity.
    Fuzzy Sets with Discrete Universes
   Fuzzy set C = “desirable city to live in”
    X = {SF, Boston, LA} (discrete and nonordered)
    C = {(SF, 0.9), (Boston, 0.8), (LA, 0.6)}
   Fuzzy set A = “sensible number of children”
    X = {0, 1, 2, 3, 4, 5, 6} (discrete universe)
    A = {(0, .1), (1, .3), (2, .7), (3, 1), (4, .6), (5, .2), (6, .1)}
    Fuzzy Sets with Cont. Universes
   Fuzzy set B = “about 50 years old”
    X = Set of positive real numbers (continuous)
    B = {(x, B(x)) | x in X}




                        1
        B(x) 
                      x  50 
                                2

                  1         
                      10 
              How to represent fuzzy sets
    There are two common ways to represent fuzzy sets depending if the set is
     discrete or continuous.

  Discrete fuzzy sets:
A notation convention for fuzzy sets when the universe of disclosure, X, is discrete
   and finite, is as follows for a fuzzy set A:             The  is not for algebraic
                                                              summation but rather
    A = {A(x1)/x1 + A(x2)/x2 + … } = {i [ A(xi)/xi ]}     denotes the collection or
                                                              aggregation of each element;
                                                              hence the “+” signs are not
                                                              algebraic add but are a
   Continuous fuzzy sets:                                    function-theoretic union.
When the universe, X, is continuous and
finite, the fuzzy set A is denoted by:
                                                   In both notations:
The  sign is not an                               •Not a quotient bar but a delimiter
algebraic integral but a                           •The numerator in each term is the
continuous function- A
theoretic union notation
                                
                            = { [ A(xi)/xi }       membership value in set A associated
                                                    with the element of the universe
for continuous variables.                           indicated in the denominator.
            Alternative Notation
   A fuzzy set A can be alternatively denoted as
    follows:

            X is discrete
                                     A   
                                          xi X
                                                  A   ( xi ) / xi


          X is continuous            A    A( x) / x
                                          X



       Note that  and integral signs stand for the union of
       membership grades; “/” stands for a marker and does
       not imply division.
               Fuzzy Partition
   Fuzzy partitions formed by the linguistic values
    “young”, “middle aged”, and “old”:




                         lingmf.m
                 Fuzzy Set Operations

   Standard Complement of a fuzzy set A:
     A(x)   = 1- A(x)
 Elements for which A(x) = A(x) are called
  equilibrium points.
 Standard intersection AB:
    =   min[A(x),B(x)]
   Standard union AB:
     (A    B)(x) = max[A(x),B(x)]
1. Complement (or negation) = 1-




2. Union (logical or): Largest (maximum) membership functions.

                                                                           Union of A and B : A  B
              Set A                             Set B


 Note that the membership degree is not the same as a probability although the values that it may
 3. Intersection (and):               Smallest (minimum) membership is not 50 / 50
 take are the same (0 to 1). The chance of a 25 year old being young or not young functions. -
 rather the degree to which a 25 year old exemplifies young is about half (0.50).

             Set A                                                        Intersection of A and B : A  B
 Set operators can be defined on fuzzy sets similarly to those on crisp sets.
                                               Set B



                  Set A                    Complement of Set A : Not A
                           Operations on Fuzzy sets
   If we define 3 fuzzy sets, A, B and C on the universe X, for a given element
    x of the universe the following are examples of operations defined on A, B
    and C.

Some operations on fuzzy sets:
Union           AB(x) = A(x) \/ B(x)
Intersection    AB(x) = A(x) /\ B(x)
Complement      Ā(x) = 1 - A(x)
etc.
                                                                                                 A
      1                                       1         A
                                                                                  1
       0.7
                  A              B                                     B

       0.3                                    0.3
      0                    14
                                          x   0             10   14   15   x      0                               x
              5       10    15       17
                      Union                         Intersection                         Complement

    The fuzzy sets A and B may be represented as:                The resulting fuzzy set may be represented as:
    A = { 0/5 + 1/10 + 0.3/14 + 0/15 }                           AB = { 0/10 + 0.3/14 + 0/15 }
    B = { 0/10 + 1/14 + 0.7/15 + 0/17 }
                                                                 How would AB be represented?
                        Membership functions
   All information contained in a fuzzy set is described by its membership
    function.                                       core
                                    
                                1
    Membership functions
    can be symmetrical or
    asymmetrical.               0                              x
                                         boundary       boundary

                                             support

   The Core of a membership function is defined as the region of the universe that
    is characterized by complete and full membership in the set. The core comprises
    those elements for which, (x) = 1
   The support is defined as that region of the universe that is characterized by
    nonzero membership in the set: (x) > 0
   The boundaries are defined as that region of the universe containing elements
    that have nonzero membership but not complete membership: 0 < (x) < 1
        Membership when using fuzzy sets
For crisp sets an element x in the universe X is either a member of some crisp set, say A
 on the universe. This binary issue of membership can be represented mathematically
 as:
                                            1,  A
                          x A(x) ={    0,  A

where the symbol x A(x) gives the indication of an unambiguous membership of
element x in set A.


Fuzzy membership extends the notion of binary membership to accommodate
 various “degrees of membership” on the real continuous interval [0, 1], where the
 endpoints conform to no membership and full membership, respectively. The sets on
 the universe X that can accommodate “degrees of membership” are referred as “fuzzy
 sets”.
More Definitions                       MF Terminology
   Support
                                 MF
   Core
   Normality                     1

   Crossover points              .5
   Fuzzy singleton               a
   a-cut, strong a-cut           0
                                               Core            X
   Convexity                               Crossover points
   Fuzzy numbers                               a - cut
   Bandwidth                                  Support
   Symmetricity
   Open left or right, closed
     The Common Membership Functions

Each fuzzy set has a
membership function.
These are normally
trapezoidal, triangular
or Gaussian (normal).
These are usually
normalized, that is,
have a maximum
value of 1. In the picture above, the fuzzy set young is
described with a trapezoidal membership function. All
ages less than 20 have full membership (=1) and all ages
greater than 30 have no membership (=0). In between is a
linear relationship between age and membership. Age 25 has
 =0.5.
           Set-Theoretic Operations




                                      fuzsetop.m
subset.m




Common MF Formulation
                                                             x a c  x 
                                trimf ( x ;a,b ,c )  max min     ,      , 0
                                                             b  a c  b 
Triangular MF:
                                                                 x a     d  x 
                                trapmf ( x ;a,b ,c ,d )  max min     ,1,       , 0
Trapezoidal MF:                                                  ba      d c 
                                                                                   2
                                                                      1  x c 
                                                                             
                                                                      2  
Gaussian MF:                     gaussmf ( x ;a,b ,c )  e
                                                                    1
                                 gbellmf ( x ;a ,b ,c )                  2b
Generalized bell MF:                                            x c
                                                             1
                                                                  b
                   MF Formulation
      disp_mf.m




                                                            1
Sigmoidal MF:               sigmf ( x ;a ,b ,c )                         Extensions:
                                                     1 e   a ( x c )



Absolute difference of two MF




  Product of two MF
   Membership Functions (MFs)
Characteristics   of MFs:
  Subjectivemeasures
  Not probability functions


   MFs                         “tall” in Asia


     .8
     .5                           “tall” in the US

                                “tall” in NBA
     .1
                      5’10’’                         Heights
                Fuzzy Rules and Inference
 Fuzzy rules are simply rules where the premises and conclusions are fuzzy.
 But crisp values can be incorporated as well.
 When using rules you have to select a fuzzy inference methodology and
 applied it to the conclusion. The two most popular fuzzy inference
 methodologies are:

     Rule

     IF A
     THEN B                                     }     Max-Product Inference


Input (crisp)

                               Rule



    Max-Min Inference   {      IF A
                               THEN B


                             Input (crisp)
           Fuzzy rules and their results
    Rule           Distance (D)      Velocity (V)            Acceleration (A)

                                           Slow                    Medium
IF D = Medium               Medium
OR V = Slow
THEN A = Medium


                                  Inputs

                  Medium                                           Slow
                                                    Medium
IF D = Medium
OR V = Medium
THEN A = Slow




                           Final acceleration = Centroid
    Fuzzy Logic/Sets: Example

   Let Y be the set of all flowers that are yellow. Let
    X, the universe of discourse, be the set of flowers
    in my backyard. In standard set theory, every
    flower x in X is either an element of Y or not. In
    fuzzy set theory, every flower x has a degree of
    yellowness mY(x).
   Let F be the set of all flowers that are perfumed .
   Let x be a flower in my backyard. If mY(x) = 0.8
    and mF(x) = 0.9 then mY&F(x) = min{0.8,0.9} =
    0.8.
                                 Fuzzification
   Fuzzification is the process of
    making a crisp quantity fuzzy
   We do this by simply recognizing
    that many of the quantities that we
    consider to be crisp and
    deterministic are actually               Example: In the real world, hardware
    nondeterministic at all: They carry      such as a digital scale generates
                                             crisp data, but these are subject
    considerable uncertainty.                to experimental error.

                                             The information shown in the figure
    If the form of uncertainty happens to    below shows one possible range of
    arise because of imprecision,            errors for a typical weight measure and
    ambiguity, noise or vagueness, then      the associated membership function
    the variable is probably fuzzy and can   that might represent such imprecision.
    be represented by a membership                                   Reading
                                                      1
    function.


                                                      0                        x
                                                            -1%       +1%
                                    Fuzzification
      The representation of imprecise data as fuzzy sets is a useful but not
       mandatory step when those data are used in fuzzy systems.

      This idea is shown in the following figure where we can consider the data
       as a crisp or as a fuzzy reading (Figures “a” and “b”).
                                                               1
                1         Reading (crisp)                                  Reading (fuzzy)
Low voltage                                            Medium
                                                       voltage
                                                              0.4                 Membership
                0.3              Membership

                0                  voltage                     0    -1%     +1%    x
      a)                                              b)

      In Fig “a” we might want to compare        In Fig “b” the intersection of the fuzzy set
      A crisp voltage reading to a fuzzy         “Medium voltage” and a fuzzified voltage
      set, say “Low voltage”. In the figure      reading occurs at a membership of
      we see that the crisp reading intersects   0.4. We can see that the intersection
      the fuzzy set at a membership of 0.3,      of the two fuzzy sets is a small triangle,
      i.e., the fuzzy set and the reading can    whose largest membership occurs at 0.4.
      be said to agree at a membership value
      of 0.3.
                       Defuzzification methods




                         (x)  x dx          Weighted average                  x* =
                                                                                             (x)  x
                                                                                              (x)
                x* =
 Centroid
                           (x) dx

         Max-membership
         or Height method




  ( x* ) >= ( ( x ))
                                                                             n

                                        Center of sums             X
                                                                        x   
                                                                            k=1
                                                                                   k (x)   dx
Mean-max membership                                      x* =               n


   x * = (a + b) / 2
                                                                 X
                                                                        k=1
                                                                                  k (x)   dx
     Fuzzy logic operations Summary

   Fuzzy math involves in general three operations:
    1. Fuzzyfication – membership function
    2. Rule evaluation
    3. Defuzzyfication
                       Fuzzyfication
   It makes the translation from real world values to Fuzzy world
    values using membership functions. The membership functions in
    Fig.1, translate a speed= 55 into fuzzy values (Degree of
    membership) SLOW=0.25, MEDIUM=0.75 and FAST=0.
                   Rule Evaluation
   Rule1: If Speed=Slow and Home=Far then Gas=Increase
   Supose SLOW=0.25 and FAR=0.82. The rule strength will
    be 0.25 (The minimum value of the antecedents) and the
    fuzzy variable INCREASE would be also 0.25.
   Rule2: If Speed=Medium and Higher=Secure then
    Gas=Increase
   Suppose in this case, MEDIUM=0.75 and SECURE=0.5.
    Now the rule strength will be 0.5 and the fuzzy variable
    INCREASE would be also 0.5.
   So, we have two rules involving fuzzy variable
    INCREASE. The "Fuzzy OR" of the two rules will be 0.5
    (The maximum value between the two proposed values).
   INCREASE=0.5
                       Defuzzyfication
   After computeing the fuzzy rules and evaluating the fuzzy
    variables, we will need to translate these results back to the real
    world. We need now a membership function for each output
    variable like in Fig. 2.
   Let the fuzzy variables be:
    DECREASE=0.2, SUSTAIN=0.8, and INCREASE=0.5
         Defuzzyfication …
   Each membership function will be clipped to
    the value of the correspondent fuzzy variable
    as shown in fig.3.
                  Defuzzyfication …
   Defuzzification is the process of making a fuzzy quantity crisp.

   There are different ways to do this and the deffuzification process to be used
    greatly depends on the degree of uncertainty within the fuzzy set
   A new output membership function is built, taking for each point in the
    horizontal axis, the maximum value between the three membership values.
   Then take the centroid. Here, Engine=+2.6




                                                  2.6
       Steps Needed for Building a Fuzzy System
   Step 1.- Determine the values of the input and output
    variables.
   Step 2.- Fuzzify the variables: create fuzzy sets to represent
    the different values of the input variables. Fuzzification is the
    process of making a crisp quantity fuzzy.
   Step 3.- Create fuzzy sets for the output variables of the
    system.
   Step 4.- Generate a set of fuzzy rules based on the input and
    output fuzzy sets.
   Step 5.- Choose a deffuzification method and apply it to the
    results obtained from the rules that are satisfied.
   Step 6.- The crisp value obtained from Step 5 is the answer to
    your problem.
Example
• The inverted pendulum
• Inputs: the angle  and d/dt input values
The fuzzy regions for the input values  (a) and d/dt (b).




The fuzzy regions of the output value u, indicating
         the movement of the pendulum base.
The fuzzification of the input measures x1=1, x2 = -4.




  The Fuzzy Associative
  Matrix (FAM) for the
  pendulum problem.
  The input values are on
  the left and top.
The fuzzy consequents
(a) And their union (b).
The centroid of the
union (-2) is the crisp
output.
 Characteristics and Comparison of Four AI Techniques
   Characteristics         ES or KBS           Fuzzy Logic               ANNs                    GAs
Knowledge representation       Explicit             Explicit             Implicit               Explicit

Numerical computation          External             Inherent             Inherent               Inherent

Training & development       Depends on        Depends on experts    Depends on data      Depends on experts &
                              experts               & data                                       data
Development time           Slow to moderate    Slow to moderate      Moderate to fast       Moderate to fast

on-line processing           May be slow         May be slow to            Fast             Slow to moderate
                                                  moderate
Initial development        Define variables     Define variables    Define input output      Define fitness
                           & input-output       and membership       parameters and       function, coding and
                              relations            functions          initial network        chromosomes
                                                                        architecture
Refinements                   Add new          Add new relations,    Adjust network         Adjust mutations,
                           relations, rules,   tune membership      weights and maybe     crossover probability
                            correct logical     functions, adjust        network            & fitness function
                           inconsistencies           beliefs           architecture
Testing                        Expert            Data & Expert             Data                   Data

Comments                   Used in complex        Used in high      20%-25% of data          Used mainly in
                             domains &         technology devices    goes to training.        optimization
                             professions                                                       problems
Fuzzy Logic Applications Area
             Application areas
   Fuzzy Control
     Subway trains
     Cement kilns
     Washing Machines
     Fridges

    Video  cameras
    Electric shavers
              Fuzzy Sets Review
 Extension of Classical Sets
 Not just a membership value of in the set
  and out the set, 1 and 0
     but   partial membership value, between 1 and 0
             Example: Height
   Tall people: say taller than or equal to 1.8m
     1.8m , 2m, 3m etc member of this set
     1.0 m, 1.5m or even 1.79999m not a member



   Real systems have measurement uncertainty
     sonear the border lines, many
      misclassifications
                      Member Functions
   Membership function
     better   than listing membership values
   e.g.
    Tall(x) = {1 if x >= 1.9m ,0 if x <= 1.7m, else ( x - 1.7 ) / 0.2 }
            Example: Fuzzy Short

   Short(x) = {0 if x >= 1.9m ,
    1  if x <= 1.7m
     else ( 1.9 - x ) / 0.2 }
           Fuzzy Set Operators Again
   Fuzzy Set:
     Union
     Intersection
     Complement



   Many possible definitions
     we   introduce one possibility
               Fuzzy Set Union

   Union ( fA(x) and fB(x) ) = max (fA(x) , fB(x) )
   Union ( Tall(x) and Short(x) )
             Fuzzy Set Intersection
   Intersection ( fA(x) and fB(x) ) = min (fA(x) , fB(x) )
   Intersection ( Tall(x) and Short(x) )
             Fuzzy Set Complement
   Complement( fA(x) ) = 1 - fA(x)
   Not ( Tall(x) )
Fuzzy Logic Operators Summary
   Fuzzy Logic:
     NOT (A) = 1 - A
     A AND B = min( A, B)
     A OR B = max( A, B)
Fuzzy Logic NOT
Fuzzy Logic AND
Fuzzy Logic OR
               Fuzzy Controllers
   Used to control a physical system
Structure of a Fuzzy Controller
                  Fuzzification
 Conversion of real input to fuzzy set values
 e.g. Medium ( x ) = {
    0  if x >= 1.90 or x < 1.70,
     (1.90 - x)/0.1 if x >= 1.80 and x < 1.90,
     (x- 1.70)/0.1 if x >= 1.70 and x < 1.80 }
                    Inference Engine

   Fuzzy rules
     based   on fuzzy premises and fuzzy consequences


   e.g.
     Ifheight is Short and weight is Light then feet are
      Small
     Short( height) AND Light(weight) => Small(feet)
        Fuzzification & Inference
                Example
   If height is 1.7m and weight is 55kg
     what   is the value of Size(feet)
                      Defuzzification

   Rule base has many rules
     sosome of the output fuzzy sets will have
      membership value > 0

     Defuzzify    to get a real value from the fuzzy
      outputs
        One   approach is to use a centre of gravity method
         Defuzzification Example
   Imagine we have output fuzzy set values
     Small membership value = 0.5
     Medium membership value = 0.25
     Large membership value = 0.0

   What is the deffuzzified value
Fuzzy Control Example
              Input Fuzzy Sets
   Angle:- -30 to 30 degrees
            Output Fuzzy Sets
   Car velocity:- -2.0 to 2.0 meters per second
                   Fuzzy Rules
   If Angle is Zero then output ?


   If Angle is SP then output ?


   If Angle is SN then output ?


   If Angle is LP then output ?
   If Angle is LN then output ?
Fuzzy Rule Table
                     Extended System
   Make use of additional information
     angular   velocity: -5.0 to 5.0 degrees/ second
   Gives better control
                   New Fuzzy Rules
 Make use of old Fuzzy rules for angular velocity
  Zero
 If Angle is Zero and Angular velocity is Zero
     then   output Zero velocity
   If Angle is SP and Angular velocity is Zero
     then   output SN velocity
   If Angle is SN and Angular velocity is Zero
     then   output SP velocity
Table format
                Complete Table
   When angular velocity is opposite to the
    angle do nothing
     System   can correct itself

   If Angle is SP and Angular velocity is SN
     then   output ZE velocity
   etc
                  Example
 Inputs:10 degrees, -3.5 degrees/sec
 Fuzzified Values


   Inference Rules

   Output Fuzzy Sets

   Defuzzified Values
      Example of a Fuzzy Controller
A cart on a 4-meter long track. The goal is to return
the cart to the center of the track with 0 velocity. The
available control is to push or pull on the cart.




   -2m                         0m                          2m
                   Cart Position
      m(x)


        left        middle        right
 1.0

                                     notice that sets overlap

0.0
                                                   x
 -2m         -1m     0m      1m           2m
              Cart Velocity
      m(x)

         moving        standing    moving
         left          still       right
 1.0




0.0
                                                   x
 -1m/s       -0.5m/s    0m/s      1m/s      2m/s
                     Cart Force
      m(F)

        pull                 push
                     none
 1.0




0.0
                                         F
  -1N        -0.5N    0N    0.5N    1N
    Simple Control Rules

 If left then push
 If right then pull
 If middle then none
 If moving left then push
 If standing still then none
 If moving right then pull
 If left and moving left then push
 If right and moving right then pull
      Fuzzy Control Algorithms
 Find the sensor values
   For example, the position might be x = -0.5
    meters and v = 0.
 Calculate the fuzzy membership
   For example, mmiddle(x = -0.5) = 0.5 and
    mleft(x = -0.5) = 0.5.
 Calculate the membership of the rule
  antecedents for all control rules.
 Apply the rules
 Aggregate the results from all control rules
 “De-fuzzify” to arrive at a single-valued action
  recommendation.
          Dempster-Shafer Theory
   Dempster-Shafer considers sets of propositions and
    provides an interval within which the belief must lie.
   interval = [Belief, Plausibility]
   Belief brings together all the evidence that would lead
    us to believe in the proposition with some certainty.
   Plausibility brings together the evidence that is
    compatible with the proposition and is not
    inconsistent with it. pl(p) = 1 – bel(p)
   So..the interval is a measure of our belief in the
    proposition and the amount of information we have
    to support this belief.
                Coin Toss Example
   Let’s say Bart goes up to Homer and bets him
    $20 that the coin he has in his hand will be
    heads on a coin toss. Homer is like, “Yeah
    right, you trying to trick me boy?! It’s a two
    headed coin isn’t it?”
              Coin Toss Example
   Belief(Heads) = 0
   Belief(not Heads) = 0
   Should Homer take the bet?

All of a sudden Lisa comes in and tells Bart to give her
back her quarter. Homer, knowing Lisa to be honest, now
thinks that maybe the coin isn’t a two-headed coin.
Homer is 80% sure about this. This now increases the
belief functions.
              Coin Toss Example
   Belief(Heads) = (Homer’s deduced certainty *
             probability of it coming up heads)
           = 0.8 * 0.5 = 0.4

   Belief(not Heads) =
           (Homer’s deduced certainty *
           probability of it not coming up heads)
       = 0.8 * 0.5 = 0.4
              Coin Toss Example

   The probability interval when being ignorant
    would be [0,1] for the probability of heads
    coming up on a coin toss.

   After Lisa comes into the scene, Homer
    deduces the coin’s probability, increasing the
    uncertainty, so the interval becomes [0.4, 0.6].

   Smaller intervals allows the reasoning system
    to make decisions, based from new information.
                          Example:
   Melissa is 90% reliable.
   She said, the computer is broken into
      Belief in computer being broken into = 0.9
      Belief in computer not being broken into = 0
      Pl(broken) = 1-0 = 1
      [belief,plausibility](broken) = [0.9,1]
   Bill is 80% reliable.
   He said, the computer is broken into
      Belief in computer being broken into = 0.8
      Belief in computer not being broken into = 0
      Pl(broken) = 1-0 = 1
      [belief,plausibility](broken) = [0.9,1]
   Probability that both of them are unreliable is 0.02
      Combined [belief,plausibility](broken) = [0.98,1]
       Dempster-Shafer Theory …

 Let  represent our ‘frame of discernment’,
  which is the set of all hypothesis. We want to
  attach a measure of belief to each of these
  hypothesis after we have been presented with
  some evidence.
 But the evidence may support subsets of .
 Also evidence supporting one hypothesis may
  alter our belief in other hypothesis.
 Dempster-Shafer allows us to handle these
  interactions.
    Dempster-Shafer Theory …

 If  contains n elements then there are 2n
  subsets of  (including the empty set ).
 m(p) is the current belief for each of the
  subsets of .
 Dempster-Shafer allows us to combine m’s
  that arise from multiple sources of evidence.
                          Example:
   A patient may be suffering from Cold, Flue,
    migraine Headache or Meningitis
   Call this set of hypothesis Q = {C,F,H,M}
   Patient has fever, which supports {C,F,M} at 0.6
     That’s,   m1({C,F,M}) = 0.6, m1(Q)=0.4
   Patient has extreme nausea, which supports
     m2({C,F,H})        = 0.7, m2(Q)=0.3
   We can combine these two belief distributions
     m1({C,F,M}) = 0.6    m2({C,F,H}) = 0.7   m3({C,F}) = 0.42
     m1(Q)=0.4            m2({C,F,H}) = 0.7   m3({C,F,H}) = 0.28
     m1({C,F,M}) = 0.6    m2(Q)=0.3           m3(C,F,M)=0.18
     m1(Q)=0.4            m2(Q)=0.3           m3(Q)=0.12
    All   the sets in m3 are non-empty and unique
                       Example …
   Third evidence, lab culture supports
      m4({M}) = 0.8 and m4(Q) = 0.2
   We can combine this with m3
        m3({C,F}) = 0.42     m4({M}) = 0.8   m5’({}) = 0.336
        m3({C,F,H}) = 0.28   m4({M}) = 0.8   m5’({}) = 0.224
        m3(C,F,M)=0.18       m4({M}) = 0.8   m5’({M}) = 0.144
        m3(Q)=0.12           m4({M}) = 0.8   m5’({M}) = 0.096
        m3({C,F}) = 0.42     m4(Q)=0.2       m5’({C,F})=0.084
        m3({C,F,H}) = 0.28   m4(Q)=0.2       m5’({C,F,H}) =0.056
        m3(C,F,M)=0.18       m4(Q)=0.2       m5’ ({C,F,M}) = 0.036
        m3(Q)=0.12           m4(Q)=0.2       m5’(Q)=0.024
   The denominator is = 1- (0.336 + 0.224) = 0.44
   m5({M}) = (0.144 + 0.096)/0.44 = 0.545,
    m5({C,F})=0.191
    m5({C,F,H}) =0.127, m5’({C,F,M}) = 0.082,
    m5(Q)=0.055
    m5({}) = 0.56
     Summary on Dempster-Shafer
   A large belief assigned to empty set (as 0.56 in the
    previous example) indicates that there is conflicting
    evidence in belief sets.

   When there are large hypothesis sets and complex sets
    of evidence, calculations can get cumbersome.

   But complexity is still less than Bayesian approach.

   Very useful tool when stronger Bayesian conclusions
    may not be justified.

   A distinction is made between probability of a
    proposition given uncertain evidence, and probability
    of proposition given no evidence.
                 Default Reasoning
   A gentle introduction
   Simulates human nature of qualitative reasoning.
      All birds fly.
      Emu is a bird.
      Therefore, Emu flies.
      Went to Australia and saw it does nor fly.
      Update your belief !
   “Jumping to conclusions”
   “Making assumptions”
   To believe one thing until a reason is found to believe
    otherwise.
      Default Reasoning Example
Homer is at work at the Springfield nuclear power
plant. Now he’s having some coffee and doughnuts
and accidentally spills it over some controls. All of
a sudden there are explosions and alarms are going
off in the plant. Homer is frantic and is saying, “Oh
my god, oh my god, Mr. Burns is going to fire me.
Oh no, what do I do, what do I do?”


Then Smithers comes and
tells Homer that Mr. Burns
wants to see him.
              Default Reasoning
   Homer’s assumption that he is going to be fired
    by Mr. Burns is an example of default
    reasoning.

   Later Homer finds out that he wasn’t even at his
    own workstation, he was at someone else’s
    workstation, so Homer doesn’t have to worry
    about being fired now. He retracts his initial
    assumption, and gives a big sigh and relaxes.
      Default Reasoning Problems

 What are good default rules to have?
 What to do in the case where some evidence
  matches two default rules with different
  conclusions?
   What conclusions should be kept and which
    ones should be retracted?
   How can beliefs that have default status be
    used to make decisions?
           Fuzzy Logic (FL) vs CF
   We use both FL and CF to handle incomplete
    knowledge
   In FL, Precision/vagueness is expressed by
    membership function to a set

               young          adult         pensioner




   mF(20,adult)=0.6, mF(20,young)=0.4, mF(20,old)=0
   Fuzzy Logic is not concerned how these distribution
    are created but how they are manipulated.
   There are many interpretations, similar to Certainty Algebra
                          Exercises

Given the fuzzy sets:-
   Tall(X) = {    0 if X < 1.6m
                  (X - 1.6m) / 0.2, if 1.6m <= X < 1.8m
                  1, if X >= 1.8m }
   Short(X) = { 1 if X < 1.6m
                  (1.8m - X) / 0.2, if 1.6m <= X < 1.8m
                  0, if X >= 1.8m }

a). Sketch the graphs of Tall(X) and Short(X).

b).     i. Calculate the Union of the fuzzy sets Tall(X) and Short(X).
      ii. Calculate the Intersection of the fuzzy sets Tall(X) and Short(X).

c). Show that the complement of Tall(X) is Short(X).
Given additional fuzzy sets:-
    Strong(Y) = { 0 if Y < 30kg
                    (Y - 30kg) / 20, if 30kg <= Y < 50kg
                    1, if Y >= 50kg }
    Weak(Y) = { 1 if Y < 30kg
                    (50kg - Y) / 20, if 30kg <= Y < 50kg
                    0, if Y >= 50kg }

  and the fuzzy rules:-

    If Tall(X) OR Strong(Y) then Heavy(Z)
    If Short(X) AND Weak(Y) then Light(Z)

Calculate the membership values of Heavy(Z) and Light(Z)
where
   i. X = 1.65m, Y = 30kg
   ii. X = 1.70m, Y = 45kg
        Complexity of the system Vs. precision in its model

        Precision in the model
                                 Mathematical
                                 equations        Model-free
                                                  Methods
                                                  (e.g., ANNs)
                                                                        Fuzzy Systems



                                          Complexity (uncertainty) of the system

For systems with little complexity, hence little uncertainty, closed-form
      mathematical expressions provide precise description of the system.
For systems that are a little more complex, but for which significant data exists,
      model free methods such as artificial NNs, provide a powerful and robust
      means to reduce uncertainty through learning, based on patterns in the
      available data.
For most complex systems where few numerical data exists and where only
      ambiguous or imprecise information may be available, fuzzy reasoning
      provides a way to understand system behavior by allowing us to interpolate
      approximately between observed input and output situations.