Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First....

121
Informed Search Brian C. Williams 16.410-13 September 23 rd , 2015 Slides adapted from: 6.034 Tomas Lozano Perez, Winston, David Hsu, and Russell and Norvig AIMA

Transcript of Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First....

Page 1: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Informed Search

Brian C. Williams 16.410-13 September 23rd, 2015

Slides adapted from: 6.034 Tomas Lozano Perez, Winston, David Hsu, and Russell and Norvig AIMA

Page 2: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Assignment •  Remember:

–  PS #2, due Today at midnight, Wednesday, September 23rd, 2015. –  Problem Set #3, out Today, due Wednesday, September 30th, 2015. – 

•  Reading: –  Today: Informed search and exploration: AIMA Ch. 4.1-2, Ch. 25.4.

Computing Shortest Paths: Cormen, Leiserson & Rivest, (opt.) “Introduction to Algorithms” Ch. 25.1-.2.

–  Wed: Activity Planning: [AIMA] Ch.10 & 11.

Brian Williams, Fall 15 9/23/15

2

Page 3: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Motion planning

E. Frazzoli (MIT) L15: Sampling-Based Motion Planning November 3, 2010 20 / 36

9/23/15 Brian Williams, Fall 15

3

Page 4: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Motion planning

9/23/15

Brian Williams, Fall 15

4

Page 5: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Review: Roadmaps are an effective state space abstraction

Brian Williams, Fall 15 9/23/15

5

Page 6: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Constructing Road Maps

Start

Goal

Configuration Spaces And Visibility Graphs

6

S

G

G’

Cell Decompositions

G S

Probabilistic Road Maps

9/23/15 Brian Williams, Fall 15

6

Page 7: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Finding A Shortest Path

Input: <gr, w, S, G>, where •  gr is a (directed) graph <V,E> with •  weight function w: VxV è R, •  S ∈ V is the Start and G ∈ V is the Goal.

8 9

u G1

5 7

x y2

0

10

57

92 3 4 6S

9/23/15

7

Page 8: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Finding A Shortest Path

Input: <gr, w, S, G>, where •  gr is a (directed) graph <V,E> with •  weight function w: VxV è R, •  S ∈ V is the Start and G ∈ V is the Goal.

Output: A simple path P = <v1, v2 …vn> from S to G,

with the shortest path weight g = δ(S,G), and its corresponding weight.

8 9

u G1

5 7

x y2

0

10

57

92 3 4 6S

9/23/15

8

Page 9: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D 2

5

4

2 3

2

5 1

8 S

D

B A

C G

C G

D

C G

2 5

6 4

9 9 8

6 10

8

0

to include path length g

2

6 g = 0

path length

Optimal Search

Problem: Find the path to the goal G with the shortest path length g.

Augment search tree nodes

9/23/15

edge cost

9

Page 10: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

goal start A* biases uniform co

towards the goal

A B

x x

spreads evenly from the start

st

Uniform cost search Informed Search

9/23/15 Brian Williams, Fall 15

10

asin33
Oval
Page 11: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Classes of Search Blind Depth-First Systematic exploration of whole tree

(uninformed) Breadth-First until the goal is found.

Iterative-Deepening

Variants Hill-Climbing (w backup)

Beam

IDA*

Best-first Uniform-cost Uses path “length” measure to

(informed) Greedy find “shortest” path.

A*

Bounding Branch and Bound Prunes suboptimal branches.

Alpha/Beta Prunes options that the adversary rules out.

9/23/15

11

asin33
Rectangle
Page 12: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Classes of Search Blind Depth-First Systematic exploration of whole tree

(uninformed) Breadth-First until the goal is found.

Iterative-Deepening

Best-first Uniform-cost Uses path “length” measure to

Greedy find “shortest” path.

A*

Brian Williams, Fall 15 9/23/15

12

Page 13: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

A B

x x

goal start

Uniform cost search spreads evenly from

g = 6 the start g = 4

g = 2

Does uniform cost search find the shortest path? Yes, Optimal

9/23/15

13

Page 14: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D 2

5

4

2 3

2

5 1

ge cost

S 0

Uniform Cost ed

Enumerates partial paths in order of increasing path length g.

path length

9/23/15

14

Page 15: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D

dge cost 2

3 2

2 4 5 1

5

S

B A 2 5

0

Uniform Cost epath length

Enumerates partial paths in order of increasing path length g.

9/23/15

15

Page 16: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D 2

5

4

2 3

2

5 1

ge cost

S

D

B A

C

2 5

6 4

0

Uniform Cost edpath length

Enumerates partial paths in order of increasing path length g.

9/23/15

16

Page 17: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D 2

5

4

2 3

2

5 1

S

D

B A

C

2 5

6 4

0

Uniform Cost edge cost path length

Enumerates partial paths in order of increasing path length g.

9/23/15

17

Page 18: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D

ge cost 2

3 2

2 4 5 1

5

S

D

B A

C G D

2 5

6 4 6 10

0

Uniform Cost edpath length

Enumerates partial paths in order of increasing path length g.

9/23/15

18

Page 19: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D 2

5

4

2 3

2

5 1

ge cost

S

D

B A

C G

C G

D

2 5

6 4

9 8

6 10

0

Uniform Cost edpath length

Enumerates partial paths in order of increasing path length g. Better path visited later.

9/23/15

19

Page 20: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D 2

5

4

2 3

2

5 1

dge cost

S

D

B A

C G

C G

D

C G

2 5

6 4

9 9 8

6 10

8

0

Uniform Cost epath length

Expands nodes already visited.

Enumerates partial paths in order of increasing path length g.

May expand vertex more than once.

Better path visited later.

9/23/15

20

Page 21: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D

ge cost 2

3 2

2 4 5 1

5

S

D

B A

C G

C G

D

C G

2 5

6 4

9 9 8

6 10

8

0 path length

Uniform Cost ed

Expands nodes already visited.

Enumerates partial paths in order of increasing path length g.

May expand vertex more than once.

Better path visited later.

9/23/15

21

Page 22: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D 2

5

4

2 3

2

5 1

ge cost

S

D

B A

C G

C G

D

C G

2 5

6 4

9 9 8

6 10

8

0

Uniform Cost edpath length

Expands nodes already visited.

Enumerates partial paths in order of increasing path length g.

May expand vertex more than once.

Best path expanded first.

9/23/15

22

Page 23: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

S

D A 2 4

0

Why Expand a Vertex More Than Once?

path length

S

A

D 2 1

4 G

1

•  The shortest path from S to G is (G D A S).

edge cost

•  D is reached first using path (D S).

Suppose we expand only the first path that visits each vertex X?

9/23/15

23

Page 24: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

S

D A 2 5

D 3

0

