20
Lights Out Issues Questions? Comment from me 1

Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

Embed Size (px)

Citation preview

Page 1: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

Lights Out Issues

Questions?

Comment from me

1

Page 2: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

2

Section 3.6.4 – A* Search

A* Search employs search with

estimates of remaining distance

dynamic programming

Page 3: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search Premise - Avoid expanding paths that are already

expansive Evaluation function f(n) = g(n) + h(n)

g(n) = cost so far to reach nh(n) = estimated cost to goal from nf(n) = estimated total cost of path through n to goal

Page 4: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search A* search uses an admissible heuristic

i.e., h(n) h*(n) where h*(n) is the true cost from n.(also require h(n) 0, so h(G) = 0 for any goal G.)

example, hSLD(n) never overestimates the actual road distance.

Page 5: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

Romania with step costs in km

Page 6: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search exampleOpen List:

Arad

We start with our initial state Arad. We make a node and add it to the open list. Since it’s the only thing on the open list, we expand the node.

Think of the open list as a priority queue (or heap) that sorts the nodes inside of it according to their g()+h() score.

Page 7: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search exampleOpen List:

Sibiu

Timisoara

Zerind

We add the three nodes we found to the open list.

We sort them according to the g()+h() calculation.

Page 8: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search exampleOpen List:

Rimricu Vicea

Fagaras

Timisoara

Zerind

Arad

Oradea

When we expand Sibiu, we produce four additional nodes. These also are placed into the Open List in order based on the g()+h() calculation.

We see that Rimricu Vicea is at the top of the open list; so, it’s the next node we will expand.

Page 9: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search exampleOpen List:

Fagaras

Pitesti

Timisoara

Zerind

Craiova

Sibiu

Arad

Oradea

When we expand Rimricu Vicea, we produce three new nodes that are placed into the Open List.

Fagaras will be the next node we should expand – it’s at the top of the sorted open list.

Page 10: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search exampleOpen List:

Pitesti

Timisoara

Zerind

Bucharest

Craiova

Sibiu

Sibiu

Arad

Oradea

When we expand Fagaras, we produce two new nodes.

As humans we recognize that one of those is Bucharest. BUT REMEMBER, the computer doesn’t check a node until it comes OFF the Open List, not going in.

Therefore, Pitesti is the next best node.

Page 11: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search exampleOpen List:

Bucharest

Timisoara

Zerind

Bucharest

Craiova

Sibiu

Sibiu

Rimricu Vicea

Craiova

Arad

Oradea

Now it looks like Bucharest is at the top of the open list…

Now we “expand” the node for Bucharest.

We’re done! (And we know the path that we’ve found is optimal.)

Page 12: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search Properties of A*

Complete?? Yes, unless there are infinitely many nodes with f f(G)

Time?? Exponential in [relative error in h x length of solution.]

Space?? Keeps all nodes in memory Optimal?? Yes – cannot expand f i+1 until fi is

finishedA* expands all nodes with f(n) < C*A* expands some nodes with f(n) = C*A* expands no nodes with f(n) > C*

Page 13: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search A* algorithm

Optimality of A* (standard proof) Suppose some suboptimal goal G2 has been

generated and is in the queue. Let n be an unexpanded node on a shortest path to an optimal goal G1.

Page 14: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

A* search A* algorithm

f(G2) = g(G2) since h(G2) = 0 > g(G1) since G2 is suboptimal f(n) since h is admissible

since f(G2) > f(n), A* will never select G2 for expansion

Page 15: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

Heuristic Functions Admissible heuristic

example: for the 8-puzzle

h1(n) = number of misplaced tiles (Hamming Distance)h2(n) = total Manhattan distance i.e. no of squares from desired location of each tile

h1(S) = ??h2(S) = ??

Page 16: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

Heuristic Functions Admissible heuristic

example: for the 8-puzzle

h1(n) = number of misplaced tilesh2(n) = total Manhattan distance i.e. no of squares from desired location of each tile

h1(S) = ?? 6h2(S) = ?? 4+0+3+3+1+0+2+1 = 14

Page 17: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

Heuristic Functions Dominance

if h1(n) h2(n) for all n (both admissible)then h2 dominates h1 and is better for search

Typical search costs in the 8-puzzle problem:

d = 14 IDS = 3,473,941 nodes A*(h1) = 539 nodes

A*(h2) = 113 nodesd = 24 IDS 54,000,000,000 nodes A*(h1) = 39,135 nodes

A*(h2) = 1,641 nodes

Page 18: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

Heuristic Functions Admissible heuristic

example: for the 8-puzzle

h1(n) = number of misplaced tilesh2(n) = total Manhattan distance i.e. no of squares from desired location of each tile

h1(S) = ?? 6h2(S) = ?? 4+0+3+3+1+0+2+1 = 14

But how do you come up with a heuristic?

Page 19: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

Heuristic Functions Relaxed problems

Admissible heuristics can be derived from the exact solution cost of a relaxed version of the problem

If the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h1(n) gives the shortest solution

If the rules are relaxed so that a tile can move to any adjacent square, then h2(n) gives the shortest solution

Key point: the optimal solution cost of a relaxed problem is no greater than the optimal solution cost of the real problem

Page 20: Lights Out Issues Questions? Comment from me 1. 2 Section 3.6.4 – A* Search A* Search employs search with estimates of remaining distance dynamic programming

20

Section 3.7.3 – Bidirectional Search