Heuristic Search Rob Platt Northeastern University Some images and - - PowerPoint PPT Presentation

heuristic search
SMART_READER_LITE
LIVE PREVIEW

Heuristic Search Rob Platt Northeastern University Some images and - - PowerPoint PPT Presentation

Heuristic Search Rob Platt Northeastern University Some images and slides are used from: AIMA Recap: What is graph search? Start state Goal state Graph search: find a path from start to goal what are the states? what are the


slide-1
SLIDE 1

Heuristic Search

Rob Platt Northeastern University Some images and slides are used from: AIMA

slide-2
SLIDE 2

Recap: What is graph search?

Graph search: find a path from start to goal – what are the states? – what are the actions (transitions)? – how is this a graph? Start state Goal state

slide-3
SLIDE 3

Recap: What is graph search?

Graph search: find a path from start to goal – what are the states? – what are the actions (transitions)? – how is this a graph? Start state Goal state

slide-4
SLIDE 4

Recap: BFS/UCS

start goal

It's like this – search in all directions equally until discovering goal

slide-5
SLIDE 5

Idea

Is it possible to use additional information to decide which direction to search in?

slide-6
SLIDE 6

Idea

Is it possible to use additional information to decide which direction to search in?

Yes!

Instead of searching in all directions, let's bias search in the direction of the goal.

slide-7
SLIDE 7

Example

Stright-line distances to Bucharest

slide-8
SLIDE 8

Example

Start state Goal state

Expand states in order of their distance to the goal – for each state that you put on the fringe: calculate straight-line distance to the goal – expand the state on the fringe closest to the goal

slide-9
SLIDE 9

Example

Start state Goal state

Expand states in order of their distance to the goal – for each state that you put on the fringe: calculate straight-line distance to the goal – expand the state on the fringe closest to the goal

Heuristic: Greedy search

slide-10
SLIDE 10

Greedy Search

slide-11
SLIDE 11

Greedy Search

Each time you expand a state, calculate the heuristic for each of the states that you add to the fringe. – heuristic: – on each step, choose to expand the state with the lowest heuristic value. i.e. distance to Bucharest

slide-12
SLIDE 12

Greedy Search

Each time you expand a state, calculate the heuristic for each of the states that you add to the fringe. – heuristic: – on each step, choose to expand the state with the lowest heuristic value. i.e. distance to Bucharest

This is like a guess about how far the state is from the goal

slide-13
SLIDE 13

Example: Greedy Search

slide-14
SLIDE 14

Example: Greedy Search

slide-15
SLIDE 15

Example: Greedy Search

slide-16
SLIDE 16

Example: Greedy Search

Path: A-S-F-B

slide-17
SLIDE 17

Example: Greedy Search

Notice that this is not the optimal path! Path: A-S-F-B

slide-18
SLIDE 18

Example: Greedy Search

Notice that this is not the optimal path! Path: A-S-F-B

Greedy Search: – Not optimal – Not complete – But, it can be very fast

slide-19
SLIDE 19

Greedy vs UCS

Greedy Search: – Not optimal – Not complete – But, it can be very fast UCS: – Optimal – Complete – Usually very slow

slide-20
SLIDE 20

Greedy vs UCS

Greedy Search: – Not optimal – Not complete – But, it can be very fast UCS: – Optimal – Complete – Usually very slow Can we combine greedy and UCS???

slide-21
SLIDE 21

Greedy vs UCS

Greedy Search: – Not optimal – Not complete – But, it can be very fast UCS: – Optimal – Complete – Usually very slow Can we combine greedy and UCS??? YES: A*

slide-22
SLIDE 22

A*

slide-23
SLIDE 23

A*

: a state : minimum cost from start to : heuristic at (i.e. an estimate of remaining cost-to-go) UCS: expand states in order of Greedy: expand states in order of A*: expand states in order of

slide-24
SLIDE 24

A*

: a state : minimum cost from start to : heuristic at (i.e. an estimate of remaining cost-to-go) UCS: expand states in order of Greedy: expand states in order of A*: expand states in order of

What is “cost-to-go”?

slide-25
SLIDE 25

A*

: a state : minimum cost from start to : heuristic at (i.e. an estimate of remaining cost-to-go) UCS: expand states in order of Greedy: expand states in order of A*: expand states in order of

What is “cost-to-go”? – minimum cost required to reach a goal state

slide-26
SLIDE 26

A*

h=0 S a d b G h=5 h=6 h=2 1 8 1 1 2 h=6 c h=7 3 e h=1 1

  • Uniform-cost orders by path cost from Start:

g(n)

  • Greedy orders by estimated cost to goal: h(n)
  • A* orders by the sum: f(n) = g(n) + h(n)

Modifjed from: T eg Grenager

slide-27
SLIDE 27

When should A* terminate?

Slide: Adapted from Berkeley CS188 course notes (downloaded Summer 2015)

S B A G 2 3 2 2

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

Should we stop when we enqueue a goal? No: only stop when we dequeue a goal

slide-28
SLIDE 28

Is A* optimal?

A G S 1 3

h = 6 h = 0

5

h = 7

Image: Adapted from Berkeley CS188 course notes (downloaded Summer 2015)

What went wrong here?

slide-29
SLIDE 29