Why Expand a Vertex More Than Once?

path length

S

A

D 2 1

4 G

1

•  The shortest path from S to G is (G D A S).

edge cost

•  D is reached first using path (D S).

•  This prevents path (D A S) from being expanded. Suppose we expand only the

first path that visits each vertex X?

9/23/15

24

Page 25: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

S

D

D A 2 4

3

0

5 G

Why Expand a Vertex More Than Once?

path length

S

A

D 2 1

4 G

1

•  The shortest path from S to G is (G D A S).

edge cost

•  D is reached first using path (D S).

•  This prevents path (D A S) from being expanded. Suppose we expand only the

first path that visits each vertex X?

9/23/15

25

Page 26: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

S

D

D A 2 5

3

0

10 G

Why Expand a Vertex More Than Once?

path length

S

A

D 2 1

4 G

1

•  The shortest path from S to G is (G D A S).

edge cost

•  D is reached first using path (D S).

•  This prevents path (D A S) from being expanded. Suppose we expanded only the

first path that visits each vertex X? •  The suboptimal path (G D S)

is returned. ð Solution: Eliminate the Visited List. 9/23/15

26

Page 27: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Generic Search Algorithm

1.  Initialize Q with partial path (S) as only entry; set Visited = ( ); 2.   If Q is empty, fail; Else, pick partial path N from Q; 3.  If head(N) = G, return N ; (we’ve reached the goal!) 4.   (Otherwise) Remove N from Q; 5.   Find all children of head(N) (its neighbors in gr) not in Visited

and create all the one-step extensions of N to each child; 6.   Add to Q all the extended paths; 7.   Add children of head(N) to Visited; 8.   Go to Step 2.

Let gr be a Graph. Let Q be a list of simple partial paths in gr. Let S be the start vertex in gr. Let G be a Goal vertex in gr.

9/23/15 27

Page 28: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Uniform Cost Search Algorithm

1.  Initialize Q with partial path (S) as only entry; set Visited = ( ); 2.   If Q is empty, fail; Else, pick partial path N from Q with best g; 3.   If head(N) = G, return N ; (we’ve reached the goal!) 4.  (Otherwise) Remove N from Q; 5.  Find all children of head(N) (its neighbors in Gr) not in Visited

and create all the one-step extensions of N to each child; 6.  Add to Q all the extended paths; 7.   Add children of head(N) to Visited; 8.   Go to Step 2.

Let gr be a weighted Graph. Let Q be a list of simple partial paths in gr. Let S be the start vertex in gr. Let G be a Goal vertex in gr. Let g be the path weight from S to N.

28

Page 29: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Implementing the Search Strategies

Depth-first:

Pick first element of Q

Add path extensions to front of Q Breadth-first:

Pick first element of Q

Add path extensions to end of Q Uniform-cost:

Pick first element of Q

Add path extensions to Q in order of increasing path weight g.

Uses visited list

Uses visited list

No visited list

Implement priority queue with a heap. For graph with n nodes: •  Keeping a queue sorted takes time O(n2). •  Heap implementation takes time O(n lg n).

9/23/15

29

Page 30: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Best First with Uniform Cost Pick first element of Q; Insert path extensions, sorted by g.

5

7

6

Q

4 3 2 1

(2 A S) (5 B S) (0 S)

C

S

B

G A

D 2

5

4

2 3

2

5 1

1

Here we: •  Insert on queue in order of g. •  Remove first element of queue. 9/23/15

30

Page 31: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Best First with Uniform Cost

5

7

6

Q

4 3 2 1

(4 C A S) (5 B S) (6 D A S) (2 A S) (5 B S) (0 S)

C

S

B

G A

D 2

5

4

2 3

2

5 1

1

2

Pick first element of Q; Insert path extensions, sorted by g.

Here we: •  Insert on queue in order of g. •  Remove first element of queue. 9/23/15

31

Page 32: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Best First with Uniform Cost

5

7

6

Q

4 3 2 1

(5 B S) (6 D A S) (4 C A S) (5 B S) (6 D A S) (2 A S) (5 B S) (0 S)

C

S

B

G A

D 2

5

4

2 3

2

5 1

1

2

3 Pick first element of Q; Insert path extensions, sorted by g.

Here we: •  Insert on queue in order of g. •  Remove first element of queue. 9/23/15

32

Page 33: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Best First with Uniform Cost

(6 D B S) (6 D A S) (10 G B S) 5

(8 G D A S) (8 G D B S) (9 C D A S) (9 C D B S) (10 G B S) 7

(6 D A S) (8 G D B S) (9 C D B S) (10 G B S) 6

Q

4 3 2 1

(5 B S) (6 D A S) (4 C A S) (5 B S) (6 D A S) (2 A S) (5 B S) (0 S)

1

2

3

5,6

7 C

S

B

G A

D 2

5

4

2 3

2

5 1

4

Pick first element of Q; Insert path extensions, sorted by g.

9/23/15

33

Page 34: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Can we stop as soon as the goal is enqueued (“visited”)?

•  Other paths to the goal that are shorter may not yet be enqueued. •  Only when a path is pulled off the Q are we guaranteed that

no shorter path will be added. •  This assumes all edges are positive.

Q 1 (0 S) 2 (2 A S) (5 B S) 3 (4 C A S) (5 B S) (6 D A S) 4 (5 B S) (6 D A S) 5 (6 D B S) (6 D A S) (10 G B S) 6 (6 D A S)(8 G D B S) (9 C D B S) (10 G B S)

(8 G D A S) (8 G D B S) (9 C D A S) (9 C D B S) 7 (10 G B S)

9/23/15

34

Page 35: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Implementing the Search Strategies

Depth-first:

Pick first element of Q

Add path extensions to front of Q Breadth-first:

Pick first element of Q

Add path extensions to end of Q Uniform-cost:

Pick first element of Q

Add path extensions to Q in increasing order of path weight g.

Uses visited list

Uses visited list

No visited list

Best-first: (generalizes uniform-cost)

Pick first element of Q

Add path extensions in increasing order of any cost function f.

No visited list

9/23/15

35

Page 36: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Best-first Search Algorithm

1.   Initialize Q with partial path (S) as only entry; 2.   If Q is empty, fail. Else, pick partial path N from Q with best f; 3.   If head(N) = G, return N; (we’ve reached the goal!) 4.   (Otherwise) Remove N from Q; 5.   Find all children of head(N) (its neighbors in gr) and create all

the one-step extensions of N to each child; 6.   Add to Q all the extended paths; 7.   Go to Step 2.

Let gr be a Graph Let Q be a list of simple partial paths in gr. Let S be the start vertex in gr. Let G be a Goal vertex in gr. Let f be a cost function on N.

9/23/15

36

Page 37: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Cost and Performance

