CS 188: Artificial Intelligence Spring 2007 Lecture 4: A* Search Srini Narayanan – ICSI and UC Berkeley Many slides over the course adapted from Dan Klein, Stuart Russell and Andrew Moore PDF created with pdfFactory Pro trial version www.pdffactory.com
Announcements § Submission of Assignment 1 § Submit program should be updated by today § Use submit hw1 for this assignment § Enrollment issues PDF created with pdfFactory Pro trial version www.pdffactory.com
Today § A* Search § Heuristic Design § Local Search PDF created with pdfFactory Pro trial version www.pdffactory.com
Recap: Search § Search problems: § States, successors, costs, start and goal tests § Search trees: § Nodes: represent paths, have costs § Strategies differing fringe management § Tree vs. graph search PDF created with pdfFactory Pro trial version www.pdffactory.com
Uniform Cost: Problems § Remember: explores c ≤ 1 … increasing cost contours c ≤ 2 c ≤ 3 § The good: UCS is complete and optimal! § The bad: § Explores options in every “direction” § No information about goal location Start Goal PDF created with pdfFactory Pro trial version www.pdffactory.com
Best-First / Greedy Search PDF created with pdfFactory Pro trial version www.pdffactory.com
Best-First / Greedy Search § Expand the node that seems closest… § What can go wrong? PDF created with pdfFactory Pro trial version www.pdffactory.com
Best-First / Greedy Search GOAL a 2 2 h=0 h=8 c b 2 5 h=4 h=5 1 8 h=11 2 e d 3 f 9 1 h=8 9 h=4 START h 4 5 h=6 1 h=12 4 3 p r 15 q h=11 h=6 h=9 PDF created with pdfFactory Pro trial version www.pdffactory.com
Best-First / Greedy Search § A common case: b … § Best-first takes you straight to the goal on a wrong path § Worst-case: like a badly- guided DFS in the worst case § Can explore everything § Can get stuck in loops if no b cycle checking … § Like DFS in completeness (finite states w/ cycle checking) PDF created with pdfFactory Pro trial version www.pdffactory.com
Best First Greedy Search Algorithm Complete Optimal Time Space Greedy Best-First O( b m ) O( b m ) Y* N Search b … m § What do we need to do to make it complete? § Can we make it optimal? PDF created with pdfFactory Pro trial version www.pdffactory.com
Combining UCS and Greedy § Uniform-cost orders by path cost, or backward cost g(n) § Best-first orders by goal proximity, or forward cost h(n) 5 h=1 e 1 1 3 2 S a d G h=5 2 1 h=6 h=2 h=0 1 b c h=5 h=4 § A* Search orders by the sum: f(n) = g(n) + h(n) Example: Teg Grenager PDF created with pdfFactory Pro trial version www.pdffactory.com
When should A* terminate? § Should we stop when we enqueue a goal? A 2 1 h = 2 G S h = 3 h = 0 B 2 2 h = 1 § No: only stop when we dequeue a goal PDF created with pdfFactory Pro trial version www.pdffactory.com
Is A* Optimal? 1 A 3 h = 6 h = 0 S h = 7 G 5 § What went wrong? § Estimated goal cost > actual good goal cost § We need estimates to be less than actual costs! PDF created with pdfFactory Pro trial version www.pdffactory.com
Admissible Heuristics § A heuristic is admissible (optimistic) if: where is the true cost to a nearest goal § E.g. Euclidean distance on a map problem § Coming up with admissible heuristics is most of what’s involved in using A* in practice. PDF created with pdfFactory Pro trial version www.pdffactory.com
Optimality of A*: Blocking This proof assumed § Proof: tree search! Where? … § What could go wrong? § We’d have to have to pop a suboptimal goal off the fringe queue § This can’t happen: § Imagine a suboptimal goal G’ is on the queue § Consider any unexpanded (fringe) node n on a shortest path to optimal G § n will be popped before G PDF created with pdfFactory Pro trial version www.pdffactory.com
What to do with revisited states? c = 1 2 The heuristic h is h = 100 1 clearly admissible 2 1 90 100 0 PDF created with pdfFactory Pro trial version www.pdffactory.com
What to do with revisited states? c = 1 2 2+1 f = 1+100 h = 100 1 2 1 4+90 90 ? 100 104 0 I f we discar d t his new node, t hen t he sear ch algor it hm expands t he goal node next and r et ur ns a non-opt imal solut ion PDF created with pdfFactory Pro trial version www.pdffactory.com
What to do with revisited states? 1 2 2+1 1+100 100 1 2 1 2+90 4+90 90 100 102 104 0 I nst ead, if we do not discar d nodes r evisit ing st at es, t he sear ch t er minat es wit h an opt imal solut ion PDF created with pdfFactory Pro trial version www.pdffactory.com
Optimality of A*: Contours § Consider what A* does: § Expands nodes in increasing total f value (f-contours) § Proof idea: optimal goals have lower f value, so get expanded first Holds for graph search as well, but we made a different assumption. What? PDF created with pdfFactory Pro trial version www.pdffactory.com
Consistency § Wait, how do we know we expand in increasing f value? § Couldn’t we pop some node n , and find its child n’ to have lower f value? § YES: h = 0 h = 8 B 3 g = 10 G A h = 10 § What do we need to do to fix this? § Consistency: § Real cost always exceeds reduction in heuristic PDF created with pdfFactory Pro trial version www.pdffactory.com
Admissibility and Consistency § A consist ent heurist ic is also admissible [Lef t as an exercise] § An admissible heurist ic may not be consist ent , but many admissible heurist ics are consist ent PDF created with pdfFactory Pro trial version www.pdffactory.com
UCS vs A* Contours § Uniform-cost expanded in all directions Start Goal § A* expands mainly toward the goal, but does hedge its bets to ensure optimality Start Goal PDF created with pdfFactory Pro trial version www.pdffactory.com
Properties of A* Uniform-Cost A* b b … … PDF created with pdfFactory Pro trial version www.pdffactory.com
Admissible Heuristics § Most of the work is in coming up with admissible heuristics § Good news: usually admissible heuristics are also consistent § More good news: inadmissible heuristics are often quite effective (especially when you have no choice) § Very common hack: use α x h(n) for admissible h, α > 1 to generate a faster but less optimal inadmissible h’ PDF created with pdfFactory Pro trial version www.pdffactory.com
Example: 8-Puzzle § What are the states? § What are the actions? § What states can I reach from the start state? § What should the costs be? PDF created with pdfFactory Pro trial version www.pdffactory.com
8-Puzzle I § Number of tiles misplaced? § Why is it admissible? Average nodes expanded when 8 § h(start) = optimal path has length… …4 steps …8 steps …12 steps § This is a relaxed- 3.6 x 10 6 ID 112 6,300 problem heuristic TILES 13 39 227 PDF created with pdfFactory Pro trial version www.pdffactory.com
8-Puzzle II § What if we had an easier 8-puzzle where any tile could slide any one direction at any time? § Total Manhattan distance Average nodes expanded when § Why admissible? optimal path has length… …4 steps …8 steps …12 steps § h(start) = 3 + 1 + 2 + … TILES 13 39 227 MAN- 12 25 73 = 18 HATTAN PDF created with pdfFactory Pro trial version www.pdffactory.com
8-Puzzle III § How about using the actual cost as a heuristic? § Would it be admissible? § Would we save on nodes? § What’s wrong with it? § With A*, trade-off between quality of estimate and work per node! PDF created with pdfFactory Pro trial version www.pdffactory.com
Trivial Heuristics, Dominance § Dominance: § Heuristics form a semi-lattice: § Max of admissible heuristics is admissible § Trivial heuristics § Bottom of lattice is the zero heuristic (what does this give us?) § Top of lattice is the exact heuristic PDF created with pdfFactory Pro trial version www.pdffactory.com
Course Scheduling § From the university’s perspective: § Set of courses {c 1 , c 2 , … c n } § Set of room / times {r 1 , r 2 , … r n } § Each pairing (c k , r m ) has a cost w km § What’s the best assignment of courses to rooms? § States: list of pairings § Actions: add a legal pairing § Costs: cost of the new pairing § Admissible heuristics? PDF created with pdfFactory Pro trial version www.pdffactory.com
Other A* Applications § Pathing / routing problems § Resource planning problems § Robot motion planning § Language analysis § Machine translation § Speech recognition § … PDF created with pdfFactory Pro trial version www.pdffactory.com
Summary: A* § A* uses both backward costs and (estimates of) forward costs § A* is optimal with admissible heuristics § Heuristic design is key: often use relaxed problems PDF created with pdfFactory Pro trial version www.pdffactory.com
Recommend
More recommend