When is A* optimal?

It depends on whether we are using the tree search

  • r the graph search version of the algorithm.

Recall: – in tree search, we do not track the explored set – in graph search, we do

slide-30
SLIDE 30

Recall: Breadth first search (BFS)

What is the purpose of the explored set?

slide-31
SLIDE 31

When is A* optimal?

It depends on whether we are using the tree search

  • r the graph search version of the algorithm.

Optimal if h is admissible Optimal if h is consistent

slide-32
SLIDE 32

When is A* optimal?

It depends on whether we are using the tree search

  • r the graph search version of the algorithm.

Optimal if h is admissible – h(s) is an underestimate

  • f the true cost-to-go.

Optimal if h is consistent – h(s) is an underestimate

  • f the cost of each arc.
slide-33
SLIDE 33

When is A* optimal?

It depends on whether we are using the tree search

  • r the graph search version of the algorithm.

Optimal if h is admissible – h(s) is an underestimate

  • f the true cost-to-go.

Optimal if h is consistent – h(s) is an underestimate

  • f the cost of each arc.

What is “cost-to-go”? – minimum cost required to reach a goal state

slide-34
SLIDE 34

When is A* optimal?

It depends on whether we are using the tree search

  • r the graph search version of the algorithm.

Optimal if h is admissible – h(s) is an underestimate

  • f the true cost-to-go.

Optimal if h is consistent – h(s) is an underestimate

  • f the cost of each arc.

More on this later...

slide-35
SLIDE 35

Admissibility: Example

Stright-line distances to Bucharest

h(s) = straight-line distance to goal state (Bucharest)

slide-36
SLIDE 36

Admissibility

Stright-line distances to Bucharest

h(s) = straight-line distance to goal state (Bucharest) Is this heuristic admissible???

slide-37
SLIDE 37

Admissibility

Stright-line distances to Bucharest

h(s) = straight-line distance to goal state (Bucharest) Is this heuristic admissible??? YES! Why?

slide-38
SLIDE 38

Admissibility: Example

h(s) = ?

Start state Goal state

Can you think of an admissible heuristic for this problem?

slide-39
SLIDE 39

Admissibility

Why isn't this heuristic admissible?

A G S 1 3

h = 6 h = 0

5

h = 7

Image: Adapted from Berkeley CS188 course notes (downloaded Summer 2015)

slide-40
SLIDE 40

Consistency

What went wrong?

Slide: Adapted from Berkeley CS188 course notes (downloaded Summer 2015)

S A B C G

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

S (0+2) A (1+4) B (1+1) C (2+1) G (5+0) C (3+1) G (6+0)

State space graph Search tree

slide-41
SLIDE 41

Consistency

Cost of going from s to s'

s s'

slide-42
SLIDE 42

Consistency

Rearrange terms

slide-43
SLIDE 43

Consistency

Cost of going from s to s' implied by heuristic Actual cost of going from s to s'

slide-44
SLIDE 44

Consistency

Cost of going from s to s' implied by heuristic Actual cost of going from s to s'

slide-45
SLIDE 45

Consistency

Consistency implies that the “f-cost” never decreases along any path to a goal state. – the optimal path gives a goal state its lowest f-cost. A* expands states in order of their f-cost. Given any goal state, A* expands states that reach the goal state optimally before expanding states the reach the goal state suboptimally.

slide-46
SLIDE 46

Consistency implies admissibility

Suppose: Then:

slide-47
SLIDE 47

Consistency implies admissibility

Suppose: Then:

slide-48
SLIDE 48

Consistency implies admissibility

Suppose: Then: admissible

slide-49
SLIDE 49

Consistency implies admissibility

Suppose: Then:

slide-50
SLIDE 50

Consistency implies admissibility

Suppose: Then: admissible

slide-51
SLIDE 51

Consistency implies admissibility

Suppose: Then: admissible admissible

slide-52
SLIDE 52

Consistency implies admissibility

Suppose: Then:

slide-53
SLIDE 53

A* vs UCS

Greedy UCS A* start goal goal start start goal

slide-54
SLIDE 54

Choosing a heuristic

The right heuristic is often problem-specific. But it is very important to select a good heuristic!

slide-55
SLIDE 55

Choosing a heuristic

How much better is ?

Consider the 8-puzzle: : number of misplaced tiles : sum of manhattan distances between each tile and its goal.

slide-56
SLIDE 56

Choosing a heuristic

Consider the 8-puzzle: : number of misplaced tiles : sum of manhattan distances between each tile and its goal. Average # states expanded on a random depth-24 puzzle:

(by depth 12)

slide-57
SLIDE 57

Choosing a heuristic

Consider the 8-puzzle: : number of misplaced tiles : sum of manhattan distances between each tile and its goal. Average # states expanded on a random depth-24 puzzle:

(by depth 12)

So, getting the heuristic right can speed things up by multiple orders of magnitude!

slide-58
SLIDE 58

Choosing a heuristic

Consider the 8-puzzle: : number of misplaced tiles : sum of manhattan distances between each tile and its goal. Why not use the actual cost to goal as a heuristic?

slide-59
SLIDE 59

How to choose a heuristic?

Nobody has an answer that always works. A couple of best-practices: – solve a relaxed version of the problem – solve a subproblem