Search Method

Worst Time

Worst Space

Guaranteed to find a path? Optimal?

Depth-First bm b*m Yes No Breadth-First bd+1 bd+1 Yes Yes for unit edge cost

Best-First

Beam (beam width = k) Hill-Climbing (no backup) Hill-Climbing (backup)

Searching a tree with branching factor b, solution depth d, and max depth m

Worst case time is proportional to number of nodes visited Worst case space is proportional to maximal length of Q

Yes if uniform cost or A* w admissible heuristic Yes bd+1 bd+1

9/23/15

37

Page 38: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Remarks

•  UCS is a straightforward instance of BFS. •  UCS is complete and optimal. •  However, like BFS (or DFS),

UCS does not consider the goal node during search and could be slow.

9/23/15 Brian Williams, Fall 15

38

Page 39: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Classes of Search Blind Depth-First Systematic exploration of whole tree

(uninformed) Breadth-First until the goal is found.

Iterative-Deepening

Best-first Uniform-cost Uses path “length” measure. Finds

Greedy “shortest” path.

A*

9/23/15 Brian Williams, Fall 15

39

Page 40: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

A B

x x

start

spst

, ND

t

goal

Uniform cost search reads evenly from

art

Chicago, Il

Rapid City Boston, Ma

Uniform cost search explores the direction away from the goal as much as with the goal.

Greedy search is directed owards the goal.

9/23/15

40

Page 41: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Greedy Search Search in an order imposed by a heuristic function, measuring cost to go.

Heuristic function h – is a function of the current node n, not the partial path s to n.

•  Estimated distance to goal – h (n,G)

•  Example: straight-line distance in a road network.

•  “Goodness” of a node – h (n)

•  Example: elevation.

•  Foothills, plateaus and ridges are problematic. 9/23/15

41

Page 42: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Greedy

Q

1 (10 S) 2 3 4 5

Added paths in blue; heuristic value of head is in front.

C

S

B

G A

D

1

0 2

4 10

1 3

Heuristic values in red Order of nodes in blue.

Pick first element of Q; Insert path extensions, sorted by h.

9/23/15

42

Page 43: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Q

1 (10 S) 2 (2 A S) (3 B S) 3 4 5

Added paths in blue; heuristic value of head is in front.

C

S

B

G A

D

1

10

2

1

0

4

3

Greedy

Heuristic values in red Order of nodes in blue.

Pick first element of Q; Insert path extensions, sorted by h.

9/23/15

43

Page 44: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Greedy

Q

1 (10 S) 2 (2 A S) (3 B S) 3 (1 C A S) (3 B S) (4 D A S) 4 5

Added paths in blue; heuristic value of head is in front.

C

S

B

G A

D

1

2

10

2

1

0

4

3

Heuristic values in red Order of nodes in blue.

Pick first element of Q; Insert path extensions, sorted by h.

9/23/15

44

Page 45: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Greedy

Q

1 (10 S) 2 (2 A S) (3 B S) 3 (1 C A S) (3 B S) (4 D A S) 4 (3 B S) (4 D A S) 5

Added paths in blue; heuristic value of head is in front.

C

S

B

G A

D

1

2

3

10

2

1

0

4

3

Heuristic values in red Order of nodes in blue.

Pick first element of Q; Insert path extensions, sorted by h.

9/23/15

45

Page 46: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Greedy

Q

1 (10 S) 2 (2 A S) (3 B S) 3 (1 C A S) (3 B S) (4 D A S) 4 (3 B S) (4 D A S) 5 (0 G B S) (4 D A S) (4 D B S)

Added paths in blue; heuristic value of head is in front.

C

S

B

G A

D

1

2

3

4

10

2

1

0

4

3

Heuristic values in red Order of nodes in blue.

Pick first element of Q; Insert path extensions, sorted by h.

9/23/15

46

Page 47: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Greedy

Q

1 (10 S) 2 (2 A S) (3 B S) 3 (1 C A S) (3 B S) (4 D A S) 4 (3 B S) (4 D A S) 5 (0 G B S) (4 D A S) ) (4 D B S)

Added paths in blue; heuristic value of head is in front.

C

S

B

G A

D

1

0 2

4 10

3

2 3 2

2 4 5

1 5

Heuristic values in red

Pick first element of Q; Insert path extensions, sorted by h.

Edge cost in green.

Did Greedy search produce the shortest path? 9/23/15

47

Page 48: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Remarks

•  The performance of GS depends strongly on the quality of the heuristic. – With a good heuristic,

GS reaches the goal quickly. – With a misleading heuristic,

GS may “get stuck” and perform worse than UCS.

•  GS is not optimal. 9/23/15 Brian Williams, Fall 15

48

Page 49: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Classes of Search Blind Depth-First Systematic exploration of whole tree

(uninformed) Breadth-First until the goal is found.

Iterative-Deepening

Best-first Uniform-cost Uses path “length” measure. Finds

Greedy “shortest” path.

A*

9/23/15 Brian Williams, Fall 15

49

Page 50: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

A B

x x

start

spth

goal

Uniform cost search reads evenly from e start

9/23/15

50

Page 51: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

x x

start t

B

t

Ggp

goal A search biases uniform cost owards the goal by using h:

•  f = g + h

•  g = distance from start.

•  h = estimated distance to goal.

A

Uniform cost search spreads evenly from he start

reedy goes for the oal, but forgets its ast.

9/23/15

51

asin33
Oval
Page 52: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Comparison of UCS and GS

UCS •  Think about the past:

GS •  Think about the future:

order the queue by g(v), order the queue by h(v), the path cost from the start the estimated path cost to (cost-to-come). the goal (cost-to-go).

•  Optimal. •  Not optimal. •  Usually not fast. •  Maybe fast.

9/23/15 Brian Williams, Fall 15

52

Page 53: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Combining UCS and GS •  What if we put g(v) and h(v) together?

Order the queue according to

•  Resulting can be both optimal and fast.

The A search algorithm

The problems

Uniform-Cost search is optimal, but may wander around a lot before findingthe goal.Greedy search is not optimal, but in some cases it is e�cient, as it is heavilybiased towards moving towards the goal. The non-optimality comes fromneglecting “the past.”

The idea

Keep track both of the cost of the partial path to get to a vertex, say g(v),and of the heuristic function estimating the cost to reach the goal from avertex, h(v).In other words, choose as a “ranking” function the sum of the two costs:

f (v) = g(v) + h(v)

g(v): cost-to-come (from the start to v).h(v): cost-to-go estimate (from v to the goal).f (v): estimated cost of the path (from the start to v and then to the goal).

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 24 / 46

9/23/15 Brian Williams, Fall 15

53

Page 54: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Remarks

