graduate ai
play

Graduate AI Lecture 2: Search I Instructors: Nihar B. Shah (this - PowerPoint PPT Presentation

Graduate AI Lecture 2: Search I Instructors: Nihar B. Shah (this time) J. Zico Kolter E XAMPLE : P ATHFINDING Best route? 2 E XAMPLE : 8-P UZZLE Fewest moves? 5 2 1 2 3 6 1 3 4 5 6 7 8 4 7 8 15780 Spring 2019: Lecture 2


  1. Graduate AI Lecture 2: Search I Instructors: Nihar B. Shah (this time) J. Zico Kolter

  2. E XAMPLE : P ATHFINDING Best route? 2

  3. E XAMPLE : 8-P UZZLE Fewest “moves”? 5 2 1 2 3 6 1 3 4 5 6 7 8 4 7 8 15780 Spring 2019: Lecture 2 3

  4. S EARCH P ROBLEMS • A search problem has: States (configurations) o Start state and goal states o Successors: mapping of states to o (action,state,cost) triples High-level objective: Find minimum-cost path from s to t in a computationally efficient manner 15780 Spring 2019: Lecture 2 4

  5. E XAMPLE : P ATHFINDING " ! 5

  6. E XAMPLE : P ATHFINDING " ! 6

  7. E XAMPLE : P ATHFINDING " ! 7

  8. E XAMPLE : P ATHFINDING " 1 2 4 ! 3 8

  9. G RAPH R EPRESENTATION 1 3 2 goal " starting state ! # & 5 1 1 1 % $ ' Cost ≥ 0 between each pair of vertices x & y High-level objective: Find minimum-cost path from s to t in a computationally efficient manner 15780 Spring 2019: Lecture 2 9

  10. E XAMPLE : 8-P UZZLE 5 2 6 1 3 1 5 2 1 2 3 7 8 4 6 1 3 4 5 6 7 8 4 5 2 3 7 8 1 s t 6 1 7 8 4 15780 Spring 2019: Lecture 2 10

  11. T REE S EARCH Inputs: • Problem instance • “Expansion strategy” Output: • Path from s to t 15780 Spring 2019: Lecture 2 11

  12. R ECALL : B READTH F IRST S EARCH • Graph with each cost 1 1 1 1 " ! # & 1 1 1 1 % $ ' • Define , 0 = cost till 0 • Expansion strategy: Expand node with minimum g … ! # $ & ' % , = 0 , = 1 , = 2 , = 2 , = 2 , = 3 #1 #2 #3 15780 Spring 2019: Lecture 2 12

  13. T REE S EARCH function T REE -S EARCH (problem, strategy) set of frontier nodes contains the start state of problem loop • if there are no frontier nodes then return failure • choose a frontier node for expansion using strategy • if the chosen node is t then return the corresponding solution • else expand the node and add the resulting nodes to the set of frontier nodes 15780 Spring 2019: Lecture 2 13

  14. U NIFORM C OST S EARCH A LGORITHM Define , 0 = cost till 0 Strategy: Expand node with smallest , 1 3 2 ! " # & 5 1 1 1 % $ ' s a e d s a d ! # $ & ' % " & Frontier: , = 0 , = 1 , = 2 , = 4 , = 6 , = 3 , = 6 , = 7 #1 #2 #3 #5 #4 #6 #7 15780 Spring 2019: Lecture 2 14

  15. U NINFORMED VS . I NFORMED • Uniform cost search uses no information about the problem other than the edge costs “Uninformed” search o • Often we may have more information… “Informed” search o 15780 Spring 2019: Lecture 2 15

  16. E XAMPLE : P ATHFINDING " “Going this direction is generally a good idea” ! 16

  17. E XAMPLE : 8-P UZZLE 5 2 1 2 3 6 1 3 4 5 6 7 8 4 7 8 “Having more blocks in their correct position is generally a good idea” 15780 Spring 2019: Lecture 2 17

  18. I NFORMED S EARCH • Additional information: For each vertex 0 , given ℎ 0 = heuristic evaluation of cost from 0 to t ℎ = 6 ℎ = 5 ℎ = 2 ℎ = 0 1 3 2 " ! # & 5 1 1 1 % $ ' ℎ = 7 ℎ = 6 ℎ = 1 • ℎ " = 0 15780 Spring 2019: Lecture 2 18

  19. G REEDY S EARCH U SING H EURISTIC • Strategy: Expand node with min. value of ℎ ℎ = 6 ℎ = 5 ℎ = 2 ℎ = 0 1 3 2 ! " # & 5 1 1 1 % $ ' ℎ = 7 ℎ = 6 ℎ = 1 ! # $ & ' & " ℎ = 6 ℎ = 5 ℎ = 6 ℎ = 2 ℎ = 1 ℎ = 2 ℎ = 0 #1 #2 #4 #5 #3 15780 Spring 2019: Lecture 2 19

  20. A* T REE S EARCH • Strategy: Expand node with min. value of 6 0 = , 0 + ℎ 0 ℎ = 6 ℎ = 5 ℎ = 2 ℎ = 0 1 3 2 " ! # & 5 1 1 1 % $ ' ℎ = 7 ℎ = 6 ℎ = 1 • Question: Which node is expanded fourth? ! # $ & ' " 6 = 6 6 = 6 6 = 8 6 = 6 6 = 7 6 = 6 #3 #1 #2 #4 15780 Spring 2019: Lecture 2 20

  21. A* T REE S EARCH • Should we stop when we discover a goal? ℎ = 2 2 # 2 ℎ = 3 ℎ = 0 ! " $ 2 3 ℎ = 1 ! # $ " " 6 = 3 6 = 4 6 = 3 6 = 5 6 = 4 #4 #1 #3 #2 • No: Only stop when we expand a goal Slide adapted from Dan Klein 15780 Spring 2019: Lecture 2 21

  22. A* P ERFORMANCE today Find minimum-cost path from s to t in a computationally efficient manner 15780 Spring 2019: Lecture 2 22

  23. A* D OESN ’ T A LWAYS W ORK ℎ = 7 ℎ = 0 5 ! " # 1 3 ℎ = 6 ! # " 6 = 7 6 = 7 6 = 5 #1 #2 • Issue: Good path has pessimistic estimate • Circumvent this issue by being optimistic! Slide adapted from Dan Klein 15780 Spring 2019: Lecture 2 23

  24. A DMISSIBLE H EURISTICS ℎ is admissible if for all 0 , ℎ 0 ≤ ℎ ∗ 0 , where ℎ ∗ is the cost of the optimal path from 0 to " ℎ = 2 ℎ = 7 ℎ = 0 5 2 2 # § ! " ℎ = 3 ℎ = 0 § ! " # 1 3 ✅ ❌ $ 2 3 ℎ = 6 ℎ = 1 § ℎ ≡ 0 § Aerial distance in pathfinding ✅ ✅ 15780 Spring 2019: Lecture 2 24

  25. O PTIMALITY OF A* T REE S EARCH Theorem: If the heuristic is admissible, then the path returned by A* tree search has minimum cost. 15780 Spring 2019: Lecture 2 25

  26. P ROOF • Recall: A* stops when goal " is expanded • For contradiction, assume " with suboptimal path is expanded before " with optimal path • There is a node 0 on the optimal path to " that has been discovered but not expanded • 6 0 = , 0 + ℎ 0 ≤ , 0 + ℎ ∗ 0 = , " >?@ < , " BC?DEFBF = 6(" BC?DEFBF ) • 0 should have been expanded before " ! ∎ Adapted from Dan Klein 26

  27. 8- PUZZLE H EURISTICS 5 2 • ℎ 1 : #tiles in wrong position 6 1 3 7 8 4 • ℎ 2 : sum of Manhattan distances of Example state tiles from goal 1 2 3 • Question: Which of these is 4 5 6 admissible? 7 8 Answer: Both o Goal state • Heuristic for designing admissible heuristics: relax the problem! 15780 Spring 2019: Lecture 2 27

  28. D OMINANCE O F H EURISTICS • ℎ dominates ℎ′ iff ∀0, ℎ 0 ≥ ℎ′(0) 5 2 6 1 3 • ℎ 1 : #tiles in wrong position 7 8 4 • ℎ 2 : sum of Manhattan distances of Example state tiles from goal 1 2 3 4 5 6 • Question: What is the dominance 7 8 relation between ℎ L and ℎ M ? Goal state Answer: ℎ M dominates ℎ L o 15780 Spring 2019: Lecture 2 28

  29. 8- PUZZLE H EURISTICS • The following table gives the number of nodes expanded by A* with the two heuristics, averaged over random 8-puzzles, for various solution lengths N ∗ (O P ) N ∗ (O Q ) Length 16 1301 211 18 3056 363 20 7276 676 22 18094 1219 24 39135 1641 • Moral: Good heuristics are crucial! 15780 Spring 2019: Lecture 2 29

  30. T REE S EARCH • Tree search can expand many nodes corresponding to the same state • In a rectangular grid: o Search tree of depth & has 4 R leaves o There are only 4& states at Manhattan distance exactly & from any given state 15780 Spring 2019: Lecture 2 30

  31. G RAPH S EARCH Graph search is the same as tree search, except that it never expands a node twice function G RAPH -S EARCH (problem, strategy) set of frontier nodes contains the start state of problem loop • if there are no unexpanded frontier nodes then return failure • choose an unexpanded frontier node for expansion using strategy, and add it to the expanded set • if the node contains a goal then return the corresponding solution • else expand the node and add the resulting nodes to the set of frontier nodes, only if not in the expanded set 15780 Spring 2019: Lecture 2 31

  32. A* G RAPH S EARCH • Does A* graph search always find the optimal path under an admissible heuristic? ℎ = 4 1 1 # ℎ = 1 ℎ = 0 ℎ = 2 3 ! % " $ 1 2 ℎ = 1 " ! # $ % % 6 = 4 6 = 6 6 = 2 6 = 5 6 = 2 6 = 3 #4 #1 #2 #3 #5 • No! 15780 Spring 2019: Lecture 2 Adapted from Dan Klein 32

  33. C ONSISTENT H EURISTICS • % 0, S = cost of cheapest path from 0 to S • ℎ is consistent if for every two nodes 0, S, ℎ 0 ≤ %(0, S) + ℎ(S) 0 S • Question: What is the relation between admissibility and consistency? Admissible ⇒ consistent " 1. • Set y = " above Consistent ⇒ admissible 2. • Graph in previous slide They are equivalent 3. They are incomparable 4. 15780 Spring 2019: Lecture 2 33

  34. 8- PUZZLE H EURISTICS , C ONSISTENT ? • ℎ 1 : #tiles in wrong position 5 2 • ℎ 2 : sum of Manhattan distances of 6 1 3 tiles from goal 7 8 4 Example state • Poll: Which of these is consistent? Answer: Both 1 2 3 o • Heuristic for designing admissible 4 5 6 heuristics: relax the problem! 7 8 Goal state Consistent heuristics yield guarantees for A*graph search (next class) 15780 Spring 2019: Lecture 2 34

  35. S UMMARY • Terminology and algorithms: Search problems o Uninformed vs. informed search o Tree search, graph search, o uniform cost search, greedy, A* Admissible and consistent heuristics o • Theorems: A* tree search is optimal with admissible ℎ o A* graph search is optimal with consistent ℎ o • Big ideas: Don’t be too pessimistic! o 15780 Spring 2019: Lecture 2 35

Recommend


More recommend