A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their...

223
A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were adapted from CS188 Intro to AI at UC Berkeley] CS 5522: Artificial Intelligence II

Transcript of A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their...

Page 1: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Search, Graph Search, Their Completeness and Optimality

Instructor: Wei Xu

Ohio State University [These slides were adapted from CS188 Intro to AI at UC Berkeley]

CS 5522: Artificial Intelligence II

Page 2: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

0

39

1

1

2

8

8 2

15

1

22

Page 3: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

0

39

1

1

2

8

8 2

15

1

22

Page 4: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

16

0

39

1

1

2

8

8 2

15

1

22

Page 5: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

16411

5

0

39

1

1

2

8

8 2

15

1

22

Page 6: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

16411

5

0

6

39

1

1

2

8

8 2

15

1

22

Page 7: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

16411

5

713

0

6

39

1

1

2

8

8 2

15

1

22

Page 8: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

16411

5

713

0

6

39

1

1

2

8

8 2

15

1

22

Page 9: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

16411

5

713

8

0

6

39

1

1

2

8

8 2

15

1

22

Page 10: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

16411

5

713

8

1011

0

6

39

1

1

2

8

8 2

15

1

22

Page 11: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

16411

5

713

8

1011

17 11

0

6

39

1

1

2

8

8 2

15

1

22

Page 12: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

16411

5

713

8

1011

17 11

0

6

39

1

1

2

8

8 2

15

1

22

Page 13: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (recap: uninformed search)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Strategy: expand a cheapest node first:

Fringe is a priority queue (priority: cumulative cost) S

G

d

b

p q

c

e

h

a

f

r

3 9 1

16411

5

713

8

1011

17 11

0

6

39

1

1

2

8

8 2

15

1

2

Cost contours

2

Page 14: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 15: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 16: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 17: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 18: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?▪ Processes all nodes with cost less than cheapest solution!

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 19: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?▪ Processes all nodes with cost less than cheapest solution!▪ If that solution costs C* and arcs cost at least ε , then the

“effective depth” is roughly C*/ε

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 20: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?▪ Processes all nodes with cost less than cheapest solution!▪ If that solution costs C* and arcs cost at least ε , then the

“effective depth” is roughly C*/ε▪ Takes time O(bC*/ε) (exponential in effective depth)

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 21: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?▪ Processes all nodes with cost less than cheapest solution!▪ If that solution costs C* and arcs cost at least ε , then the

“effective depth” is roughly C*/ε▪ Takes time O(bC*/ε) (exponential in effective depth)

▪ How much space does the fringe take?

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 22: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?▪ Processes all nodes with cost less than cheapest solution!▪ If that solution costs C* and arcs cost at least ε , then the

“effective depth” is roughly C*/ε▪ Takes time O(bC*/ε) (exponential in effective depth)

▪ How much space does the fringe take?▪ Has roughly the last tier, so O(bC*/ε)

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 23: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?▪ Processes all nodes with cost less than cheapest solution!▪ If that solution costs C* and arcs cost at least ε , then the

“effective depth” is roughly C*/ε▪ Takes time O(bC*/ε) (exponential in effective depth)

▪ How much space does the fringe take?▪ Has roughly the last tier, so O(bC*/ε)

▪ Is it complete?

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 24: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?▪ Processes all nodes with cost less than cheapest solution!▪ If that solution costs C* and arcs cost at least ε , then the

“effective depth” is roughly C*/ε▪ Takes time O(bC*/ε) (exponential in effective depth)

▪ How much space does the fringe take?▪ Has roughly the last tier, so O(bC*/ε)

▪ Is it complete?▪ Assuming best solution has a finite cost and minimum arc cost

is positive, yes!

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 25: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?▪ Processes all nodes with cost less than cheapest solution!▪ If that solution costs C* and arcs cost at least ε , then the

“effective depth” is roughly C*/ε▪ Takes time O(bC*/ε) (exponential in effective depth)

▪ How much space does the fringe take?▪ Has roughly the last tier, so O(bC*/ε)

▪ Is it complete?▪ Assuming best solution has a finite cost and minimum arc cost

is positive, yes!

