lecture 3
play

Lecture 3 Music: 9 to 5 - Dolly Parton Por una Cabeza - PowerPoint PPT Presentation

Lecture 3 Music: 9 to 5 - Dolly Parton Por una Cabeza (instrumental) - written by Carlos Gardel, performed by Horacio Rivera Bear Necessities - from The Jungle Book, performed by Anthony the Banjo Man MOVE TO THE FRONT OF THE


  1. Lecture 3 ▪ Music: ▪ 9 to 5 - Dolly Parton ▪ Por una Cabeza (instrumental) - written by Carlos Gardel, performed by Horacio Rivera ▪ Bear Necessities - from The Jungle Book, performed by Anthony the Banjo Man MOVE TO THE FRONT OF THE ROOM.

  2. Announcements ▪ Lecture will be in Dwinelle 155 until the department tells us otherwise ▪ Please move to the front of the room. ▪ Homework 1: Search ▪ Written component: exam-style template to be completed (we recommend on paper) and to be submitted into Gradescope ▪ Project 1: Search ▪ Start early and ask questions! ▪ Mega Office Hours is tomorrow, 5 - 7 pm, in Cory 521. ▪ This is a place for you to meet and form study groups with other students, to work on the homework/project. ▪ There will be multiple TAs to help answer questions. ▪ Mini-Contest 1 released (optional) ▪ Due Monday, 7/8, at 11:59 pm. ▪ Some people have duplicate Gradescope accounts enrolled in the class! ▪ Make sure you only have one account, or we won’t be able to assign you a grade at the end.

  3. CS 188: Artificial Intelligence Informed Search Instructors: Aditya Baradwaj and Brijen Thananjeyan University of California, Berkeley [slides adapted from Dan Klein, Pieter Abbeel]

  4. Today ▪ Informed Search ▪ Heuristics ▪ Greedy Search ▪ A* Search ▪ Graph Search

  5. Recap: Search

  6. Recap: Search ▪ Search problem: ▪ States (configurations of the world) ▪ Actions and costs ▪ Successor function (world dynamics) ▪ 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 ▪ Chooses an ordering of the fringe (unexplored nodes) ▪ Optimal: finds least-cost plans

  7. Example: Pancake Problem Cost: Number of pancakes flipped

  8. Example: Pancake Problem

  9. Example: Pancake Problem State space graph with costs as weights 4 2 3 2 3 4 3 4 2 3 2 2 4 3

  10. General Tree Search Action: flip top two Action: flip all four Path to reach goal: Cost: 2 Cost: 4 Flip four, flip three Total cost: 7

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

  12. Uninformed Search

  13. Uniform Cost Search ▪ Strategy: expand lowest path cost c ≤ 1 … c ≤ 2 c ≤ 3 ▪ The good: UCS is complete and optimal! ▪ The bad: ▪ Explores options in every “direction” Start Goal ▪ No information about goal location [Demo: contours UCS empty (L3D1)] [Demo: contours UCS pacman small maze (L3D3)]

  14. Video of Demo Contours UCS Empty

  15. Video of Demo Contours UCS Pacman Small Maze

  16. Informed Search

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

  18. Example: Heuristic Function h(x)

  19. Example: Heuristic Function Q: What are some heuristics for the pancake sorting problem? 3 h(x) 4 3 4 3 0 4 4 3 4 4 2 3

  20. Example: Heuristic Function Heuristic: the number of the largest pancake that is still out of place 3 h(x) 4 3 4 3 0 4 4 3 4 4 2 3

  21. Greedy Search

  22. Example: Heuristic Function h(x)

  23. Greedy Search ▪ Expand the node that seems closest… ▪ What can go wrong?

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

  25. Video of Demo Contours Greedy (Empty)

  26. Video of Demo Contours Greedy (Pacman Small Maze)

  27. A* Search

  28. A* Search UCS Greedy A*

  29. Combining UCS and Greedy ▪ Uniform-cost orders by path cost, or backward cost g(n) ▪ 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 ▪ A* Search orders by the sum: f(n) = g(n) + h(n)

  30. When should A* terminate? ▪ Should we stop when we enqueue a goal? h = 2 A 2 2 S G h = 3 h = 0 2 3 B h = 1 ▪ No: only stop when we dequeue a goal

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

  32. Admissible Heuristics

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

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

  35. Break! ▪ Stand up and stretch ▪ Talk to your neighbors

  36. Optimality of A* Tree Search

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

  38. Optimality of A* Tree Search: Blocking Proof: … ▪ Imagine B is on the fringe ▪ Some ancestor n of A is on the fringe, too (maybe A!) ▪ 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

  39. Optimality of A* Tree Search: Blocking Proof: … ▪ Imagine B is on the fringe ▪ Some ancestor n of A is on the fringe, too (maybe A!) ▪ 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

  40. Optimality of A* Tree Search: Blocking Proof: … ▪ Imagine B is on the fringe ▪ Some ancestor n of A is on the fringe, too (maybe A!) ▪ 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 ▪ All ancestors of A expand before B ▪ A expands before B ▪ A* search is optimal

  41. Properties of A*

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

  43. UCS vs A* Contours ▪ Uniform-cost expands equally in all “directions” Start Goal ▪ 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)]

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

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

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

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

  48. Comparison Greedy Uniform Cost A*

  49. A* Applications

  50. A* Applications ▪ Video games ▪ Pathing / routing problems ▪ Resource planning problems ▪ Robot motion planning ▪ Language analysis ▪ Machine translation ▪ Speech recognition ▪ … [Demo: UCS / A* pacman tiny maze (L3D6,L3D7)] [Demo: guess algorithm Empty Shallow/Deep (L3D8)]

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

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

  53. Creating Heuristics

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

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

  56. 8 Puzzle I ▪ Heuristic: Number of tiles misplaced ▪ Why is it admissible? ▪ h(start) = 8 ▪ 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

  57. 8 Puzzle II ▪ What if we had an easier 8-puzzle where any tile could slide any direction at any time, ignoring other tiles? ▪ Total Manhattan distance Start State Goal State ▪ Why is it admissible? Average nodes expanded ▪ 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

Recommend


More recommend