CS 312: Algorithm Design & Analysis Lecture #37: A* (cont.); Admissible Heuristics Credit: adapted...
-
Upload
avice-jennings -
Category
Documents
-
view
215 -
download
2
Transcript of CS 312: Algorithm Design & Analysis Lecture #37: A* (cont.); Admissible Heuristics Credit: adapted...
CS 312: Algorithm Design & Analysis
Lecture #37: A* (cont.); Admissible Heuristics
Credit: adapted from slides by Stuart Russell of UC Berkeley.
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Announcements
Project #7: TSP Whiteboard: due today Early: next Wednesday (4/8) Due: next Friday (4/10)
Competition (“The Bake-Off”) Big 3 problems in the Competition set survey 3 problems in the One-Time Competition set survey
Hall of Fame (Bake-Off results) presented last day of class (4/13)
Optional: Cookie Bake-Off Bring to final exam A bit of extra HW credit for winning this bake-off
Objectives
Prove the optimality of A*
Understand Admissible Heuristics
Revisit the idea of “Relaxed Problems” more deeply
Search algorithms
A. Beam Search
Q. How could you change A* or B&B to be more memory efficient?
Various forms of Beam search: Agenda size Threshold from best
Sacrifices guarantees of optimality
Theorem
If is admissible, then A* is optimal
Proof of Optimality of A*
Suppose some sub-optimal goal state G2 has been generated and is on the agenda. Let n be an unexpanded state on the agenda such that n is on a shortest (optimal) path to the optimal goal state G. Assume h() is admissible.
Focus on G2:
f(G2) = g(G2) since h(G2) = 0
g(G2) > g(G) since G2 is suboptimal
Proof of Optimality of A*
Suppose some sub-optimal goal state G2 has been generated and is on the agenda. Let n be an unexpanded state on the agenda such that n is on a shortest (optimal) path to the optimal goal state G. Assume h() is admissible.
f(G2) = g(G2) since h(G2) = 0
g(G2) > g(G) since G2 is suboptimal
Focus on G:
f(G) = g(G) since h(G) = 0
f(G2) > f(G) substitution
Proof of Optimality of A*
Suppose some sub-optimal goal state G2 has been generated and is on the agenda. Let n be an unexpanded state on the agenda such that n is on a shortest (optimal) path to the optimal goal state G. Assume h() is admissible.
Now focus on n:
h(n) ≤ h*(n) since h is admissible
g(n) + h(n) ≤ g(n) + h*(n) algebra
f(n) = g(n) + h(n) definition
f(G) = g(n) + h*(n) by assumption
f(n) ≤ f(G) substitution
Hence f(G2) > f(n), and A* will never select G2 for expansion.
f(G2) = g(G2) since h(G2) = 0
g(G2) > g(G) since G2 is suboptimal
f(G) = g(G) since h(G) = 0
f(G2) > f(G) substitution
Optimality of A*
A* expands states in order of increasing f value Gradually adds "f-contours" of states
Like Uniform cost search, but more directed!
Contour i has all states with f=fi, where fi < fi+1
Solving the 8-puzzle with A*
states? actions? goal test? path cost g(n)?
Example: The 8-puzzle
states? locations of tiles actions? move blank left, right, up, down goal test? = goal state (given) path cost g(n)? 1 per move
Example: The 8-puzzle
What does the state space look like? How deep? Note: optimal solution of n-Puzzle family is NP-
hard Not known to be in NP
Admissible heuristics?
Admissible heuristics?
total pieces out of place manhattan distance(blank, g_blank) (or other norm) optimal solution to problem with w/ 2 blanks (possibly solved
recursively by A*!) look-up in pattern database if goal; 1 otherwise total manhattan distance x 2 (-1) if blank involved total of: optimal number of moves between any two locations on
board # of pieces lower and after me
Relaxed problems A problem with fewer restrictions is called a
relaxed problem
Theorem:The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem E.g., our bound function for TSP
Relaxed problems
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
Admissible heuristics
E.g., for the 8-puzzle: h1(n) = number of misplaced tiles h2(n) = total Manhattan distance (i.e., no. of squares from desired location of each tile)
h1(S) = ? h2(S) = ?
Admissible heuristics
E.g., for the 8-puzzle: h1(n) = number of misplaced tiles h2(n) = total Manhattan distance (i.e., no. of squares from desired location of each tile)
h1(S) = ? 8 h2(S) = ? 3+1+2+2+2+3+3+2 = 18
Dominance; i.e. Tighter Bounds If h2(n) ≥ h1(n) for all n (both admissible)
then h2 dominates h1 h2 is better for search
Typical search costs (average number of states expanded) for d-puzzle:
d=11 (3x4)Iterative Deepening Search (IDS) = 3,644,035 statesA*(h1) = 227 states A*(h2) = 73 states
d=24 (5 x 5)IDS = too many statesA*(h1) = 39,135 states A*(h2) = 1,641 states
Compare and Contrast
A* vs. Branch & Bound Reasoning about an admissible heuristic in A*
is like reasoning about optimistic bounds in B&B
A* doesn’t include a BSSF Thus, B&B is potentially more memory
efficient
Assignment
HW #28