10/2/17 Today CE 473: Artificial Intelligence Autumn 2017 § A* Search A* Search § Heuristic Design § Graph search Dieter Fox Based on slides from Pieter Abbeel & Dan Klein Multiple slides from Stuart Russell, Andrew Moore, Luke Zettlemoyer What is a Heuristic ? Example: Heuristic Function § An estimate of how close a state is to a goal § Designed for a particular search problem 10 5 11.2 § Examples: Manhattan distance: 10+5 = 15 Euclidean distance: 11.2 h(x) Greedy Search Best First (Greedy) § Strategy: expand a node b that you think is closest to … a goal state § Heuristic: estimate of distance to nearest goal for each state § A common case: b § Best-first takes you straight … to the (wrong) goal § Worst-case: like a badly- guided DFS 1
10/2/17 Greedy Search A* Search § Expand the node that seems closest… § What can go wrong? Combining UCS and Greedy When should A* terminate? § Uniform-cost orders by path cost, or backward cost g(n) § Should we stop when we enqueue a goal? § Greedy orders by goal proximity, or forward cost h(n) 8 g = 0 h=6 S 2 A 2 e h=1 g = 1 h=5 a 1 h = 2 1 3 2 G S h = 3 S a d G g = 9 h=1 g = 2 h=6 g = 4 b d e h=6 h=5 h = 0 1 h=2 h=2 h=0 B 3 1 2 c b g = 3 h=7 g = 6 g = 10 h=2 c G d h = 1 h=0 h=7 h=6 § No: only stop when we dequeue a goal g = 12 G h=0 § A* Search orders by the sum: f(n) = g(n) + h(n) Example: Teg Grenager Is A* Optimal? Admissible Heuristics 1 § A heuristic h is admissible (optimistic) if: A 3 h = 6 h = 0 where is the true cost to a nearest goal S h = 7 G § Example: 5 15 § What went wrong? § Actual bad goal cost < estimated good path cost § Coming up with admissible heuristics is most of § We need estimates to be less than or equal to what’s involved in using A* in practice. actual costs! 2
10/2/17 Optimality of A* Tree Search Optimality of A* Tree Search Proof: Assume: … § Imagine B is on the fringe § A is an optimal goal node … § B is a suboptimal goal node § Some ancestor n of A is on the fringe, too (maybe A!) § h is admissible § Claim: n will be expanded before B Claim: 1. f(n) is less or equal to f(A) § A will exit the fringe before B Definition of f-cost Admissibility of h h = 0 at a goal Optimality of A* Tree Search Optimality of A* Tree Search Proof: Proof: … … § Imagine B is on the fringe § Imagine B is on the fringe § Some ancestor n of A is on the fringe, § Some ancestor n of A is on the too (maybe A!) fringe, too (maybe A!) § Claim: n will be expanded before B § Claim: n will be expanded before B 1. f(n) is less or equal to f(A) 1. f(n) is less or equal to f(A) 2. f(A) is less than f(B) 2. f(A) is less than f(B) 3. n expands before B B is suboptimal § All ancestors of A expand before B [since n will put the next node n’ toward A on the h = 0 at a goal fringe; repeat claim for n’ until you hit A] § A expands before B § A* search is optimal UCS vs A* Contours Which Algorithm? § Uniform-cost expanded § Uniform cost search (UCS): in all directions Start Goal § A* expands mainly toward the goal, but hedges its bets to ensure optimality Start Goal 3
10/2/17 Which Algorithm? Which Algorithm? § A*, Manhattan Heuristic: § Best First / Greedy, Manhattan Heuristic: Creating Admissible Heuristics Creating Heuristics § Most of the work in solving hard search problems optimally is in coming up with admissible heuristics 8-puzzle: § Often, admissible heuristics are solutions to relaxed problems, where new actions are available 366 15 § What are the states? § How many states? § What are the actions? § Inadmissible heuristics are often useful too § What states can I reach from the start state? § What should the costs be? 8 Puzzle I 8 Puzzle II § What if we had an easier 8- § Heuristic: Number of puzzle where any tile could tiles misplaced slide any direction at any time, ignoring other tiles? § Total Manhattan distance § h(start) = 8 § h(start) = 3 + 1 + 2 + … § Is it admissible? = 18 Average nodes expanded when Average nodes expanded when optimal path has length… optimal path has length… …4 steps …8 steps …12 steps …4 steps …8 steps …12 steps 3.6 x 10 6 TILES UCS 112 6,300 13 39 227 § Admissible? MANHATTAN 12 TILES 13 39 227 25 73 4
10/2/17 8 Puzzle III Trivial Heuristics, Dominance § How about using the actual cost as a § Dominance: h a ≥ h c if heuristic? § Would it be admissible? § Heuristics form a semi-lattice: § Would we save on nodes expanded? § Max of admissible heuristics is admissible § What’s wrong with it? § With A*: a trade-off between quality of § Trivial heuristics estimate and work per node! § Bottom of lattice is the zero heuristic (what does this give us?) § Top of lattice is the exact heuristic A* Applications Tree Search: Extra Work! § Pathing / routing problems § Failure to detect repeated states can cause exponentially more work. Why? § Resource planning problems § Robot motion planning § Language analysis § Machine translation § Speech recognition § … Graph Search Graph Search § Idea: never expand a state twice § In BFS, for example, we shouldn’t bother expanding some nodes (which, and why?) § How to implement: § Tree search + set of expanded states (“closed set”) S § Expand the search tree node-by-node, but… e p § Before expanding a node, check to make sure its state has never d been expanded before q e h r b c § If not new, skip it, if new add to closed set a a h r p q f § Hint: in python, store the closed set as a set, not a list q c p q f G § Can graph search wreck completeness? Why/why not? a q c G § How about optimality? a 5
10/2/17 Consistency of Heuristics A* Graph Search Gone Wrong State space graph Search tree Main idea: estimated heuristic costs ≤ actual costs § A § Admissibility: heuristic cost ≤ actual cost to goal S (0+2) 1 A A C h=4 h=1 1 h(A) ≤ actual cost from A to G 1 h=4 h=2 A (1+4) B (1+1) h=3 S S C C § Consistency: heuristic “arc” cost ≤ actual cost for each arc h=1 1 h=2 h(A) – h(C) ≤ cost(A to C) 3 2 C (2+1) C (3+1) Consequences of consistency: 3 § B B § The f value along a path never decreases G (5+0) G (6+0) G h=1 h(A) ≤ cost(A to C) + h(C) G G f(A) = g(A) + h(A) ≤ g(A) + cost(A to C) + h(C) = f(C) h=0 § A* graph search is optimal Optimality of A* Graph Search Optimality § Tree search: § Sketch: consider what A* does with a consistent heuristic: § A* optimal if heuristic is admissible (and non-negative) § UCS is a special case (h = 0) § Nodes are popped with non-decreasing f- f ≤ 1 … scores: for all n, n’ with n’ popped after n : f ≤ 2 § Graph search: f(n’) ≥ f(n) f ≤ 3 § A* optimal if heuristic is consistent § Proof by induction: (1) always pop the lowest f- score from the fringe, (2) all new nodes have § UCS optimal (h = 0 is consistent) larger (or equal) scores, (3) add them to the fringe, (4) repeat! § For every state s, nodes that reach s § Consistency implies admissibility optimally are expanded before nodes that reach s sub-optimally § In general, natural admissible heuristics tend to be consistent, especially if from relaxed problems § Result: A* graph search is optimal Summary: A* § 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 6
Recommend
More recommend