▪ Is it optimal?

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 26: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search (UCS) Properties

▪ What nodes does UCS expand?▪ Processes all nodes with cost less than cheapest solution!▪ If that solution costs C* and arcs cost at least ε , then the

“effective depth” is roughly C*/ε▪ Takes time O(bC*/ε) (exponential in effective depth)

▪ How much space does the fringe take?▪ Has roughly the last tier, so O(bC*/ε)

▪ Is it complete?▪ Assuming best solution has a finite cost and minimum arc cost

is positive, yes!

▪ Is it optimal?▪ Yes! (Proof next lecture via A*)

b

C*/ε “tiers”c ≤ 3

c ≤ 2

c ≤ 1

Page 27: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Infinite Search Tree

S G

b

a

Consider this 4-state graph:

▪ best solution may have an infinite cost (e.g ride a sightseeing train for as long as possible)

Page 28: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Infinite Search Tree

S G

b

a

Consider this 4-state graph: How big is its search tree (from S)?

▪ best solution may have an infinite cost (e.g ride a sightseeing train for as long as possible)

Page 29: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Infinite Search Tree

S G

b

a

Consider this 4-state graph: How big is its search tree (from S)?

▪ best solution may have an infinite cost (e.g ride a sightseeing train for as long as possible)

Page 30: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Today

▪ Informed Search ▪Heuristics

▪Greedy Search

▪ A* Search

▪ Graph Search

Page 31: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Recap: Search

Page 32: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Page 33: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Page 34: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Page 35: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Page 36: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Cost: Number of pancakes flipped

Page 37: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Page 38: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Page 39: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

3

2

4

3

3

2

2

2

4

State space graph with costs as weights

34

3

4

2

Page 40: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

General Tree Search

Page 41: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

General Tree Search

Page 42: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

General Tree Search

Page 43: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

General Tree Search

Action: flip top two

Cost: 2

Action: flip all fourCost: 4

Page 44: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

General Tree Search

Page 45: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

General Tree Search

Page 46: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

General Tree Search

Page 47: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

General Tree Search

Path to reach goal: Flip four, flip three

Total cost: 7

Page 48: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

The One Queue

▪ All these search algorithms are the same except for fringe strategies ▪ Conceptually, all fringes are priority

queues (i.e. collections of nodes with attached priorities)

▪ Practically, for DFS and BFS, you can avoid the log(n) overhead from an actual priority queue, by using stacks and queues

▪ Can even code one implementation that takes a variable queuing object

Page 49: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uninformed Search

Page 50: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Uniform Cost Search

▪ Strategy: expand lowest path cost

▪ The good: UCS is complete and optimal!

▪ The bad: ▪ Explores options in every “direction” ▪ No information about goal location

Start Goal

c ≤ 3

c ≤ 2

c ≤ 1

[Demo: contours UCS empty (L3D1)] [Demo: contours UCS pacman small maze (L3D3)]

Page 51: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours UCS Empty

Page 52: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours UCS Empty

Page 53: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours UCS Empty

Page 54: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours UCS Pacman Small Maze

Page 55: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours UCS Pacman Small Maze

Page 56: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours UCS Pacman Small Maze

Page 57: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Informed Search

Page 58: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Search Heuristics

Page 59: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Search Heuristics

▪ A heuristic is:▪ A function that estimates how close a state is to a

goal▪ Designed for a particular search problem

Page 60: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Search Heuristics

▪ A heuristic is:▪ A function that estimates how close a state is to a

goal▪ Designed for a particular search problem

Page 61: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Search Heuristics

▪ A heuristic is:▪ A function that estimates how close a state is to a

goal▪ Designed for a particular search problem

Page 62: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Search Heuristics

▪ A heuristic is:▪ A function that estimates how close a state is to a

goal▪ Designed for a particular search problem

Page 63: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Search Heuristics

▪ A heuristic is:▪ A function that estimates how close a state is to a

goal▪ Designed for a particular search problem▪ Examples: Manhattan distance, Euclidean distance

for pathing

Page 64: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Search Heuristics

▪ A heuristic is:▪ A function that estimates how close a state is to a

goal▪ Designed for a particular search problem▪ Examples: Manhattan distance, Euclidean distance

