cs 188 artificial intelligence
play

CS 188: Artificial Intelligence Search Continued Instructors: Anca - PowerPoint PPT Presentation

CS 188: Artificial Intelligence Search Continued Instructors: Anca Dragan University of California, Berkeley [These slides adapted from Dan Klein and Pieter Abbeel; ai.berkeley.edu] Recap: Search Depth-First (Tree) Search Breadth-First (Tree)


  1. CS 188: Artificial Intelligence Search Continued Instructors: Anca Dragan University of California, Berkeley [These slides adapted from Dan Klein and Pieter Abbeel; ai.berkeley.edu]

  2. Recap: Search

  3. Depth-First (Tree) Search

  4. Breadth-First (Tree) Search

  5. Iterative Deepening o Idea: get DFS’s space advantage with BFS’s time / shallow-solution b advantages … o Run a DFS with depth limit 1. If no solution… o Run a DFS with depth limit 2. If no solution… o Run a DFS with depth limit 3. ….. o Isn’t that wastefully redundant? o Generally most work happens in the lowest level searched, so not so bad!

  6. Cost-Sensitive Search G O a AL c b e d f ST AR h T p r q

  7. Cost-Sensitive Search G O a 2 2 AL c b 3 2 1 8 2 e d 3 f 9 8 2 ST AR h T 4 2 1 4 p r 15 q BFS finds the shortest path in terms of number of actions. How? It does not find the least-cost path. We will now cover a similar algorithm which does find the least-cost path.

  8. Uniform Cost Search

  9. Uniform Cost Search 2 G a Strategy: expand a c b 8 1 cheapest node first: 2 2 e 3 d f Fringe is a priority queue 9 2 8 S h (priority: cumulative cost) 1 1 p r q 15 0 S 9 1 e p 3 d q 16 11 5 17 e h r b 4 c 11 Cost 6 13 7 h r p q f a a contours q c 8 p q f G a q c 11 10 G a

  10. Uniform Cost Search (UCS) Properties o What nodes does UCS expand? o Processes all nodes with cost less than cheapest solution! b c ≤ 1 o If that solution costs C* and arcs cost at least ε , then the … “effective depth” is roughly C*/ε c ≤ 2 C*/ε “tiers” o Takes time O(b C*/ε ) (exponential in effective depth) c ≤ 3 o How much space does the fringe take? o Has roughly the last tier, so O(b C*/ε ) o Is it complete? o Assuming best solution has a finite cost and minimum arc cost is positive, yes! (if no solution, still need depth != ∞ ) o Is it optimal? o Yes! (Proof via A*)

  11. Uniform Cost Issues o Remember: UCS explores increasing c ≤ 1 … cost contours c ≤ 2 c ≤ 3 o The good: UCS is complete and optimal! o The bad: o Explores options in every “direction” Start Goal o No information about goal location [Demo: empty grid UCS (L2D5)] o We’ll fix that soon! [Demo: maze with deep/shallow water DFS/BFS/UCS (L2D7)]

  12. Video of Demo Empty UCS

  13. Video of Demo Maze with Deep/Shallow Water --- DFS, BFS, or UCS? (part 1)

  14. Video of Demo Maze with Deep/Shallow Water --- DFS, BFS, or UCS? (part 2)

  15. Video of Demo Maze with Deep/Shallow Water --- DFS, BFS, or UCS? (part 3)

  16. The One Queue o All these search algorithms are the same except for fringe strategies o Conceptually, all fringes are priority queues (i.e. collections of nodes with attached priorities) o Practically, for DFS and BFS, you can avoid the log(n) overhead from an actual priority queue, by using stacks and queues o Can even code one implementation that takes a variable queuing object

  17. Up next: Informed Search ▪ Informed Search o Uninformed Search ▪ Heuristics o DFS ▪ Greedy Search o BFS ▪ A* Search o UCS ▪ Graph Search

  18. Search Heuristics ▪ A heuristic is: ▪ A function that estimates how close a state is to a goal ▪ Designed for a particular search problem ▪ Pathing? ▪ Examples: Manhattan distance, Euclidean distance for pathing 10 5 11. 2

  19. Example: Heuristic Function h(x)

  20. Greedy Search

  21. Greedy Search o Expand the node that seems closest… o Is it optimal? o No. Resulting path to Bucharest is not the shortest!

  22. Greedy Search b … o Strategy: expand a node that you think is closest to a goal state o Heuristic: estimate of distance to nearest goal for each state o A common case: b o Best-first takes you straight to the (wrong) … goal o Worst-case: like a badly-guided DFS [Demo: contours greedy empty (L3D1)] [Demo: contours greedy pacman small maze (L3D4)]

  23. A* Search

  24. A* Search UCS Greedy A*

  25. Combining UCS and Greedy o Uniform-cost orders by path cost, or backward cost g(n) o Greedy orders by goal proximity, or forward cost h(n) g = 0 8 S h=6 g = 1 h=1 e a h=5 1 1 3 2 g = 9 g = 2 g = 4 S a d G b d e h=1 h=6 h=2 h=6 h=5 1 h=2 h=0 1 g = 3 g = 6 g = 10 c b c G d h=7 h=0 h=2 h=7 h=6 g = 12 G h=0 o A* Search orders by the sum: f(n) = g(n) + h(n) Example: Teg Grenager

  26. When should A* terminate? o Should we stop when we enqueue a goal? h = 2 g h + A 2 2 S 0 3 3 S S->A 2 2 4 G h = 3 h = 0 S->B 2 1 3 2 3 B S->B->G 5 0 5 h = 1 S->A->G 4 0 4 o No: only stop when we dequeue a goal

  27. Is A* Optimal? h = 6 1 3 A g h + S 0 7 7 S h = 7 G h = 0 S->A 1 6 7 S->G 5 0 5 5 o What went wrong? o Actual bad goal cost < estimated good goal cost o We need estimates to be less than actual costs!

  28. Admissible Heuristics

  29. Idea: Admissibility Inadmissible (pessimistic) heuristics Admissible (optimistic) heuristics break optimality by trapping slow down bad plans but good plans on the fringe never outweigh true costs

  30. Admissible Heuristics o A heuristic h is admissible (optimistic) if: where is the true cost to a nearest goal o Examples: 0.0 15 11.5 o Coming up with admissible heuristics is most of what’s involved in using A* in practice.

  31. Optimality of A* Tree Search

  32. Optimality of A* Tree Search Assume: o A is an optimal goal node … o B is a suboptimal goal node o h is admissible Claim: o A will exit the fringe before B

  33. Optimality of A* Tree Search: Blocking Proof: … o Imagine B is on the fringe o Some ancestor n of A is on the fringe, too (maybe A!) o Claim: n will be expanded before B 1. f(n) is less or equal to f(A) Definition of f-cost Admissibility of h h = 0 at a goal

  34. Optimality of A* Tree Search: Blocking Proof: … o Imagine B is on the fringe o Some ancestor n of A is on the fringe, too (maybe A!) o Claim: n will be expanded before B 1. f(n) is less or equal to f(A) 2. f(A) is less than f(B) B is suboptimal h = 0 at a goal

  35. Optimality of A* Tree Search: Blocking Proof: … o Imagine B is on the fringe o Some ancestor n of A is on the fringe, too (maybe A!) o Claim: n will be expanded before B 1. f(n) is less or equal to f(A) 2. f(A) is less than f(B) 3. n expands before B o All ancestors of A expand before B o A expands before B o A* search is optimal

  36. Properties of A* Uniform-Cost A* b b … …

  37. UCS vs A* Contours o Uniform-cost expands equally in all “directions” Start Goal o A* expands mainly toward the goal, but does hedge its bets to ensure optimality Start Goal [Demo: contours UCS / greedy / A* empty (L3D1)] [Demo: contours A* pacman small maze (L3D5)]

  38. Video of Demo Contours (Empty) -- UCS

  39. Video of Demo Contours (Empty) -- Greedy

  40. Video of Demo Contours (Empty) – A*

  41. Video of Demo Contours (Pacman Small Maze) – A*

  42. Comparison Greedy Uniform Cost A*

  43. Video of Demo Pacman (Tiny Maze) – UCS / A*

  44. Video of Demo Empty Water Shallow/Deep – Guess Algorithm

  45. Creating Heuristics

  46. Creating Admissible Heuristics o Most of the work in solving hard search problems optimally is in coming up with admissible heuristics o Often, admissible heuristics are solutions to relaxed problems, where new actions are available 366 15 o Inadmissible heuristics are often useful too

  47. Example: 8 Puzzle Start State Actions Goal State o What are the states? o How many states? Admissible o What are the actions? heuristics? o How many successors from the start state? o What should the costs be?

  48. 8 Puzzle I o Heuristic: Number of tiles misplaced o Why is it admissible? 8 o h(start) = o This is a relaxed-problem heuristic Start State Goal State Average nodes expanded when the optimal path has… …4 steps …8 steps …12 steps 6,300 UCS 112 3.6 x 10 6 TILES 13 39 227 Statistics from Andrew Moore

  49. 8 Puzzle II o What if we had an easier 8-puzzle where any tile could slide any direction at any time, ignoring other tiles? o Total Manhattan distance Start State Goal State o Why is it admissible? Average nodes expanded o h(start) = 3 + 1 + 2 + … = 18 when the optimal path has… …4 steps …8 steps …12 steps TILES 13 39 227 MANHATTA 12 25 73 N

  50. 8 Puzzle III o How about using the actual cost as a heuristic? o Would it be admissible? o Would we save on nodes expanded? o What’s wrong with it? o With A*: a trade-off between quality of estimate and work per node o As heuristics get closer to the true cost, you will expand fewer nodes but usually do more work per node to compute the heuristic itself

  51. Graph Search

  52. Tree Search: Extra Work! o Failure to detect repeated states can cause exponentially more work. State Graph Search Tree

  53. Graph Search o In BFS, for example, we shouldn’t bother expanding the circled nodes (why?) S e p d q e h r b c h r p q f a a q c p q f G a q c G a

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