Fuzzy Logic Todays class: No notes, but the following are useful - - PowerPoint PPT Presentation

fuzzy logic
SMART_READER_LITE
LIVE PREVIEW

Fuzzy Logic Todays class: No notes, but the following are useful - - PowerPoint PPT Presentation

Fuzzy Logic Todays 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


slide-1
SLIDE 1

CSCE 420-500 Introduction to AI Fuzzy Logic 1

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

slide-2
SLIDE 2

Lofti Zadeh

CSCE 420 Introduction to AI 2

slide-3
SLIDE 3

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?

CSCE 420 Introduction to AI 3

slide-4
SLIDE 4

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

CSCE 420 Introduction to AI 4

slide-5
SLIDE 5

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)

CSCE 420 Introduction to AI 5

slide-6
SLIDE 6

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

CSCE 420 Introduction to AI 6

slide-7
SLIDE 7

Fuzzy Sets: Domain

CSCE 420 Introduction to AI 7

1 10

Crisp domain: PROXIMITY Distance from robot

Degree of membership CLOSE CLOSE is a fuzzy set over the domain

slide-8
SLIDE 8

Fuzzy Sets: Multiple Sets

CSCE 420 Introduction to AI 8

1 10

Crisp domain: PROXIMITY Distance from robot

CLOSE Notes:

  • Fuzzy sets often overlap -- that’s seen as a Good Thing
  • Set can have different shapes (lines, trapezoids, sigmoids)

FAR Degree of membership

slide-9
SLIDE 9

Membership Functions

CSCE 420 Introduction to AI 9

1 10

Crisp domain: PROXIMITY Distance from robot

CLOSE

If robot is 3 meters from obstacle, it has a membership in CLOSE of 0.7 and a membership in FAR of 0.3

MCLOSE(3)=0.7 MFAR(3)=0.3 FAR 3 Degree of membership

slide-10
SLIDE 10

Back to Swerve

CSCE 420 Introduction to AI 10

  • Perceptual schema is a tuple

– membership function for the fuzzy variable PROXIMITY

  • MCLOSE(x), MFAR(X)

PS MS

PROXIMITY

slide-11
SLIDE 11

Fuzzy Rules

CSCE 420 Introduction to AI 11

Motor Schema might be expressed as rule(s): If PROXIMITY is CLOSE TURN is HARD_RIGHT Fuzzy rule If PROXIMITY is FAR TURN is SOFT_RIGHT Fuzzy rule

slide-12
SLIDE 12

Fuzzy Output Variable

CSCE 420 Introduction to AI 12

1 90

Crisp domain: TURN Distance for robot to turn to the right

Degree of membership

SOFT_RIGHT HARD_RIGHT

slide-13
SLIDE 13

Strength

CSCE 420 Introduction to AI 13

Motor Schema might be expressed as rule(s): If PROXIMITY is CLOSE TURN is HARD_RIGHT If PROXIMITY is FAR TURN is SOFT_RIGHT

MCLOSE(3)=0.7 MFAR(3)=0.3 MHARD_RIGHT=0.7 MSOFT_RIGHT=0.3

slide-14
SLIDE 14

Resulting Membership

CSCE 420 Introduction to AI 14

1 90

Crisp domain: TURN Distance for robot to turn to the right

Degree of membership

SOFT_RIGHT HARD_RIGHT

MSOFT_RIGHT=0.3

slide-15
SLIDE 15

Resulting Membership

CSCE 420 Introduction to AI 15

1 90

Crisp domain: TURN Distance for robot to turn to the right

Degree of membership

SOFT_RIGHT HARD_RIGHT

MSOFT_RIGHT=0.3 MHARD_RIGHT=0.7

slide-16
SLIDE 16

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

CSCE 420 Introduction to AI 16

slide-17
SLIDE 17

Defuzzification: Blended Centroid

CSCE 420 Introduction to AI 17

1 90

Crisp domain: TURN Distance for robot to turn to the right

Degree of membership

SOFT_RIGHT HARD_RIGHT C = MA(X)X

MA(X)

C ≈ 174.6 3.2 = 54.6

slide-18
SLIDE 18

There can be some problems…

CSCE 420 Introduction to AI 18

1

  • 90

90 And where would the centroid be? Consider Centroid of Largest Area (CLA) Consider the output of an avoid…

slide-19
SLIDE 19

Defuzzification: Largest Centroid

CSCE 420 Introduction to AI 19

1 90

Crisp domain: TURN Distance for robot to turn to the right

Degree of membership

SOFT_RIGHT HARD_RIGHT C = MA(X)X

MA(X)

C ≈ 61.7

slide-20
SLIDE 20

Defuzzification: Weighted Means

CSCE 420 Introduction to AI 20

1 90

Crisp domain: TURN Distance for robot to turn to the right

Degree of membership

SOFT_RIGHT HARD_RIGHT

C = 0.3(18) + 0.7(72) = 55.8

18 72 0.3 0.7

slide-21
SLIDE 21

Back to Swerve

CSCE 420 Introduction to AI 21

  • And so we get an answer!

PS MS

PROXIMITY

Vdir=54.6 Vmagr=1 Dist=3m SOFT_RIGHT=0.3 HARD_RIGHT=0.7

slide-22
SLIDE 22

Back to Swerve

CSCE 420 Introduction to AI 22

  • And so we get an answer!

PS MS

PROXIMITY

Vdir=54.6 Vmagr=1 Dist=3m SOFT_RIGHT=0.3 HARD_RIGHT=0.7 Fuzzify Apply Rules Defuzzify

slide-23
SLIDE 23

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

CSCE 420 Introduction to AI 23

slide-24
SLIDE 24

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)

CSCE 420 Introduction to AI 24

slide-25
SLIDE 25

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

CSCE 420 Introduction to AI 25

slide-26
SLIDE 26

Hedges

CSCE 420 Introduction to AI 26

If PROXIMITY is CLOSE AND NOT (OPEN is RIGHTSIDE OR OPEN is LEFTSIDE) TURN is VERY HARD_RIGHT OPEN is RIGHTSIDE=0.1 OPEN is LEFTSIDE=0.15 PROXIMITY is CLOSE=0.95 Moves the fuzzy set over

1 HARD_RIGHT

slide-27
SLIDE 27

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

CSCE 420 Introduction to AI 27