•  A search generalizes both UCS and GS. – Setting h(v)=0, we get UCS. –  Ignoring g(v), we get GS.

•  A search appears fast, but is not optimal. What is the problem?

9/23/15 Brian Williams, Fall 15

54

Page 55: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A* Search

To make A search optimal, •  h(v) must always underestimate the distance to

the goal. • In other words, the heuristic must be optimistic

(admissible):

Remarks on the A search algorithm

A search is similar to UCS, with a bias induced by the heuristic h. Ifh = 0, A = UCS.

The A search is complete, but is not optimal. What is wrong?(Recall that if h = 0 then A = UCS, and hence optimal...)

A⇤ Search

Choose an admissible h(v) h⇤(v)(The star means “opti

The A search with an admissible heuristic is called A⇤, which isguaranteed to be optimal.

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 31 / 46

9/23/15 Brian Williams, Fall 15

55

Page 56: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Simple Optimal Search Algorithm BFS + Admissible Heuristic

Let gr be a Graph Let Q be a list of simple partial paths in gr Let S be the start vertex in gr and Let G be a Goal vertex in gr. Let f = g + h be an admissible heuristic function.

1.   Initialize Q with partial path (S) as only entry; 2.   If Q is empty, fail. Else, use f to pick “best” partial path N from Q; 3.   If head(N) = G, return N; (we’ve reached the goal) 4.   (Otherwise) Remove N from Q; 5.   Find all the descendants of head(N) (its neighbors in Gr) and create all the

one-step extensions of N to each descendant; 6.   Add to Q all the extended paths; 7.   Go to Step 2.

9/23/15

56

Page 57: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

In the example, is h an admissible heuristic?

C

S

B

G A

D

1

2 2 3 2 0

4 2 4 10 5 1 3 5

•  A is ok. • B is ok.  •  C is ok. •  D is too big; needs to be ≤ 2. •  S is too big; can always use 0 for start.

Heuristic Values of h in Red. Edge cost in Green. A finds an optimal solution

if h never over estimates.

•  Search is called A*. 9/23/15

•  h is called “admissible.” 57

Page 58: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Admissible heuristics for 8 puzzle?

6 2 8 3 5

4 7 1

1 2 3 8 4 7 6 5

S G

What is the heuristic? •  An underestimate of number of moves to the goal.

Examples:

1.   Number of misplaced tiles (7)

2.   Sum of Manhattan distance of each tile to its goal location 9/23/15

(17)

58

Page 59: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Finding admissible heuristics

•  Often domain-specific knowledge is required.

•  Examples

Admissible heuristics

How to find an admissible heuristic? i.e., a heuristic that neveroverestimates the cost-to-go.

Examples of admissible heuristics

h(v) = 0: this always works! However, it is not very useful, and inthis case A⇤ = UCS .

h(v) = distance(v , g) when the vertices of the graphs are physicallocations.

h(v) = kv � gkp, when the vertices of the graph are points in anormed vector space.

A general method

Choose h as the optimal cost-to-go function for a relaxed problem, that iseasy to compute.(Relaxed problem: ignore some of the constraints in the original problem)

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 38 / 46

9/23/15 Brian Williams, Fall 15

59

Page 60: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Finding admissible heuristics

•  Relaxation – Create a relaxed problem by ignoring some

constraints in the original problem. •  Consistency

– A heuristic function h is consistent if – A consistent heuristic function is admissible.

Consistent heuristics

An additional useful property for A⇤ heuristics is called consistency

A heuristic h : X ! R�0

is said consistent if

h(u) w (e = (u, v)) + h(v), 8(u, v) 2 E .

In other words, a consistent heuristics satisfies a triangle inequality.

If h is a consistent heuristics, then f = g + h is non-decreasing alongpaths:

f (v) = g(v) + h(v) = g(u) + w(u, v) + h(v) � f (u).

Hence, the values of f on the sequence of nodes expanded by A⇤ isnon-decreasing: the first path found to a node is also the optimalpath ) no need to compare costs!

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 41 / 46

9/23/15 Brian Williams, Fall 15

60

Page 61: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Benefits of heuristics

0

5000

10000

15000

20000

25000

30000

35000

40000

45000

50000

2 4 6 8 10 12 14 16 18 20 22 24

IDS A*(h1) A*(h2)

9/23/15 Brian Williams, Fall 15

AIMA, Sect. 3.6, Fig. 3.29 61

Page 62: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Why the difference?

•  h(v)=0 •  h(v)=h*(v)

9/23/15 Brian Williams, Fall 15

62

Page 63: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A* optimality: intuition

If the heuristic function •  over-estimates the distance to the goal,

–  we eliminate the optimal solution and make a mistake that is irrecoverable.

•  under-estimates the distance, –  the search may be misled. –  However, as the search continues, the cost of the

sub-optimal path rises, and –  we eventually recover from the mistake.

9/23/15 Brian Williams, Fall 15

63

Page 64: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A* optimality: proof

Proof (sketch) of A⇤ optimality

By contradiction

Assume that A⇤ returns P , but w(P) > w⇤

(w⇤ is the optimal path weight/cost).

Find the first unexpanded node on the optimal path P⇤, call it n.

f (n) > w(P), otherwise we would have expanded n.

f (n) = g(n) + h(n) by definition

= g⇤(n) + h(n) because n is on the optimal path.

g⇤(n) + h⇤(n) because h is admissible

= f ⇤(n) = W ⇤ because h is admissible

Hence W ⇤ � f (n) > W , which is a contradiction.

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 37 / 46

*

9/23/15 Brian Williams, Fall 15

64

Page 65: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Can We Prune Search Branches?

Property: Shortest Paths are extensions of Shortest Sub-Paths.

•  Suppose path P = P1 o P2 , from S to G, is shortest.

•  Suppose P2 , from U to G, is not.

•  Then there exists P2’ from U to G that is shorter than P2.

•  Hence P’ = P1 o P2’ is shorter than P.

•  By contradiction, if P is a shortest, then P2 is a shortest sub-path.

9/23/15

65

Page 66: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Can We Prune Search Branches?

Property: Shortest Paths are extensions of Shortest Sub-Paths.

Idea: when shortest path S to U is found, ignore other paths S to U.

•  When BFS dequeues the first partial path with head node U, this path is guaranteed to be the shortest path from S to U.

"   Given the first path to U, we don’t need to extend other paths to U; delete them (expanded list).

9/23/15

66

Page 67: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Simple Optimal Search Algorithm How do we add dynamic programming?

1.   Initialize Q with partial path (S) as only entry; 2.   If Q is empty, fail. Else, use f to pick the “best” partial path N from Q; 3.   If head(N) = G, return N; (we’ve reached the goal) 4.   (Else) Remove N from Q; 5.   Find all children of head(N) (its neighbors in gr) and

