200 likes | 293 Views
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. CS 312: Algorithm Analysis. Lecture #37: A* (cont.); Admissible Heuristics. Credit : adapted from slides by Stuart Russell of UC Berkeley. Announcements. Homework #27 due today Project #7: TSP
E N D
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. CS 312: Algorithm Analysis Lecture #37: A* (cont.); Admissible Heuristics Credit: adapted from slides by Stuart Russell of UC Berkeley.
Announcements • Homework #27 due today • Project #7: TSP • Early: today • Due: Friday! • Competition (“The Bake-Off”) • Big 3 problems in the “Competition” survey • Open categories: • #1: parallel implementations • #2: B&B without time bounds • #3: non B&B • Also required: “Competition Test Set” survey • Submit only once to this survey • Hall of Fame (Bake-Off results) presented next Monday • Also: Cookie Bake-Off on day of final
Objectives • Prove the optimality of A* • Understand Admissible Heuristics • Revisit the idea of “Relaxed Problems” more deeply
Theorem • If h(n) is admissible, then A* is optimal
Proof of Optimality of A* • Suppose some sub-optimal goal state G2has 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 f(G) = g(G) since h(G) = 0 f(G2) > f(G) substitution
Proof of Optimality of A* • Suppose some sub-optimal goal state G2has 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 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 Hence f(G2) > f(n), and A* will never select G2 for expansion.
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
Example: The 8-puzzle • states? • actions? • goal test? • path cost? What does the state space look like? How deep?
Example: The 8-puzzle • states?locations of tiles • actions?move blank left, right, up, down • goal test?= goal state (given) • path cost? 1 per move
Example: The 8-puzzle • Note: optimal solution of n-Puzzle family is NP-hard • Not known to be in NP
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
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
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
Dominance; i.e. Tighter Bounds • If h2(n) ≥ h1(n) for all n (both admissible) • then h2dominatesh1 • h2is better for search • Typical search costs (average number of states expanded) for d-puzzle: • d=12 (3x4 ?) Iterative Deepening Search (IDS) = 3,644,035 states A*(h1) = 227 states A*(h2) = 73 states • d=24 (4 x 6?) IDS = too many states A*(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 • How could you change A* or B&B to be more memory efficient? • Various forms of Beam search
Assignment No more homework Finish Project #7! Reading: local search