Fuzzy Logic • Today’s class: No notes, but the following are useful resources: http://www.seattlerobotics.org/Encoder/mar98/fuz/flindex.html http://www.cs.cmu.edu/Groups/AI/html/faqs/ai/fuzzy/part1/faq.html http://plato.stanford.edu/entries/logic-fuzzy/ • Objectives: – Broaden FOL treatment in R&N. – Given a description of a set of behaviors and their fuzzy input and output sets, combine the behaviors using the centroid of area and centroid of largest area methods. – Be able to evaluate fuzzy rules with conjunctions, disjunctions, and negations Fuzzy Logic CSCE 420-500 Introduction to AI 1
Lofti Zadeh 2 CSCE 420 Introduction to AI
Fuzzy Logic • What if the precise value of the vector output wasn’t important? – The opposite of “precise” is “fuzzy” • Turn HARD_RIGHT instead of -90 deg • Go FAST instead of 0.8*Vmax • This may be more natural, more linguistic How do we generate and combine outputs like HARD_RIGHT and SOFT_LEFT? 3 CSCE 420 Introduction to AI
General Procedure • Generate fuzzy outputs (Fuzzification) – Usually have perception operations that yields a “crisp” number that is then converted to a fuzzy input (fuzzified) • Apply fuzzy rules (Fuzzy Rules) – The control logic has rules to convert the the fuzzy input into a fuzzy output • Combine fuzzy outputs (Defuzzification) – When multiple components produce fuzzy outputs, they have to be converted to a single “crisp” number 4 CSCE 420 Introduction to AI
Motivating Example: Swerving Robot • “Swerve” is a runaway behavior that doesn’t let the robot turn more than 90 degrees from current direction – Vdir: [0,90] – Closer the robot, the harder the turn to the right • Robot velocity is same (for simplicity) 5 CSCE 420 Introduction to AI
Linguistic-based rules • Swerve 1 (from sensor 1) – If an obstacle is close, take a HARD RIGHT • Swerve 2 (from sensor 2) – If an obstacle is far, take a SOFT RIGHT 6 CSCE 420 Introduction to AI
Fuzzy Sets: Domain CLOSE Degree of membership 1 0 0 10 Crisp domain: PROXIMITY Distance from robot CLOSE is a fuzzy set over the domain 7 CSCE 420 Introduction to AI
Fuzzy Sets: Multiple Sets CLOSE FAR Degree of membership 1 0 0 10 Crisp domain: PROXIMITY Distance from robot Notes: • Fuzzy sets often overlap -- that’s seen as a Good Thing • Set can have different shapes (lines, trapezoids, sigmoids) 8 CSCE 420 Introduction to AI
Membership Functions CLOSE FAR Degree of membership 1 0 0 3 10 Crisp domain: PROXIMITY Distance from robot If robot is 3 meters from obstacle, it has a membership in CLOSE of 0.7 and a membership in FAR of 0.3 M CLOSE (3)=0.7 M FAR (3)=0.3 9 CSCE 420 Introduction to AI
Back to Swerve • Perceptual schema is a tuple – membership function for the fuzzy variable PROXIMITY • M CLOSE (x), M FAR (X) PROXIMITY PS MS 10 CSCE 420 Introduction to AI
Fuzzy Rules Motor Schema might be expressed as rule(s): If PROXIMITY is CLOSE Fuzzy rule TURN is HARD_RIGHT If PROXIMITY is FAR Fuzzy rule TURN is SOFT_RIGHT 11 CSCE 420 Introduction to AI
Fuzzy Output Variable Degree of membership SOFT_RIGHT HARD_RIGHT 1 0 0 90 Crisp domain: TURN Distance for robot to turn to the right 12 CSCE 420 Introduction to AI
Strength Motor Schema might be expressed as rule(s): M CLOSE (3)=0.7 If PROXIMITY is CLOSE M HARD_RIGHT =0.7 TURN is HARD_RIGHT M FAR (3)=0.3 If PROXIMITY is FAR M SOFT_RIGHT =0.3 TURN is SOFT_RIGHT 13 CSCE 420 Introduction to AI
Resulting Membership Degree of membership SOFT_RIGHT HARD_RIGHT 1 0 0 90 Crisp domain: TURN Distance for robot to turn to the right M SOFT_RIGHT =0.3 14 CSCE 420 Introduction to AI
Resulting Membership Degree of membership SOFT_RIGHT HARD_RIGHT 1 0 0 90 Crisp domain: TURN Distance for robot to turn to the right M SOFT_RIGHT =0.3 M HARD_RIGHT =0.7 15 CSCE 420 Introduction to AI
Defuzzification • Now we have an output that is a fuzzy variable, but we need to convert it to a crisp value to actually send the motor commands. • Several alternatives: – Take Centroid (along Crisp axis) of Blended Area – Take Centroid of Largest Area – Weighted Means in area of overlap 16 CSCE 420 Introduction to AI
Defuzzification: Blended Centroid Degree of membership SOFT_RIGHT HARD_RIGHT 1 0 0 90 Crisp domain: TURN Distance for robot to turn to the right ∫ M A ( X ) X C ≈ 174.6 C = 3.2 = 54.6 ∫ M A ( X ) 17 CSCE 420 Introduction to AI
There can be some problems… Consider the output of an avoid… 1 0 -90 0 90 And where would the centroid be? Consider Centroid of Largest Area (CLA) 18 CSCE 420 Introduction to AI
Defuzzification: Largest Centroid Degree of membership SOFT_RIGHT HARD_RIGHT 1 0 0 90 Crisp domain: TURN Distance for robot to turn to the right ∫ M A ( X ) X C = C ≈ 61.7 ∫ M A ( X ) 19 CSCE 420 Introduction to AI
Defuzzification: Weighted Means Degree of membership SOFT_RIGHT HARD_RIGHT 1 0.7 0.3 0 0 90 18 72 Crisp domain: TURN Distance for robot to turn to the right C = 0.3(18) + 0.7(72) = 55.8 20 CSCE 420 Introduction to AI
Back to Swerve • And so we get an answer! PROXIMITY SOFT_RIGHT=0.3 Dist=3m V dir =54.6 PS MS V magr =1 HARD_RIGHT=0.7 21 CSCE 420 Introduction to AI
Back to Swerve • And so we get an answer! Fuzzify Apply Rules Defuzzify PROXIMITY SOFT_RIGHT=0.3 Dist=3m V dir =54.6 PS MS V magr =1 HARD_RIGHT=0.7 22 CSCE 420 Introduction to AI
Conjunction, Disjunction, Negation and Hedges If PROXIMITY is CLOSE AND OPEN is RIGHTSIDE TURN is HARD_RIGHT If PROXIMITY is CLOSE AND OPEN is LEFTSIDE TURN is HARD_LEFT If PROXIMITY is FAR AND OPEN is RIGHTSIDE TURN is SOFT_RIGHT If PROXIMITY is FAR AND OPEN is LEFTSIDE TURN is SOFT_LEFT If PROXIMITY is CLOSE AND NOT (OPEN is RIGHTSIDE OR OPEN is LEFTSIDE) TURN is VERY HARD_RIGHT 23 CSCE 420 Introduction to AI
Evaluation • A AND B is minimum(A, B) – PROXIMITY is CLOSE= 0.7 – OPEN IS RIGHTSIDE= 0.3 – If PROXIMITY is CLOSE AND OPEN is RIGHTSIDE= 0.3 • A OR B is maximum(A, B) – PROXIMITY is CLOSE= 0.7 – OPEN IS RIGHTSIDE= 0.3 – If PROXIMITY is CLOSE OR OPEN is RIGHTSIDE= 0.7 • NOT A is 1-A – OPEN is RIGHTSIDE=0.2 – NOT OPEN is RIGHTSIDE=1-0.2=0.8 (1.0 is full membership for our examples) 24 CSCE 420 Introduction to AI
Example If PROXIMITY is CLOSE AND NOT (OPEN is RIGHTSIDE OR OPEN is LEFTSIDE) Where OPEN is RIGHTSIDE=0.1 OPEN is LEFTSIDE=0.15 PROXIMITY is CLOSE=0.95 25 CSCE 420 Introduction to AI
Hedges If PROXIMITY is CLOSE AND NOT (OPEN is RIGHTSIDE OR OPEN is LEFTSIDE) TURN is VERY HARD_RIGHT HARD_RIGHT OPEN is RIGHTSIDE=0.1 1 OPEN is LEFTSIDE=0.15 PROXIMITY is CLOSE=0.95 0 Moves the fuzzy set over 26 CSCE 420 Introduction to AI
Summary • Many packages have fuzzy logic: Java, MATLAB • Fuzzy works by – Fuzzification of crisp values – Application of rules, each of which has a strength – Defuzzification output of rules to produce a crisp output • Problems include – Results may not be what was expected – The number and shape of sets impact behavior 27 CSCE 420 Introduction to AI
Recommend
More recommend