create all the one-step extensions of N to each child; 6.   Add to Q all the extended paths; 7.   Go to Step 2.

Let gr be a Graph. Let Q be a list of simple partial paths in gr. Let S be the start vertex in gr. Let G be a Goal vertex in gr. Let f = g + h be an admissible heuristic function.

9/23/15

67

Page 68: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

A* Optimal Search Algorithm BFS + Dyn Prog + Admissible Heuristic

1.   Initialize Q with partial path (S) as only entry; set Expanded = ( ); 2.   If Q is empty, fail. Else, use f to pick “best” partial path N from Q; 3.   If head(N) = G, return N; (we’ve reached the goal) 4.   (Else) Remove N from Q; 5.   if head(N) is in Expanded, go to Step 2; otherwise, add head(N) to Expanded; 6.   Find all the children of head(N) (its neighbors in gr) not in Expanded,

and create all one-step extensions of N to each child; 7.   Add to Q all the extended paths; 8.   Go to Step 2.

Let gr be a Graph Let Q be a list of simple partial paths in gr. Let S be the start vertex in gr. Let G be a Goal vertex in gr. Let f = g + h be an admissible heuristic function.

9/23/15

68

Page 69: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

A* (BFS + DynProg + Admissible Heuristic)

Q 1 (0 S)

1

Added paths in blue; cost f at head of each path.

C

S

B

G A

D

1

2 2 3 2 0

1 2 4 5 1 0 3 5

Heuristic Values of g in Red Edge cost in Green

Pick first element of Q; Insert path extensions, sorted by path length + heuristic.

Expanded

9/23/15

69

Page 70: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

A* (BFS + DynProg + Admissible Heuristic)

Q

2 1 (0 S)

Added paths in blue; cost f at head of each path

C

2 2 3 G A 2 0

1 1 2 4 D S 5 1 0 3 5 B

1

Heuristic Values of g in Red Edge cost in Green

Expanded

S

Pick first element of Q; Insert path extensions, sorted by path length + heuristic.

9/23/15

70

Page 71: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

A* (BFS + DynProg + Admissible Heuristic)

Q 1 (0 S) 2 (4 A S) (8 B S) 3

2

1

C

S

B

G A

D

1

2 2 3 2 0

1 2 4 5 1 0 3 5

Added paths in blue; cost f at head of each path

Heuristic Values of g in Red Edge cost in Green

Pick first element of Q; Insert path extensions, sorted by path length + heuristic.

Expanded

S S A

9/23/15

71

Page 72: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

A* (BFS + DynProg + Admissible Heuristic)

Q 1 (0 S) 2 (4 A S) (8 B S) 3 (5 C A S) (7 D A S) (8 B S) 4

3

2

1

C

S

B

G A

D

1

2 2 3 2 0 1

2 4 5 1 0 3 5

Added paths in blue; cost f at head of each path

Heuristic Values of g in Red Edge cost in Green

Pick first element of Q; Insert path extensions, sorted by path length + heuristic.

Expanded

S S A S A C

9/23/15

72

Page 73: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

A* (BFS + DynProg + Admissible Heuristic)

Q 1 (0 S) 2 (4 A S) (8 B S) 3 (5 C A S) (7 D A S) (8 B S) 4 (7 D A S) (8 B S) 5

3

2

4 1

C

S

B

G A

D

1

2 2 3 2 0

1 2 4 5 1 0 3 5

Added paths in blue; cost f at head of each path

Heuristic Values of g in Red Edge cost in Green

Expanded

S S A S A C S A C D

Pick first element of Q; Insert path extensions, sorted by path length + heuristic.

9/23/15

73

Page 74: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

A* (BFS + DynProg + Admissible Heuristic)

Q 1 (0 S) 2 (4 A S) (8 B S) 3 (5 C A S) (7 D A S) (8 B S) 4 (7 D A S) (8 B S) 5 (8 G D A S) (8 B S)

3

5 2

4 1

C

S

B

G A

D

1

2 2 3 2 0

1 2 4 5 1 0 3 5

Added paths in blue; cost f at head of each path

Heuristic Values of g in Red Edge cost in Green

Expanded

S S A S A C S A C D

Pick first element of Q; Insert path extensions, sorted by path length + heuristic.

9/23/15

74

Page 75: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Expanded List can offer Exponential Saving

Enumerate all (sub)paths:

•  For simple paths of length n through S states, O(|S|2n+1).

