1 / 66

CS 343H: Artificial Intelligence

CS 343H: Artificial Intelligence. Week 2b: Informed Search. Quiz : review. Which are true about DFS? ( b is branching factor, m is depth of search tree.) At any given time during the search, the number of nodes on the fringe can be no larger than bm .

klassiter
Download Presentation

CS 343H: Artificial Intelligence

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 343H: Artificial Intelligence Week 2b: Informed Search

  2. Quiz : review • Which are true about DFS? (b is branching factor, m is depth of search tree.) • At any given time during the search, the number of nodes on the fringe can be no larger than bm. • At any given time in the search, the number of nodes on the fringe can be as large as b^m. • The number of nodes expanded throughout the entire search can be no larger than bm. • The number of nodes expanded throughout the entire search can be as large as b^m.

  3. Quiz : review • Which are true about BFS? (b is the branching factor, s is the depth of the shallowest solution) • At any given time during the search, the number of nodes on the fringe can be no larger than bs. • At any given time during the search, the number of nodes on the fringe can be as large as b^s. • The number of nodes considered throughout the entire search can be no larger than bs. • The number of nodes considered throughout the entire search can be as large as b^s.

  4. Quiz: search execution • Run DFS, BFS, and UCS:

  5. Today • Informed search • Heuristics • Greedy search • A* search • Graph search

  6. Recap: Search • Search problem: • States (configurations of the world) • Actions and costs • Successor function: a function from states to lists of (state, action, cost) triples (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 State space graph with costs as weights 4 2 3 2 3 4 3 4 2 3 2 2 4 3

  9. General Tree Search Action: flip top twoCost: 2 Action: flip all fourCost: 4 Path to reach goal: Flip four, flip three Total cost: 7

  10. Recall: Uniform Cost Search • Strategy: expand lowest path cost • The good: UCS is complete and optimal! • The bad: • Explores options in every “direction” • No information about goal location c  1 … c  2 c  3 Start Goal [demo: countours UCS]

  11. Example: Uniform cost search

  12. Another example

  13. Informed search: main idea

  14. Search heuristic • A heuristic is: • A function that estimates how close a state is to a goal • Designed for a particular search problem 10 5 11.2

  15. Example: Heuristic Function h(x)

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

  17. How to use the heuristic? • What about following the “arrow” of the heuristic?.... Greedy search

  18. Example: Heuristic Function h(x)

  19. Best First / Greedy Search • Expand the node that seems closest… • What can go wrong?

  20. 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 • Worst-case: like a badly-guided DFS … b …

  21. Quiz: greedy search • Which solution would greedy search find if run on this graph?

  22. Enter: A* search

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

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

  25. Quiz: A* Tree search

  26. Quiz: A* Tree search • When running A*, the first node expanded is S (like all search algorithms). After expanding S, two nodes will be on the fringe: S->A and S->D. Fill in: • g((S->A)) = • h((S->A)) = • f((S->A)) = • g((S->D))= • h((S->D)) = • f((S->D)) = • Which node will be expanded next?

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

  28. Idea: admissibility Inadmissible (pessimistic): break optimality by trapping good plans on the fringe Admissible (optimistic): slows down bad plans but never outweigh true costs

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

  30. Optimality of A* Notation: • g(n) = cost to node n • h(n) = estimated cost from n to the nearest goal (heuristic) • f(n) = g(n) + h(n) =estimated total cost via n • A: a lowest cost goal node • B: another goal node … A B Claim: A will exit the fringe before B.

  31. Claim: A will exit the fringe before B. Optimality of A* • Imagine B is on the fringe. • Some ancestor n of A must be on the fringe too (maybe n is A) • Claim: n will be expanded before B. • f(n) <= f(A) … A B • f(n) = g(n) + h(n) // by definition • f(n) <= g(A) // by admissibility of h • g(A) = f(A) // because h=0 at goal

  32. Claim: A will exit the fringe before B. Optimality of A* • Imagine B is on the fringe. • Some ancestor n of A must be on the fringe too (maybe n is A) • Claim: n will be expanded before B. • f(n) <= f(A) • f(A) < f(B) … A B • g(A) < g(B) // B is suboptimal • f(A) < f(B) // h=0 at goals

  33. Claim: A will exit the fringe before B. Optimality of A* • Imagine B is on the fringe. • Some ancestor n of A must be on the fringe too (maybe n is A) • Claim: n will be expanded before B. • f(n) <= f(A) • f(A) < f(B) • n will expand before B … A B • f(n) <= f(A) < f(B) // from above • f(n) < f(B)

  34. Claim: A will exit the fringe before B. Optimality of A* • Imagine B is on the fringe. • Some ancestor n of A must be on the fringe too (maybe n is A) • Claim: n will be expanded before B. • f(n) <= f(A) • f(A) < f(B) • n will expand before B • All ancestors of A expand before B • A expands before B … A B

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

  36. UCS vs A* Contours • Uniform-cost expands equally in all directions • A* expands mainly toward the goal, but does hedge its bets to ensure optimality Start Goal Start Goal

  37. Recall: greedy

  38. Uniform cost search

  39. A*

  40. Quiz: A* tree search

  41. Quiz

  42. A* applications • Pathing / routing problems • Video games • Resource planning problems • Robot motion planning • Language analysis • Machine translation • Speech recognition • …

  43. 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 • Inadmissible heuristics are often useful too (why?) 366 15

  44. Example: 8 Puzzle • What are the states? • How many states? • What are the actions? • What states can I reach from the start state? • What should the costs be?

  45. 8 Puzzle I • Heuristic: Number of tiles misplaced • Why is it admissible? • h(start) = • This is a relaxed-problem heuristic 8

  46. 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 • Why admissible? • h(start) = 3 + 1 + 2 + … = 18

  47. 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 • Why admissible? • h(start) = 3 + 1 + 2 + … = 18

  48. Quiz 1 • Consider the problem of Pacman eating all dots in a maze. Every movement action has a cost of 1. Select all heuristics that are admissible, if any. • the total number of dots left • the distance to the closest dot • the distance to the furthest dot • the distance to the closest dot plus distance to the furthest dot • none of the above

  49. 8 Puzzle III • How about using the actual cost as a heuristic? • Would it be admissible? • Would we save on nodes expanded? • What’s wrong with it? • With A*: a trade-off between quality of estimate and work per node!

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

More Related