for pathing

10

5

Page 65: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Search Heuristics

▪ A heuristic is:▪ A function that estimates how close a state is to a

goal▪ Designed for a particular search problem▪ Examples: Manhattan distance, Euclidean distance

for pathing

11.2

Page 66: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

h(x)

Page 67: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Page 68: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic: (the size of) the largest pancake that is still out of place

Page 69: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic: (the size of) the largest pancake that is still out of place

43

0

2

3

3

3

4

4

3

4

4

4

h(x)

Page 70: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

Page 71: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

h(x)

Page 72: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

Page 73: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

Page 74: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

Page 75: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

Page 76: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

▪ Expand the node that seems closest…

Greedy Search

Page 77: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

Page 78: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

Page 79: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

Page 80: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

Page 81: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

Page 82: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

▪ Expand the node that seems closest…

▪ What can go wrong?

Page 83: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

▪ Expand the node that seems closest…

▪ What can go wrong?

Page 84: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

▪ Strategy: expand a node that you think is closest to a goal state▪ Heuristic: estimate of distance to nearest goal

for each state

…b

[Demo: contours greedy empty (L3D1)] [Demo: contours greedy pacman small maze (L3D4)]

Page 85: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

▪ Strategy: expand a node that you think is closest to a goal state▪ Heuristic: estimate of distance to nearest goal

for each state

▪ A common case:▪ Best-first takes you straight to the (wrong) goal

…b

[Demo: contours greedy empty (L3D1)] [Demo: contours greedy pacman small maze (L3D4)]

Page 86: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

▪ Strategy: expand a node that you think is closest to a goal state▪ Heuristic: estimate of distance to nearest goal

for each state

▪ A common case:▪ Best-first takes you straight to the (wrong) goal

▪ Worst-case: like a badly-guided DFS

…b

[Demo: contours greedy empty (L3D1)] [Demo: contours greedy pacman small maze (L3D4)]

Page 87: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Greedy Search

▪ Strategy: expand a node that you think is closest to a goal state▪ Heuristic: estimate of distance to nearest goal

for each state

▪ A common case:▪ Best-first takes you straight to the (wrong) goal

▪ Worst-case: like a badly-guided DFS

…b

…b

[Demo: contours greedy empty (L3D1)] [Demo: contours greedy pacman small maze (L3D4)]

Page 88: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours Greedy (Empty)

Page 89: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours Greedy (Empty)

Page 90: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours Greedy (Empty)

Page 91: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours Greedy (Pacman Small Maze)

Page 92: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours Greedy (Pacman Small Maze)

Page 93: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours Greedy (Pacman Small Maze)

Page 94: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Search

Page 95: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Search

Page 96: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Search

Page 97: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Search

UCS

Page 98: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Search

UCS Greedy

Page 99: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Search

UCS Greedy

A*

Page 100: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Combining UCS and Greedy

S a d

b

Gh=5

h=6

h=2

1

8

11

2

h=6 h=0

c

h=7

3

e h=11

Example: Teg Grenager

Page 101: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Combining UCS and Greedy

▪ Uniform-cost orders by path cost, or backward cost g(n)

S a d

b

Gh=5

h=6

h=2

1

8

11

2

h=6 h=0

c

h=7

3

e h=11

Example: Teg Grenager

Page 102: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Combining UCS and Greedy

▪ Uniform-cost orders by path cost, or backward cost g(n)

S a d

b

Gh=5

h=6

h=2

1

8

11

2

h=6 h=0

c

h=7

3

e h=11

Example: Teg Grenager

Page 103: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Combining UCS and Greedy

▪ Uniform-cost orders by path cost, or backward cost g(n)

S a d

b

Gh=5

h=6

h=2

1

8

11

2

h=6 h=0

c

h=7

3

e h=11

Example: Teg Grenager

Page 104: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Combining UCS and Greedy

▪ Uniform-cost orders by path cost, or backward cost g(n)▪ Greedy orders by goal proximity, or forward cost h(n)

S a d

b

Gh=5

h=6

h=2

1

8

11

2

h=6 h=0

c

h=7

3

e h=11

Example: Teg Grenager

Page 105: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Combining UCS and Greedy

▪ Uniform-cost orders by path cost, or backward cost g(n)▪ Greedy orders by goal proximity, or forward cost h(n)

S a d

b

Gh=5

h=6

h=2

1

8

11

2

h=6 h=0

c

h=7

3

e h=11

Example: Teg Grenager

Page 106: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Combining UCS and Greedy

▪ Uniform-cost orders by path cost, or backward cost g(n)▪ Greedy orders by goal proximity, or forward cost h(n)

S a d

b

Gh=5

h=6

h=2

1

8

11

2

h=6 h=0

c

h=7

3

e h=11

Example: Teg Grenager

Page 107: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Combining UCS and Greedy

▪ Uniform-cost orders by path cost, or backward cost g(n)▪ Greedy orders by goal proximity, or forward cost h(n)

▪ A* Search orders by the sum: f(n) = g(n) + h(n)

S a d

b

Gh=5

h=6

h=2

1

8

11

2

h=6 h=0

c

h=7

3

e h=11

Example: Teg Grenager

Page 108: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

When should A* terminate?

S

B

A

G

2

3

2

2h = 1

h = 2

h = 0h = 3

Page 109: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

When should A* terminate?

▪ Should we stop when we enqueue a goal?

▪ No: only stop when we dequeue a goal

S

B

A

G

2

3

2

2h = 1

h = 2

h = 0h = 3

Page 110: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Is A* Optimal?

▪ What went wrong?

A

GS

1 3h = 6

h = 05

h = 7

Page 111: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Is A* Optimal?

▪ What went wrong?▪ Actual bad goal cost < estimated good goal cost

A

GS

1 3h = 6

h = 05

h = 7

Page 112: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Is A* Optimal?

▪ What went wrong?▪ Actual bad goal cost < estimated good goal cost▪ We need estimates to be less than actual costs!

A

GS

1 3h = 6

h = 05

h = 7

Page 113: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Admissible Heuristics

Page 114: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Idea: Admissibility

Inadmissible (pessimistic) heuristics break optimality by trapping good plans on the

fringe

Admissible (optimistic) heuristics slow down bad plans but never outweigh true

costs

Page 115: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Admissible Heuristics

▪ A heuristic h is admissible (optimistic) if:

where is the true cost to a nearest goal

Page 116: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Admissible Heuristics

▪ A heuristic h is admissible (optimistic) if:

where is the true cost to a nearest goal

▪ Examples:

Page 117: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Admissible Heuristics

▪ A heuristic h is admissible (optimistic) if:

where is the true cost to a nearest goal

▪ Examples:

15

Page 118: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Admissible Heuristics

▪ A heuristic h is admissible (optimistic) if:

where is the true cost to a nearest goal

▪ Examples:4

15

Page 119: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Admissible Heuristics

▪ A heuristic h is admissible (optimistic) if:

where is the true cost to a nearest goal

▪ Examples:

▪ Coming up with admissible heuristics is most of what’s involved in using A* in practice.

415

Page 120: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search

Page 121: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search

Assume: ▪ A is an optimal goal node ▪ B is a suboptimal goal node ▪ h is admissible

Claim:

▪ A will exit the fringe before B

Page 122: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof:…

Page 123: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof:▪ Imagine B is on the fringe

Page 124: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof:▪ Imagine B is on the fringe

Page 125: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof:▪ Imagine B is on the fringe▪ Some ancestor n of A is on the

fringe, too (maybe A!)

Page 126: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof:▪ Imagine B is on the fringe▪ Some ancestor n of A is on the

fringe, too (maybe A!)

Page 127: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof:▪ Imagine B is on the fringe▪ Some ancestor n of A is on the

fringe, too (maybe A!)▪ Claim: n will be expanded

before B

Page 128: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof:▪ Imagine B is on the fringe▪ Some ancestor n of A is on the

fringe, too (maybe A!)▪ Claim: n will be expanded

before B

Page 129: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof:▪ Imagine B is on the fringe▪ Some ancestor n of A is on the

fringe, too (maybe A!)▪ Claim: n will be expanded

before B1. f(n) is less or equal to f(A)

Page 130: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof:▪ Imagine B is on the fringe▪ Some ancestor n of A is on the

fringe, too (maybe A!)▪ Claim: n will be expanded

before B1. f(n) is less or equal to f(A)

Definition of f-costAdmissibility of hh = 0 at a goal

Page 131: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof: ▪ Imagine B is on the fringe ▪ Some ancestor n of A is on the

fringe, too (maybe A!) ▪ Claim: n will be expanded

before B 1. f(n) is less or equal to f(A) 2. f(A) is less than f(B)

B is suboptimalh = 0 at a goal

Page 132: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Tree Search: Blocking

Proof: ▪ Imagine B is on the fringe ▪ Some ancestor n of A is on the

fringe, too (maybe A!) ▪ Claim: n will be expanded before B

1. f(n) is less or equal to f(A) 2. f(A) is less than f(B) 3. n expands before B

▪ All ancestors of A expand before B ▪ A expands before B ▪ A* search is optimal

Page 133: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Properties of A*

Page 134: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Properties of A*

…b

…b

Uniform-Cost A*

Page 135: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

UCS vs A* Contours

▪ Uniform-cost expands equally in all “directions”

▪ A* expands mainly toward the goal, but does hedge its bets to ensure optimality

Start Goal

Start Goal

[Demo: contours UCS / greedy / A* empty (L3D1)] [Demo: contours A* pacman small maze (L3D5)]

Page 136: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours (Empty) -- UCS

Page 137: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours (Empty) -- UCS

Page 138: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours (Empty) -- UCS

Page 139: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours (Empty) -- Greedy

Page 140: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours (Empty) -- Greedy

Page 141: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours (Empty) -- Greedy

Page 142: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours (Empty) – A*

Page 143: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours (Empty) – A*

Page 144: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo Contours (Empty) – A*

Page 145: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Applications

▪ Video games ▪ Pathing / routing problems ▪ Resource planning problems ▪ Robot motion planning ▪ Language analysis ▪ Machine translation ▪ Speech recognition ▪ …

[Demo: UCS / A* pacman tiny maze (L3D6,L3D7)] [Demo: guess algorithm Empty Shallow/Deep (L3D8)]

Page 146: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo (Empty Shallow/Deep) -- UCS

Page 147: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo (Empty Shallow/Deep) -- UCS

Page 148: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo (Empty Shallow/Deep) — Greedy

Page 149: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo (Empty Shallow/Deep) — Greedy

Page 150: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo (Empty Shallow/Deep) — A*

Page 151: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Video of Demo (Empty Shallow/Deep) — A*

Page 152: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Creating Heuristics

Page 153: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Creating Admissible Heuristics

▪ Most of the work in solving hard search problems optimally is in coming up with admissible heuristics

Page 154: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Creating Admissible Heuristics

▪ Most of the work in solving hard search problems optimally is in coming up with admissible heuristics

▪ Often, admissible heuristics are solutions to relaxed problems, where new actions are available

366

Page 155: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Creating Admissible Heuristics

▪ Most of the work in solving hard search problems optimally is in coming up with admissible heuristics

▪ Often, admissible heuristics are solutions to relaxed problems, where new actions are available

15366

Page 156: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Creating Admissible Heuristics

▪ Most of the work in solving hard search problems optimally is in coming up with admissible heuristics

▪ Often, admissible heuristics are solutions to relaxed problems, where new actions are available

▪ Inadmissible heuristics are often useful too

15366

Page 157: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: 8 Puzzle

▪ What are the states? ▪ How many states? ▪ What are the actions? ▪ How many successors from the start state? ▪ What should the costs be?

Start State Goal StateActions

Page 158: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle I

▪ Heuristic: Number of tiles misplaced

Start State Goal State

Page 159: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle I

▪ Heuristic: Number of tiles misplaced▪ Why is it admissible?

Start State Goal State

Page 160: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle I

▪ Heuristic: Number of tiles misplaced▪ Why is it admissible?▪ h(start) =

Start State Goal State

Page 161: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle I

▪ Heuristic: Number of tiles misplaced▪ Why is it admissible?▪ h(start) =8

Start State Goal State

Page 162: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle I

▪ Heuristic: Number of tiles misplaced▪ Why is it admissible?▪ h(start) =8

Average nodes expanded when the optimal path has……4 steps …8 steps …12 steps

UCS 112 6,300 3.6 x 106

TILES 13 39 227

Start State Goal State

Statistics from Andrew Moore

Page 163: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle I

▪ Heuristic: Number of tiles misplaced▪ Why is it admissible?▪ h(start) =▪ This is a relaxed-problem heuristic

8

Average nodes expanded when the optimal path has……4 steps …8 steps …12 steps

UCS 112 6,300 3.6 x 106

TILES 13 39 227

Start State Goal State

Statistics from Andrew Moore

Page 164: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle I

▪ Heuristic: Number of tiles misplaced▪ Why is it admissible?▪ h(start) =▪ This is a relaxed-problem heuristic

8

Average nodes expanded when the optimal path has……4 steps …8 steps …12 steps

UCS 112 6,300 3.6 x 106

TILES 13 39 227

Start State Goal State

Statistics from Andrew Moore

Page 165: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle II

▪ What if we had an easier 8-puzzle where any tile could slide any direction at any time, ignoring other tiles?

Start State Goal State

Page 166: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle II

▪ What if we had an easier 8-puzzle where any tile could slide any direction at any time, ignoring other tiles?

▪ Total Manhattan distanceStart State Goal State

Page 167: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle II

▪ What if we had an easier 8-puzzle where any tile could slide any direction at any time, ignoring other tiles?

▪ Total Manhattan distance

▪ Why is it admissible?

Start State Goal State

Page 168: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle II

▪ What if we had an easier 8-puzzle where any tile could slide any direction at any time, ignoring other tiles?

▪ Total Manhattan distance

▪ Why is it admissible?

▪ h(start) =

Start State Goal State

Page 169: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle II

▪ What if we had an easier 8-puzzle where any tile could slide any direction at any time, ignoring other tiles?

▪ Total Manhattan distance

▪ Why is it admissible?

▪ h(start) = 3 + 1 + 2 + … = 18

Start State Goal State

Page 170: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle II

▪ What if we had an easier 8-puzzle where any tile could slide any direction at any time, ignoring other tiles?

▪ Total Manhattan distance

▪ Why is it admissible?

▪ h(start) = 3 + 1 + 2 + … = 18Average nodes expanded when the optimal path has……4 steps …8 steps …12 steps

TILES 13 39 227MANHATTAN 12 25 73

Start State Goal State

Page 171: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle III

▪ How about using the actual cost as a heuristic?▪ Would it be admissible?▪ Would we save on nodes expanded?▪ What’s wrong with it?

Page 172: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle III

▪ How about using the actual cost as a heuristic?▪ Would it be admissible?▪ Would we save on nodes expanded?▪ What’s wrong with it?

▪ With A*: a trade-off between quality of estimate and work per node

Page 173: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle III

▪ How about using the actual cost as a heuristic?▪ Would it be admissible?▪ Would we save on nodes expanded?▪ What’s wrong with it?

▪ With A*: a trade-off between quality of estimate and work per node

Page 174: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

8 Puzzle III

▪ How about using the actual cost as a heuristic?▪ Would it be admissible?▪ Would we save on nodes expanded?▪ What’s wrong with it?

▪ With A*: a trade-off between quality of estimate and work per node▪ As heuristics get closer to the true cost, you will expand fewer nodes but

usually do more work per node to compute the heuristic itself

Page 175: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Semi-Lattice of Heuristics

Page 176: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Trivial Heuristics, Dominance

▪ Dominance: ha ≥ hc if

▪ Heuristics form a semi-lattice: ▪ Max of admissible heuristics is admissible

▪ Trivial heuristics ▪ Bottom of lattice is the zero heuristic

(what does this give us?) ▪ Top of lattice is the exact heuristic

Page 177: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Graph Search

Page 178: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

▪ Failure to detect repeated states can cause exponentially more work.

Search TreeState Graph

Tree Search: Extra Work!

Page 179: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

▪ Failure to detect repeated states can cause exponentially more work.

Search TreeState Graph

Tree Search: Extra Work!

Page 180: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Graph Search

▪ In BFS, for example, we shouldn’t bother expanding the circled nodes (why?)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Page 181: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Graph Search

▪ In BFS, for example, we shouldn’t bother expanding the circled nodes (why?)

S

a

b

d p

a

c

e

p

h

f

r

q

q c G

a

qe

p

h

f

r

q

q c G

a

Page 182: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Graph Search

▪ Idea: never expand a state twice

Page 183: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Graph Search

▪ Idea: never expand a state twice

▪ How to implement:

▪ Tree search + set of expanded states (“closed set”)▪ Expand the search tree node-by-node, but…▪ Before expanding a node, check to make sure its state has

never been expanded before▪ If not new, skip it, if new add to closed set

Page 184: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Graph Search

▪ Idea: never expand a state twice

▪ How to implement:

▪ Tree search + set of expanded states (“closed set”)▪ Expand the search tree node-by-node, but…▪ Before expanding a node, check to make sure its state has

never been expanded before▪ If not new, skip it, if new add to closed set

▪ Important: store the closed set as a set, not a list

Page 185: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Graph Search

▪ Idea: never expand a state twice

▪ How to implement:

▪ Tree search + set of expanded states (“closed set”)▪ Expand the search tree node-by-node, but…▪ Before expanding a node, check to make sure its state has

never been expanded before▪ If not new, skip it, if new add to closed set

▪ Important: store the closed set as a set, not a list

▪ Can graph search wreck completeness? Why/why not?

Page 186: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Graph Search

▪ Idea: never expand a state twice

▪ How to implement:

▪ Tree search + set of expanded states (“closed set”)▪ Expand the search tree node-by-node, but…▪ Before expanding a node, check to make sure its state has

never been expanded before▪ If not new, skip it, if new add to closed set

▪ Important: store the closed set as a set, not a list

▪ Can graph search wreck completeness? Why/why not?

▪ How about optimality?

Page 187: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Graph Search Gone Wrong?

S

A

B

C

G

1

1

1

23

State space graph

Page 188: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Graph Search Gone Wrong?

S

A

B

C

G

1

1

1

23

h=2

h=1

h=4

h=1

h=0

State space graph

Page 189: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Graph Search Gone Wrong?

S

A

B

C

G

1

1

1

23

h=2

h=1

h=4

h=1

h=0

S (0+2)

State space graph Search tree

Page 190: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Graph Search Gone Wrong?

S

A

B

C

G

1

1

1

23

h=2

h=1

h=4

h=1

h=0

S (0+2)

A (1+4) B (1+1)

State space graph Search tree

Page 191: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Graph Search Gone Wrong?

S

A

B

C

G

1

1

1

23

h=2

h=1

h=4

h=1

h=0

S (0+2)

A (1+4) B (1+1)

C (3+1)

State space graph Search tree

Page 192: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Graph Search Gone Wrong?

S

A

B

C

G

1

1

1

23

h=2

h=1

h=4

h=1

h=0

S (0+2)

A (1+4) B (1+1)

C (3+1)

G (6+0)

State space graph Search tree

Page 193: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Graph Search Gone Wrong?

S

A

B

C

G

1

1

1

23

h=2

h=1

h=4

h=1

h=0

S (0+2)

A (1+4) B (1+1)

C (2+1) C (3+1)

G (6+0)

State space graph Search tree

Page 194: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A* Graph Search Gone Wrong?

S

A

B

C

G

1

1

1

23

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

Page 195: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Consistency of Heuristics

3

A

C

G

h=4 h=11

Page 196: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Consistency of Heuristics

▪ Main idea: estimated heuristic costs ≤ actual costs

▪ Admissibility: heuristic cost ≤ actual cost to goal h(A) ≤ actual cost from A to G ▪ Consistency: heuristic “arc” cost ≤ actual cost for each arc h(A) – h(C) ≤ cost(A to C)

3

A

C

G

h=4 h=11

Page 197: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Consistency of Heuristics

▪ Main idea: estimated heuristic costs ≤ actual costs

