1 / 26

State Space Search Algorithms

State Space Search Algorithms. CSE 472 Introduction to Artificial Intelligence Autumn 2003. Depth First Search. Maintain stack of nodes to visit Properties Complete? Time Complexity? Space Complexity?. Not for infinite spaces. a. O(b^d). b. c. O(d). g. h. d. e. f.

Download Presentation

State Space Search Algorithms

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. State Space Search Algorithms CSE 472 Introduction to Artificial Intelligence Autumn 2003

  2. Depth First Search • Maintain stack of nodes to visit • Properties • Complete? • Time Complexity? • Space Complexity? Not for infinite spaces a O(b^d) b c O(d) g h d e f

  3. Breadth First Search • Maintain FIFO queue of nodes to visit • Properties • Complete? • Time Complexity? • Space Complexity? Yes a O(b^d) b c O(b^d) g h d e f

  4. Iterative Deepening Search • DFS with limit; incrementally grow limit • Properties • Complete? • Time Complexity? • Space Complexity? Yes a a O(b^d) b b c c O(d) g h d e f

  5. Dijkstra’s Shortest Path Algorithm • Like breadth-first search, but uses a priority queue instead of a FIFO queue • Generalizes BFS to case where arcs can have different lengths • Example: maze where roads between intersections are different lengths • Example: complete CSE major doing as little homework as possible, where each course has estimated number of hours of homework

  6. Pseudocode for Dijkstra • Initialize the cost of each vertex to  • cost[s] = 0; • heap.insert(s); • While (! heap.empty()) n = heap.deleteMin() if (n is a goal vertex) then return “Success!” For (each vertex a which is adjacent to n along edge e) if (cost[n] + edge_cost[e] < cost[a]) then cost [a] = cost[n] + edge_cost[e] previous_on_path_to[a] = n; if (a is in the heap) then heap.decreaseKey(a) else heap.insert(a)

  7. Edsger Wybe Dijkstra (1930-2002) • Invented concept of structured programming • 1972 Turing Award • “In their capacity as a tool, computers will be but a ripple on the surface of our culture. In their capacity as intellectual challenge, they are without precedent in the cultural history of mankind.”

  8. Map of Manhattan • How would you find a path from S to G? S 52nd St G 51st St 50th St 10th Ave 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave 2nd Ave 3rd Ave

  9. Best-First Search • The Manhattan distance ( x+  y) is an estimate of the distance to the goal • It is a heuristic function • Best-First Search • Order nodes in priority queue to minimize estimated distance to the goal h(n) • Compare: Dijkstra • Order nodes in priority queue to minimize distance from the start

  10. Best First in Action • How would you find a path from S to G? S 52nd St G 51st St 50th St 10th Ave 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave 2nd Ave 3rd Ave

  11. Problem 1: Led Astray • Eventually will expand vertex to get back on the right track S G 52nd St 51st St 50th St 10th Ave 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave 2nd Ave 3rd Ave

  12. Problem 2: Optimality • With Best-First Search, are you guaranteed a shortest path is found when • goal is first seen? • when goal is removed from priority queue (as with Dijkstra?)

  13. Sub-Optimal Solution • No! Goal is by definition at distance 0: will be removed from priority queue immediately, even if a shorter path exists! (5 blocks) S 52nd St h=2 h=5 G h=4 51st St h=1 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

  14. Synergy? • Dijkstra / Breadth First guaranteed to find optimal solution • Best First often visits far fewer vertices, but may not provide optimal solution • Can we get the best of both?

  15. A* (“A star”) Order vertices in priority queue to minimize (distance from start) + (estimated distance to goal) f(n) = g(n) + h(n) f(n) = priority of a node g(n) = true distance from start h(n) = heuristic distance to goal

  16. Optimality • Suppose the estimated distance (h) is alwaysless than or equal to the true distance to the goal • heuristic is a lower bound on true distance • heuristic is admissible • Then: when the goal is removed from the priority queue, we are guaranteed to have found a shortest path!

  17. A* in Action S (5 blocks) 52nd St G 51st St 50th St 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

  18. A* in Action S (5 blocks) 52nd St G 51st St 50th St 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

  19. A* in Action S (5 blocks) 52nd St G 51st St 50th St 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

  20. A* in Action S (5 blocks) 52nd St G 51st St 50th St 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

  21. A* in Action S (5 blocks) 52nd St G 51st St 50th St 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

  22. A* in Action S (5 blocks) 52nd St G 51st St 50th St 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

  23. A* in Action S (5 blocks) 52nd St G 51st St 50th St 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave DONE!

  24. What Would Dijkstra Have Done? S (5 blocks) 52nd St G 51st St 50th St 49th St 48th St 47th St 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave

  25. Importance of Heuristics 7 2 3 4 1 6 8 5 • h1 = number of tiles in the wrong place • h2 = sum of distances of tiles from correct location D IDS A*(h1) A*(h2) 2 10 6 6 4 112 13 12 6 680 20 18 8 6384 39 25 10 47127 93 39 12 364404 227 73 14 3473941 539 113 18 3056 363 24 39135 1641

  26. Maze Runner Demo

More Related