•  For simple paths up to length n, O(|S|2n+2.

Enumerate all shortest (sub)paths:

•  Property: Shortest paths are extensions of Shortest Sub-Paths.

•  Algorithm: Dynamic Programming:

•  Compute shortest paths of length n from shortest (sub)paths of length n-1.

•  O(n|S|2) for shortest paths up to length n and |S| states.

Dynamic Programming

The optimality principle

Let P = (s, . . . , v , . . . g) be an optimal path (from s to g). Then, for anyv 2 P , the sub-path S = (v , . . . , g) is itself an optimal path (from v to g).

Using the optimality principle

Essentially, optimal paths are made of optimal paths. Hence, we canconstruct long complex optimal paths by putting together shortoptimal paths, which can be easily computed.

Fundamental formula in dynamic programming:

h⇤(u) = min(u,v)2E

[w( (u, v) ) + h⇤(v)] .

Typically, it is convenient to build optimal paths working backwardsfrom the goal.

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 43 / 46

9/23/15

75

Page 76: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Remarks

•  The performance of A* search depends on the quality of the heuristic.

•  A* search is optimal.

9/23/15 Brian Williams, Fall 15

76

Page 77: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

start Ato

A B

x x

Grto

ty, ND

goal * biases uniform cost wards the goal b by adding

h.

Uniform cost search spreads evenly from the start using g.

Recap: Informed Search Chicago, Il

eedy search is directed wards the goal using h.

Rapid Ci Boston, Ma

9/23/15 Brian Williams, Fall 15

77

asin33
Oval
Page 78: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Appendices

•  Bounding. •  Variants. •  More about Informed Search. •  Dynamic Programming.

Page 79: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Classes of Search Blind Depth-First Systematic exploration of whole tree

(uninformed) Breadth-First until the goal is found.

Iterative-Deepening

Best-first Uniform-cost Uses path “length” measure. Finds

Greedy “shortest” path.

A*

Bounding Branch and Bound Prunes suboptimal branches.

Alpha/Beta (L6) Prunes options that the adversary rules out.

9/23/15 Brian Williams, Fall 15

79

Page 80: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Branch and Bound

0 S

B

C D D G

G C G C

A 4

5

8

7

10 8 10 10

7 10

C

S

B

G A

D 2

5

4

2 3

2

5 1

2

1

0 1

3

0

Heuristic Values of g in Red Edge cost in Green

•  A* generalizes best-first search.

•  How do we generalize depth-first search?

9/23/15

80

Page 81: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Branch and Bound

0 S

B

C D D G

G C G C

4 8 A

5 7 7

10 8 10 10

10

C

S

B

G A

D

1

2 2 3 2 0

1 2 4 5 1 3 5

0

Heuristic Values of g in Red Edge cost in Green

•  Idea 1: Maintain the best solution found thus far (incumbent).

•  Idea 2: Prune all subtrees worse than the incumbent.

Incumbent: cost U = ∞, 8 path P = (), (S A D G)

9/23/15

81

Page 82: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Branch and Bound

0 S

B

C D D G

G C G C

4 8 A

5 7 7

10 8 10 10

10

C

S

B

G A

D

1

2 2 3 2 0

1 2 4 5 1 3 5

0

Heuristic Values of g in Red Edge cost in Green

•  Idea 1: Maintain the best solution found thus far (incumbent).

•  Idea 2: Prune all subtrees worse than the incumbent.

•  Any search order allowed (DFS, Reverse-DFS, BFS, Hill w BT…).

Incumbent: cost U = path P =

∞, (),

10, (S B G)

8 (S A D G)

9/23/15

82

Page 83: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Simple Optimal Search Using Branch and Bound

Let gr be a Graph. Let Q be a list of simple partial paths in gr. Let S be the start vertex in gr. Let G be a Goal vertex in gr. Let f = g + h be an admissible heuristic function. U and P are the cost and path of the best solution thus far (Incumbent).

1.   Initialize Q with partial path (S); Incumbent U = ∞, P = (); 2.   If Q is empty, return Incumbent U and P,

Else, remove a partial path N from Q; 3.   If f(N) >= U, Go to Step 2. 4.   If head(N) = G, then U = f(N) and P = N (a better path to the goal) 5.   (Else) Find all children of head(N) (its neighbors in gr) and

create all the one-step extensions of N to each child. 6.   Add to Q all the extended paths. 7.   Go to Step 2.

9/23/15

83

Page 84: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Appendices

•  Bounding. •  Variants. •  More about Informed Search. •  Dynamic Programming.

Page 85: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Classes of Search Blind Depth-First Systematic exploration of whole tree

(uninformed) Breadth-First until the goal is found.

Iterative-Deepening

Variants Hill-Climbing (w backup)

Beam

IDA*

Best-first Uniform-cost Uses path “length” measure. Finds

Greedy “shortest” path.

A*

Bounding Branch and Bound Prunes suboptimal branches.

Alpha/Beta Prunes options that the adversary rules out.

9/23/15 85

Page 86: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D

1

Q

1 (10 S) 2 (2 A S) (3 B S) 3 4

Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

Hill-Climbing Pick first element of Q; Replace Q with extensions (sorted by heuristic value)

9/23/15

86

Page 87: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D

2

1

Q

1 (10 S) 2 (2 A S) (3 B S) 3 (1 C A S) (4 D A S) 4

Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

Hill-Climbing Pick first element of Q; Replace Q with extensions (sorted by heuristic value)

Removed

9/23/15

87

Page 88: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D

2

1

3

Q

1 (10 S) 2 (2 A S) (3 B S) 3 (1 C A S) (4 D A S) 4 ( )

Heuristic Values Fails to find a path! A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

Hill-Climbing Pick first element of Q; Replace Q with extensions (sorted by heuristic value)

9/23/15

88

Page 89: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Cost and Performance Searching a tree with branching factor b, solution depth d, and max depth m

Search Worst Worst Guaranteed to Optimal? Method Time Space find a path?

Depth-First bm b*m Yes No Breadth-First bd+1 bd+1 Yes Yes for unit edge cost

Best-First bd+1 bd+1 Yes Yes if uniform cost or A* w admissible heuristic.

Beam (beam width = k) Hill-Climbing

b*m b No No (no backup) Hill-Climbing (backup)

Worst case time is proportional to number of nodes visited Worst case space is proportional to maximal length of Q

9/23/15

89

Page 90: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Hill-Climbing (with backup)

C

S

B

G A

D

1

Q

1 (10 S) 2 (2 A S) (3 B S) 3 4 5 Heuristic Values

A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

Pick first element of Q; Add path extensions (sorted by heuristic value) to front of Q

9/23/15

90

Page 91: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Hill-Climbing (with backup)

C

S

B

G A

D

2

1

Pick first element of Q; Add path extensions (sorted by heuristic value) to front of Q

Q

1 (10 S) 2 (2 A S) (3 B S) 3 (1 C A S) (4 D A S) (3 B S) 4 5 Heuristic Values

A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

All new nodes before old

9/23/15

91

Page 92: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Hill-Climbing (with backup)

C

S

B

G A

D

3

2

1

Pick first element of Q; Add path extensions (sorted by heuristic value) to front of Q

Q

1 (10 S) 2 (2 A S) (3 B S) 3 (1 C A S) (4 D A S) (3 B S) 4 (4 D A S) (3 B S) 5 Heuristic Values

A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

9/23/15

92

Page 93: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Hill-Climbing (with backup)

C

S

B

G A

D

3

2

4

1

Pick first element of Q; Add path extensions (sorted by heuristic value) to front of Q

Q

1 (10 S) 2 (2 A S) (3 B S) 3 (1 C A S) (4 D A S) (3 B S) 4 (4 D A S) (3 B S) 5 (0 G D A S) (1 C A S) (3 B S) Heuristic Values

A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

9/23/15

93

Page 94: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Hill-Climbing (with backup)

C

S

B

G A

D

3

5 2

4

1

Q

1 (10 S) 2 (2 A S) (3 B S) 3 (1 C A S) (4 D A S) (3 B S) 4 (4 D A S) (3 B S) 5 (0 G D A S) (1 C A S) (3 B S) Heuristic Values

A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

Pick first element of Q; Add path extensions (sorted by heuristic value) to front of Q

9/23/15

94

Page 95: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Cost and Performance Searching a tree with branching factor b, solution depth d, and max depth m

Search Worst Worst Guaranteed to Optimal? Method Time Space find a path?

Depth-First bm b*m Yes No Breadth-First bd+1 bd+1 Yes Yes for unit edge cost

Best-First bd+1 bd+1 Yes Yes if uniform cost or A* w admissible heuristic.

Beam (beam width = k) Hill-Climbing

b*m b No No (no backup) Hill-Climbing (backup)

Worst case time is proportional to number of nodes visited Worst case space is proportional to maximal length of Q

9/23/15

95

Page 96: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Cost and Performance Searching a tree with branching factor b, solution depth d, and max depth m

Search Worst Worst Guaranteed to Optimal? Method Time Space find a path?

Depth-First bm b*m Yes No Breadth-First bd+1 bd+1 Yes Yes for unit edge cost

Best-First bd+1 bd+1 Yes Yes if uniform cost or A* w admissible heuristic.

Beam (beam width = k) Hill-Climbing

b*m b No No (no backup) Hill-Climbing

bm b*m Yes No (backup)

Worst case time is proportional to number of nodes visited Worst case space is proportional to maximal length of Q

9/23/15

96

Page 97: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Classes of Search Blind Depth-First Systematic exploration of whole tree

(uninformed) Breadth-First until the goal is found.

Iterative-Deepening

Variants Hill-Climbing (w backup)

Beam

IDA*

Best-first Uniform-cost Uses path “length” measure. Finds

Greedy “shortest” path.

A*

Bounding Branch and Bound Prunes suboptimal branches

Alpha/Beta Prunes options the adversary rules out

9/23/15 97

Page 98: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Q

1 (10 S) 2

Expand all Q elements; Keep the k best extensions (sorted by heuristic value)

C

S

B

G A

D

1

Heuristic Values Idea: Incrementally expand the k best paths A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

Let k = 2

Beam

9/23/15

98

Page 99: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D

1

Expand all Q elements; Keep the k best extensions (sorted by heuristic value)

Q

1 (10 S) 2 (2 A S) (3 B S)

Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

Idea: Incrementally expand the k best paths

Let k = 2

Beam

9/23/15

99

Page 100: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D

2

1 2

Q

1 (10 S) 2 (2 A S) (3 B S)

(0 G B S) (1 C A S) 3

(4 D A S) (4 D B S)

Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

Keep k best

Expand all Q elements; Keep the k best extensions (sorted by heuristic value)

Idea: Incrementally expand the k best paths

Let k = 2

Beam

9/23/15

100

Page 101: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

C

S

B

G A

D

3 2

1 2

Q

1 (10 S) 2 (2 A S) (3 B S)

(0 G B S) (1 C A S) 3

(4 D A S) (4 D B S)

Heuristic Values A=2 C=1 S=10 B=3 D=4 G=0

Added paths in blue; heuristic value of head is in front.

Beam Expand all Q elements; Keep the k best extensions (sorted by heuristic value)

Keep k best

Idea: Incrementally expand the k best paths

Let k = 2 9/23/15

101

Page 102: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Brian Williams, Fall 15

Cost and Performance

Search Worst Worst Guaranteed to Optimal? Method Time Space find a path?

Depth-First bm b*m Yes No Breadth-First bd+1 bd+1 Yes Yes for unit edge cost

Best-First bd+1 bd+1 Yes Yes if uniform cost or A* w admissible heuristic.

Beam k*b*m k*b No No (beam width = k)

Hill-Climbing b*m b No No (no backup)

Hill-Climbing bm b*m Yes No (backup)

Searching a tree with branching factor b, solution depth d, and max depth m

Worst case time is proportional to number of nodes visited Worst case space is proportional to maximal length of Q

9/23/15

102

Page 103: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Appendices

•  Bounding •  Variants •  More about Informed Search. •  Dynamic Programming.

Page 104: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

•  Optimal (shortest) path <s,b,g> •  Sub-optimal path <s,a,d,g>, …

Example: point-to-point shortest path

Find the minimum-weight path from s to g in the graph below:

Solution: a simple path P = hg , d , a, si (P = hg , d , b, si would beacceptable, too), with weight w(P) = 8.

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 5 / 46

Breadth-first search: an example

9/23/15 Brian Williams, Fall 15

104

Page 105: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Example: point-to-point shortest path

Find the minimum-weight path from s to g in the graph below:

Solution: a simple path P = hg , d , a, si (P = hg , d , b, si would beacceptable, too), with weight w(P) = 8.

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 5 / 46

Uniform-cost search: an example

9/23/15 Brian Williams, Fall 15

105

Page 106: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Uniform-cost search

Q hstarti ; // Initialize the queue with the starting node

while Q is not empty doPick (and remove) the path P with lowest cost g = w(P) from the queue Q ;if head(P) = goal then return P ; // Reached the goal

foreach vertex v such that (head(P), v) 2 E, do //for all neighborsadd hv ,Pi to the queue Q ; // Add expanded paths

return FAILURE ; // Nothing left to consider.

Uniform-Cost Search

Note: no visited list!

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 6 / 469/23/15 Brian Williams, Fall 15

106

Page 107: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A trace of UCS execution

Q:path cost

hsi 0

sstart

a

b

c

d g

2

23

4

5

5

2

Example of Uniform-Cost Search: Step 1

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 7 / 46

Q:

path cost

ha, si 2hb, si 5

sstart

a

b

c

d g

2

23

4

5

5

2

Example of Uniform-Cost Search: Step 2

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 8 / 46

Q:

state cost

hc , a, si 4hb, si 5hd , a, si 6

sstart

a

b

c

d g

2

23

4

5

5

2

Example of Uniform-Cost Search: Step 3

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 9 / 46

Q:

state cost

hb, si 5hd , a, si 6hd , c , a, si 7

sstart

a

b

c

d g

2

23

4

5

5

2

Example of Uniform-Cost Search: Step 4

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 10 / 46

9/23/15 Brian Williams, Fall 15

107

Page 108: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A trace of UCS execution

Q:

state cost

hd , a, si 6hd , c , a, si 7hg , b, si 10

sstart

a

b

c

d g

2

23

4

5

5

2

Example of Uniform-Cost Search: Step 5

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 11 / 46

Q:

state cost

hd , c , a, si 7hg , d , a, si 8hg , b, si 10

sstart

a

b

c

d g

2

23

4

5

5

2

Example of Uniform-Cost Search: Step 6

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 12 / 46

Q:

state cost

hg , d , a, si 8hg , d , c , a, si 9hg , b, si 10

sstart

a

b

c

d g

2

23

4

5

5

2

Example of Uniform-Cost Search: Step 7

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 13 / 46

9/23/15 Brian Williams, Fall 15

108

Page 109: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Greedy (best-first) search

Q hstarti; // Initialize the queue with the starting node

while Q is not empty doPick the path P with minimum heuristic cost h(head(P)) from the queue Q;if head(P) = goal then return P ; // We have reached the goal

foreach vertex v such that (head(P), v) 2 E, doadd hv ,Pi to the queue Q;

return FAILURE ; // Nothing left to consider.

Greedy (Best-First) Search

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 16 / 46

9/23/15 Brian Williams, Fall 15

109

Page 110: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A trace of GS execution

Q:path cost h

hsi 0 10

s10start

a2

b3

c1

d4

g0

2

23

4

5

5

2

Example of Greedy (Best-First) Search: Step 1

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 17 / 46

Q:

path cost h

ha, si 2 2hb, si 5 3

s10start

a2

b3

c1

d4

g0

2

23

4

5

5

2

Example of Greedy (Best-First) Search: Step 2

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 18 / 46

Q:

path cost h

hc , a, si 4 1hb, si 5 3hd , a, si 6 4

s10start

a2

b3

c1

d4

g0

2

23

4

5

5

2

Example of Greedy (Best-First) Search: Step 3

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 19 / 46

Q:

path cost h

hb, si 5 3hd , a, si 6 4hd , c , a, si 7 4

s10start

a2

b3

c1

d4

g0

2

23

4

5

5

2

Example of Greedy (Best-First) Search: Step 4

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 20 / 46

9/23/15 Brian Williams, Fall 15

110

Page 111: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A trace of GS execution

Q:

path cost h

hg , b, si 10 0hd , a, si 6 4hd , c , a, si 7 4

s10start

a2

b3

c1

d4

g0

2

23

4

5

5

2

Example of Greedy (Best-First) Search: step 5

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 21 / 46

9/23/15 Brian Williams, Fall 15

111

Page 112: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A search

Q hstarti; // Initialize the queue with the starting node

while Q is not empty doPick the path P with minimum estimated cost f (P) = g(P) + h(head(P))from the queue Q;if head(P) = goal then return P ; // We have reached the goal

foreach vertex v such that (head(P), v) 2 E, doadd hv ,Pi to the queue Q;

return FAILURE ; // Nothing left to consider.

A Search

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 25 / 46

9/23/15 Brian Williams, Fall 15

112

Page 113: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A trace of A search execution

Q:path g h f

hsi 0 10 10

s10start

a2

b3

c1

d5

g0

2

23

4

5

5

2

Example of A Search: Step 1

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 26 / 46

Q:

path g h f

ha, si 2 2 4hb, si 5 3 8

s10start

a2

b3

c1

d5

g0

2

23

4

5

5

2

Example of A Search: step 2

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 27 / 46

Q:

path g h f

hc , a, si 4 1 5hb, si 5 3 8hd , a, si 6 5 11

s10start

a2

b3

c1

d5

g0

2

23

4

5

5

2

Example of A Search: step 3

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 28 / 46

Q:

path g h f

hb, si 5 3 8hd , a, si 6 5 11hd , c , a, si 7 5 12

s10start

a2

b3

c1

d5

g0

2

23

4

5

5

2

Example of A Search: step 4

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 29 / 46

9/23/15 Brian Williams, Fall 15

113

Page 114: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A trace of A search execution

Q:

path g h f

hg , b, si 10 0 10hd , a, si 6 5 11hd , c , a, si 7 5 12

s10start

a2

b3

c1

d5

g0

2

23

4

5

5

2

Example of A Search: step 5

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 30 / 46

9/23/15 Brian Williams, Fall 15

114

Page 115: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A trace of A* search execution

Q:path g h f

hsi 0 10 10

s6start

a2

b3

c1

d1

g0

2

23

4

5

5

2

6 6

Example of A⇤ Search: step 1

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 32 / 46

Q:

path g h f

ha, si 2 2 4hb, si 5 3 8

s6start

a2

b3

c1

d1

g0

2

23

4

5

5

2

Example of A⇤ Search: step 2

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 33 / 46

Q:

path g h f

hc , a, si 4 1 5hd , a, si 6 1 7hb, si 5 3 8

s6start

a2

b3

c1

d1

g0

2

23

4

5

5

2

Example of A⇤ Search: step 3

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 34 / 46

Q:

path g h f

hd , a, si 6 1 7hb, si 5 3 8

hd , c , a, si 7 1 8

s6start

a2

b3

c1

d1

g0

2

23

4

5

5

2

Example of A⇤ Search: Step 4

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 35 / 46

9/23/15 Brian Williams, Fall 15

115

Page 116: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

A trace of A* search execution

Q:

path g h f

hg , d , a, si 8 0 8hb, si 5 3 8

hd , c , a, si 7 1 8

s6start

a2

b3

c1

d1

g0

2

23

4

5

5

2

Example of A⇤ Search: step 5

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 36 / 46

9/23/15 Brian Williams, Fall 15

116

Page 117: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Appendices

•  Bounding •  Variants •  More about Informed Search. •  Dynamic Programming.

Page 118: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Dynamic programming

•  Search algorithms work towards the goal. Hence the need for the heuristic h(v).

•  What if we work backwards from the goal? h(G)=0, and h(v) becomes available when needed.

•  Bellman’s dynamic programming principle:

–  Shortest paths computed from smaller shortest paths.

Dynamic Programming

The optimality principle

Let P = (s, . . . , v , . . . g) be an optimal path (from s to g). Then, for anyv 2 P , the sub-path S = (v , . . . , g) is itself an optimal path (from v to g).

Using the optimality principle

Essentially, optimal paths are made of optimal paths. Hence, we canconstruct long complex optimal paths by putting together shortoptimal paths, which can be easily computed.

Fundamental formula in dynamic programming:

h⇤(u) = min(u,v)2E

[w( (u, v) ) + h⇤(v)] .

Typically, it is convenient to build optimal paths working backwardsfrom the goal.

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 43 / 46

9/23/15 Brian Williams, Fall 15

118

Page 119: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

DP example Dijkstra’s algorithm: example

5 2

4

0

4

6

5

21

Inf Inf

Inf

0

4

6

5

21

6 2

4

0

4

6

5

21

5 2

4

0

4

6

5

21

S A

G B

Dynamic programming requires the computation of all optimalsub-paths, from all possible initial states (curse of dimensionality).

On-line computation is easy via state feedback: convert an open-loopproblem into a feedback problem. This can be useful in real-worldapplications, where the state is subject to errors.

E. Frazzoli (MIT) L05: Informed Search November 1, 2010 45 / 46

9/23/15 Brian Williams, Fall 15

119

Page 120: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

Comparison of A* and DP

A* Dynamic programming •  Search towards the goal, •  Work backwards from the

guided by a heuristic. goal. •  Fast if the heuristic is good. •  Slower. •  Find the optimal path from •  Find the optimal path from

the start node to the goal every node to the goal node. node. •  Provide closed-loop

•  Provide open-loop control. feedback control.

9/23/15 Brian Williams, Fall 15

120

Page 121: Cognitive Robotics: Informed Search - MIT OpenCourseWare · Classes of Search . Blind. Depth-First. Systematic exploration of whole tree (uninformed) Breadth-First. until the goal

MIT OpenCourseWarehttps://ocw.mit.edu

16.412J / 6.834J Cognitive RoboticsSpring 2016

For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.