▪ Admissibility: heuristic cost ≤ actual cost to goal h(A) ≤ actual cost from A to G ▪ Consistency: heuristic “arc” cost ≤ actual cost for each arc h(A) – h(C) ≤ cost(A to C)

3

A

C

G

h=4 h=11

Page 198: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Consistency of Heuristics

▪ Main idea: estimated heuristic costs ≤ actual costs

▪ Admissibility: heuristic cost ≤ actual cost to goal h(A) ≤ actual cost from A to G ▪ Consistency: heuristic “arc” cost ≤ actual cost for each arc h(A) – h(C) ≤ cost(A to C)

▪ Consequences of consistency:

▪ The f value along a path never decreases h(A) ≤ cost(A to C) + h(C)

▪ A* graph search is optimal

3

A

C

G

h=4 h=11

Page 199: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Consistency of Heuristics

▪ Main idea: estimated heuristic costs ≤ actual costs

▪ Admissibility: heuristic cost ≤ actual cost to goal h(A) ≤ actual cost from A to G ▪ Consistency: heuristic “arc” cost ≤ actual cost for each arc h(A) – h(C) ≤ cost(A to C)

▪ Consequences of consistency:

▪ The f value along a path never decreases h(A) ≤ cost(A to C) + h(C)

▪ A* graph search is optimal

3

A

C

G

h=4 h=11

h=1

Page 200: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Graph Search

Page 201: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality of A* Graph Search

▪ Sketch: consider what A* does with a consistent heuristic:

▪ Fact 1: In tree search, A* expands nodes in increasing total f value (f-contours)

▪ Fact 2: For every state s, nodes that reach s optimally are expanded before nodes that reach s suboptimally

▪ Result: A* graph search is optimal

f ≤ 3

f ≤ 2

f ≤ 1

Page 202: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Optimality

▪ Tree search: ▪ A* is optimal if heuristic is admissible ▪ UCS is a special case (h = 0)

▪ Graph search: ▪ A* optimal if heuristic is consistent ▪ UCS optimal (h = 0 is consistent)

▪ Consistency implies admissibility

▪ In general, most natural admissible heuristics tend to be consistent, especially if from relaxed problems

Page 203: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

A*: Summary

▪ A* uses both backward costs and (estimates of) forward costs

▪ A* is optimal with admissible / consistent heuristics

▪ Heuristic design is key: often use relaxed problems

Page 204: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Tree Search Pseudo-Code

Page 205: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Graph Search Pseudo-Code

Page 206: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Page 207: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Page 208: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Page 209: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Page 210: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

Cost: Number of pancakes flipped

Page 211: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Pancake Problem

3

2

4

3

3

2

2

2

4

State space graph with costs as weights

34

3

4

2

Page 212: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Page 213: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic ha: the largest pancake that is still out of place

Page 214: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic ha: the largest pancake that is still out of place

43

0

2

3

3

3

4

4

3

4

4

4

h(x)

Page 215: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic ha: the largest pancake that is still out of place

43

0

2

3

3

3

4

4

3

4

4

4

h(x)

ha is admissible, because putting the pancake i into place has a cost of at least i.

Page 216: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Page 217: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic hc: the number of the pancake that is still out of place

Page 218: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic hc: the number of the pancake that is still out of place

42

0

2

3

2

3

3

2

3

4

3

3

h(x)

Page 219: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic hc: the number of the pancake that is still out of place

42

0

2

3

2

3

3

2

3

4

3

3

h(x)

hc is admissible, because a flip of size k can put at most put k pancakes into position.

Page 220: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Page 221: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic hd: one less than the size of the pancake at the top

Page 222: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic hd: one less than the size of the pancake at the top

32

0

1

2

0

1

2

3

2

1

3

0

h(x)

Page 223: A* Search, Graph Search, Their Completeness and Optimality · A* Search, Graph Search, Their Completeness and Optimality Instructor: Wei Xu Ohio State University [These slides were

Example: Heuristic Function

Heuristic hd: one less than the size of the pancake at the top

32

0

1

2

0

1

2

3

2

1

3

0

h(x)

hd is admissible, because of the size of flip needed to move the top pancake into position.