today ce 473 artificial intelligence spring 2015
play

Today CE 473: Artificial Intelligence Spring 2015 A* Search A* - PDF document

4/7/15 Today CE 473: Artificial Intelligence Spring 2015 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


  1. 4/7/15 Today CE 473: Artificial Intelligence Spring 2015 § 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 Recap: Search Example: Pancake Problem § Search problem: Action: Flip over the § States (configurations of the world) top n pancakes § Successor function: a function from states to lists of (state, action, cost) triples; drawn as a graph § Start state and goal test § Search tree: § Nodes: represent plans for reaching states § Plans have costs (sum of action costs) § Search Algorithm: § Systematically builds a search tree Cost: Number of pancakes flipped § Chooses an ordering of the fringe (unexplored nodes) Example: Pancake Problem Example: Pancake Problem State space graph with costs as weights 4 2 3 2 3 4 3 4 2 3 2 2 3 4 3 1

  2. 4/7/15 General Tree Search Example: Heuristic Function Heuristic: the largest pancake that is still out of place 3 h(x) 4 3 4 Action: flip top 3 0 Action: flip all four Path to reach goal: two Cost: 4 Flip four, flip three Cost: 2 4 Total cost: 7 4 3 4 4 2 3 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 2

  3. 4/7/15 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 ¡ A 2 2 e ¡ h=1 ¡ g ¡= ¡1 ¡h=5 ¡ 1 ¡ a ¡ h = 2 G 1 ¡ 3 ¡ 2 ¡ S h = 3 g ¡= ¡9 ¡h=1 ¡ S ¡ a ¡ d ¡ G ¡ 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 § Examples: 5 15 4 § 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! 3

  4. 4/7/15 OpFmality ¡of ¡A* ¡Tree ¡Search ¡ OpFmality ¡of ¡A* ¡Tree ¡Search ¡ Proof: ¡ Assume: ¡ … § Imagine ¡B ¡is ¡on ¡the ¡fringe ¡ § A ¡is ¡an ¡opFmal ¡goal ¡node ¡ … § B ¡is ¡a ¡subopFmal ¡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 ¡ DefiniFon ¡of ¡f-­‑cost ¡ Admissibility ¡of ¡h ¡ h ¡= ¡0 ¡at ¡a ¡goal ¡ OpFmality ¡of ¡A* ¡Tree ¡Search ¡ OpFmality ¡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 ¡ § Some ¡ancestor ¡ n ¡of ¡A ¡is ¡on ¡the ¡ fringe, ¡too ¡(maybe ¡A!) ¡ fringe, ¡too ¡(maybe ¡A!) ¡ § Claim: ¡ n ¡will ¡be ¡expanded ¡ § Claim: ¡ n ¡will ¡be ¡expanded ¡ before ¡B ¡ 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 ¡subopFmal ¡ § All ¡ancestors ¡of ¡A ¡expand ¡ h ¡= ¡0 ¡at ¡a ¡goal ¡ before ¡B ¡ § A ¡expands ¡before ¡B ¡ § A* ¡search ¡is ¡opFmal ¡ 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 4

  5. 4/7/15 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 + … = 18 § Is it admissible? 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 TILES UCS 112 6,300 3.6 x 10 6 13 39 227 § Admissible? TILES 13 39 227 MANHATTAN 12 25 73 5

  6. 4/7/15 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 a § How about optimality? 6

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend