Out line Using knowledge Heurist ics I nf ormed Search Best -f - - PDF document

out line
SMART_READER_LITE
LIVE PREVIEW

Out line Using knowledge Heurist ics I nf ormed Search Best -f - - PDF document

Out line Using knowledge Heurist ics I nf ormed Search Best -f irst search Greedy best -f irst search A* search CS 486/ 686 Ot her variat ions of A* Univer sit y of Wat erloo Back t o heurist ics May 10 1


slide-1
SLIDE 1

1

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

1

I nf ormed Search

CS 486/ 686 Univer sit y of Wat erloo May 10

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

2

Out line

  • Using knowledge

– Heurist ics

  • Best -f irst search

– Greedy best -f irst search – A* search – Ot her variat ions of A*

  • Back t o heurist ics

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

3

Recall f rom last lect ure

  • Uninf ormed search met hods expand nodes

based on “dist ance” f rom st art node

– Never look ahead t o t he goal – E.g. in unif orm cost search expand t he cheapest pat h. We never consider t he cost of get t ing t o t he goal – Advant age is t hat we have t his inf ormat ion

  • But , we of t en have some addit ional knowledge

about t he problem

– E.g. in t raveling around Romania we know t he dist ances bet ween cit ies so can measure t he

  • verhead of going in t he wrong direct ion

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

4

I nf ormed Search

  • Our knowledge is of t en on t he merit of nodes

– Value of being at a node

  • Dif f erent not ions of merit

– I f we are concerned about t he cost of t he solut ion, we might want a not ion of how expensive it is t o get f rom a st at e t o a goal – I f we are concerned wit h minimizing comput at ion, we might want a not ion of how easy it is t o get a st at e t o a goal – We will f ocus on cost of solut ion

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

5

I nf ormed search

  • We need t o develop a domain specif ic

heurist ic f unct ion, h(n)

  • h(n) guesses t he cost of reaching t he

goal f rom node n

– The heur ist ic f unct ion must be domain specif ic – We of t en have some inf ormat ion about t he problem t hat can be used in f or ming a heurist ic f unct ion (i.e. heur ist ics are domain specif ic)

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

6

I nf ormed search

  • I f h(n1)<

h(n2) t hen we guess t hat it is cheaper t o reach t he goal f rom n1 t han it is f rom n2

  • We require

– h(n)=0 when n is a goal node – h(n)> = 0 f or all ot her nodes

slide-2
SLIDE 2

2

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

7

Greedy best -f irst search

  • Use t he heur ist ic f unct ion, h(n), t o rank

t he nodes in t he f ringe

  • Search st r at egy

– Expand node wit h lowest h-value

  • Greedily t rying t o f ind t he least -cost

solut ion

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

8

Gr eedy best -f ir st sear ch: Example

S C B A G

2 1 1 2 4 h=4 h=3 h=2 h=1 h=0 P at h cost Heur ist ic f unct ion

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

9

Example cont …

S C B A G

2 1 1 2 4 h=4 h=3 h=2 h=1 h=0

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

10

Example cont …

S C B A G

2 1 1 2 4 h=4 h=3 h=2 h=1 h=0

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

11

Example cont …

S C B A G

2 1 1 2 4 h=4 h=3 h=2 h=1 h=0

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

12

Example cont …

S C B A G

2 1 1 2 4 h=4 h=3 h=2 h=1 h=0

slide-3
SLIDE 3

3

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

13

Example cont …

S C B A G

2 1 1 2 4 h=4 h=3 h=2 h=1 h=0

Found t he goal Pat h is S, A, C, G Cost of t he pat h is 2+4+2=8 But cheaper pat h is S, A, B, C, G Wit h cost 2+1+1+2=6

Greedy best-first is not optimal

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

14

Anot her Example

C G

2

S B A

2 1 h=4 h=3 h=4 h=1 h=0 1 1

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

15

Anot her Example

C G

2

S B A

2 1 h=4 h=3 h=4 h=1 h=0 1 1

Greedy best -f irst can get st uck in loops Not complet e

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

16

Propert ies of greedy search

  • Not opt imal!
  • Not complet e!

– I f we check f or repeat ed st at es t hen we are ok

  • Exponent ial space in worst case since need t o

keep all nodes in memory

  • Exponent ial worst case t ime O(bm) where m is

t he maximum dept h of t he t ree

– I f we choose a good heurist ic t hen we can do much bet t er

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

17

A* Search

  • Greedy best -f ir st search is t oo greedy

– I t does not t ake int o account t he cost of t he pat h so f ar!

  • Def ine

– f (n)=g(n)+h(n) – g(n) is t he cost of t he pat h t o node n – h(n) is t he heurist ic est imat e of t he cost of reaching t he goal f rom node n

  • A* search

– Expand node in f r inge (queue) wit h lowest f value

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

18

A* Example

S C B A G

2 1 1 2 4 h=4 h=3 h=2 h=1 h=0

  • 1. Expand S
  • 2. Expand A
  • 3. Choose bet ween B (f (B)=3+2=5) and C (f (C)=6+1=7) ) expand B
  • 4. Expand C
  • 5. Expand G – recognize it is t he goal
slide-4
SLIDE 4

4

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

19

When should A* t erminat e?

  • As soon as we f ind a goal st at e?

S A B C G

h=2 h=3 h=7 1 1 1 7

D

h=1 7 1

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

20

When should A* t erminat e?

  • As soon as we f ind a goal st at e?

S A B C G

h=2 h=3 h=7 1 1 1 7

D

h=1 7 1

A* Terminat es only when goal st at e is popped f rom t he queue

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

21

A* and revisit ing st at es

What if we revisit a st at e t hat was already expanded?

S A B C G 1 h=3 h=2 h=7 1 1 7 2

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

22

A* and revisit ing st at es

What if we revisit a st at e t hat was already expanded?

S A B C G 1 h=3 h=2 h=7 1 1 7 2

I f we allow st at es t o be expanded again, we might get a bet t er solut ion!

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

23

I s A* Opt imal?

S A G 1 1 3 h=6

  • No. This example shows why not .

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

24

Admissible heurist ics

  • Let h*(n) denot e t he t rue minimal cost

t o t he goal f rom node n

  • A heurist ic, h, is admissible if

– h(n) ≤ h*(n) f or all n

  • Admissible heurist ics never
  • verest imat e t he cost t o t he goal

– Opt imist ic

slide-5
SLIDE 5

5

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

25

Opt imalit y of A*

  • I f t he heurist ic is admissible t hen A* wit h

t ree-search is opt imal

Let G be an opt imal goal st at e, and f (G) = f * = g(G). Let G

2 be a subopt imal goal st at e, i.e. f (G 2) = g(G 2) >

f *. Assume f or cont radict ion t hat A* has select ed G

2 f rom t he queue.

(This would t erminat e A* wit h a subopt imal solut ion) Let n be a node t hat is current ly a leaf node on an opt imal pat h t o G. Because h is admissible, f * ≥ f (n). I f n is not chosen f or expansion over G

2, we must have f (n) ≥ f (G 2)

So, f * ≥ f (G

2). Because h(G 2)=0, we have f * ≥ g(G 2), cont radict ion.

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

26

Opt imalit y of A*

  • For searching graphs we require

somet hing st ronger t han admissibilit y

– Consist ency (monot onicit y):

  • h(n) ≤ cost (n,n’)+h(n’)

– Almost any admissible heurist ic f unct ion will also be consist ent

  • A* graph-search wit h a consist ent

heurist ic is opt imal

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

27

Propert ies of A*

  • Complet e if t he heurist ic is consist ent

– Along any pat h, f always increases ) if a solut ion exist s somewhere t he f value will event ually get t o it s cost

  • Exponent ial t ime complexit y in wor st case

– A good heurist ic will help a lot here – O(bm) if t he heurist ic is per f ect

  • Exponent ial space complexit y

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

28

Memor y-bounded heur ist ic search

  • A* keeps most generat ed nodes in memory

– On many problems A* will run out of memory

  • I t erat ive deepening A* (I DA*)

– Like I DS but change f -cost rat her t han dept h at each it erat ion

  • SMA* (Simplif ied Memory-Bounded A*)

– Uses all available memory – Proceeds like A* but when it runs out of memory it drops t he worst leaf node (one wit h highest f - value) – I f all leaf nodes have t he same f -value t hen it drops oldest and expands t he newest – Opt imal and complet e if dept h of shallowest goal node is less t han memory size

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

29

Heurist ic Funct ions

  • A good heurist ic f unct ion can make all

t he dif f er ence!

  • How do we get heurist ics?

– One appr oach is t o t hink of an easier problem and let h(n) be t he cost of reaching t he goal in t he easier problem

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

30

8-puzzle

  • Relax t he game
  • 1. Can move t ile f rom posit ion A t o posit ion B if A is

next t o B (ignore whet her or not posit ion is blank)

  • 2. Can move t ile f rom posit ion A t o posit ion B if B is

blank (ignore adj acency)

  • 3. Can move t ile f rom posit ion A t o posit ion B

2

Start State Goal State

1 3 4 6 7 5 1 2 3 4 6 7 8 5 8

slide-6
SLIDE 6

6

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

31

8-puzzle cont …

  • 3 leads t o misplaced t ile heurist ic

– To solve t his problem need t o move each t ile int o it s f inal posit ion – Number of moves = number of misplaced t iles – Admissible

  • 1 leads t o manhat t an dist ance heurist ic

– To solve t he puzzle need t o slide each t ile int o it s f inal posit ion – Admissible

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

32

8-puzzle cont …

  • h1=misplaced t iles
  • h2=manhat t an dist ance
  • Not e h2 dominat es h1

– h1(n) ≤ h2(n) f or all n – Which heur ist ic is best ?

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

33

Designing heurist ics

  • Relaxing t he problem (as j ust

illust r at ed)

  • Precomput ing solut ion cost s of

subproblems and st oring t hem in a pat t ern dat abase

  • Learning f rom experience wit h t he

problem class

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

34

Conclusion

  • What you should now know

– Thor oughly under st and A* and I DA* – Be able t o t race simple examples of A* and I DA* execut ion – Underst and admissibilit y of heurist ics – Proof of complet eness, opt imalit y – Crit icize greedy best -f irst search

cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

35

Next class

  • Local search

– Russell and Norvig Sect ions 4.3-4.5