uninformed search
play

Uninformed Search Alice Gao Lecture 3 Based on work by K. - PowerPoint PPT Presentation

1/34 Uninformed Search Alice Gao Lecture 3 Based on work by K. Leyton-Brown, K. Larson, and P. van Beek 2/34 Outline Learning Goals Uninformed Search Breadth-First Search Depth-First Search Iterative-Deepening Search Comparing the


  1. 1/34 Uninformed Search Alice Gao Lecture 3 Based on work by K. Leyton-Brown, K. Larson, and P. van Beek

  2. 2/34 Outline Learning Goals Uninformed Search Breadth-First Search Depth-First Search Iterative-Deepening Search Comparing the algorithms Revisiting the Learning Goals

  3. 3/34 Learning goals By the end of the lecture, you should be able to frontier in a search tree. cost) (dealing with repeated states) complexity. optimality, time and space complexity. appropriate to use a particular search algorithm. ▶ Describe what it means to expand a node and what is a ▶ Defjne/trace/implement search algorithms (with/without ▶ Defjne completeness, optimality, time complexity and space ▶ Determine properties of search algorithms: completeness, ▶ Given a scenario, explain why it is appropriate or not

  4. 4/34 Learning Goals Uninformed Search Breadth-First Search Depth-First Search Iterative-Deepening Search Comparing the algorithms Revisiting the Learning Goals

  5. 5/34 Terminologies and the root is the start state. to the current state to generate a set of new states. expansion. ▶ A search tree: the nodes are the states, the arcs are actions, ▶ Expanding a node means applying every legal action ▶ The frontier contains the set of all leaf nodes available for

  6. 6/34 Problem Solving by Graph Searching frontier start node explored nodes unexplored nodes

  7. 7/34 return the solution 9: end while add every successor of the node to the frontier 8: generate all the successors of the node 7: end if 6: 5: Graph Search Algorithm if the node contains a goal state then 4: remove a node from the frontier 3: 2: while frontier is not empty do 1: put the start state in the frontier Algorithm 1 Generic graph search algorithm 10: return failure

  8. 8/34 The Search Strategy Search strategy: which node do we remove from the frontier? ▶ Breadth-fjrst search treats the frontier as a queue (FIFO). ▶ Depth-fjrst search treats the frontier as a stack (LIFO). ▶ Informed search treats the frontier as a priority queue.

  9. 9/34 Evaluating an Algorithm’s Performance Defjnition (complete) If a solution exists, a complete algorithm is guaranteed to fjnd a solution within a fjnite amount of time. Defjnition (optimal) If a solution exists and an algorithm fjnds a solution, then the fjrst solution found by an optimal algorithm is the solution with the lowest cost.

  10. 10/34 Evaluating an Algorithm’s Performance Defjnition (time complexity) The time complexity of a search algorithm is an expression for the worst-case amount of time it will take to run, expressed in terms of b , d , and m . Defjnition (space complexity) The space complexity of a search algorithm is an expression for the worst-case amount of memory that the algorithm will use, expressed in terms of b , d , and m . Useful defjnitions: ▶ b : the maximum branching factor (may be infjnite). ▶ d : the depth of the shallowest goal node (fjnite). ▶ m : the maximum path length (may be infjnite).

  11. 11/34 Learning Goals Uninformed Search Breadth-First Search Depth-First Search Iterative-Deepening Search Comparing the algorithms Revisiting the Learning Goals

  12. 12/34 return the solution 9: end while add every successor of the node to the frontier 8: generate all the successors of the node 7: end if 6: 5: Breadth-First Search if the node contains a goal state then 4: remove the oldest node added to the frontier 3: 2: while frontier is not empty do 1: put the start state in the frontier Algorithm 2 Breadth-First Search 10: return failure

  13. 13/34 Breadth-First Search Treats the frontier as a queue (FIFO). Expands the shallowest node in the frontier. ▶ Complete? ▶ Optimal? Yes if all arc costs are the same. ▶ Time complexity: O ( b d ) ▶ Space complexity:

  14. 14/34 CQ: Is BFS complete? CQ: Is BFS complete? (A) Yes. (B) No. (C) The answer depends on the branching factor. (D) The answer depends on whether there are infjnite paths in the search tree.

  15. 15/34 CQ: Space complexity of BFS CQ: What is the space complexity of BFS? (A) O ( bd ) (B) O ( b d ) (C) O ( bm ) (D) O ( b m )

  16. 16/34 Using Breadth-First Search Would you use Breadth-First Search in any scenario below? 1. Memory is limited. 2. All solutions are deep in the tree. 3. There are infjnite paths in the tree. 4. The branching factor is large. 5. We must fjnd the shallowest goal node.

  17. 17/34 Learning Goals Uninformed Search Breadth-First Search Depth-First Search Iterative-Deepening Search Comparing the algorithms Revisiting the Learning Goals

  18. 18/34 return the solution 9: end while add every successor of the node to the frontier 8: generate all the successors of the node 7: end if 6: 5: Depth-First Search if the node contains a goal state then 4: remove the newest node added to the frontier 3: 2: while frontier is not empty do 1: put the start state in the frontier Algorithm 3 Depth-First Search 10: return failure

  19. 19/34 Depth-First Search Treats the frontier as a stack (LIFO). Expands the deepest node in the frontier. ▶ Complete? ▶ Optimal? No. ▶ Time complexity: O ( b m ) ▶ Space complexity:

  20. 20/34 CQ: Is DFS complete? CQ: Is DFS complete? (A) Yes. (B) No. (C) The answer depends on the branching factor. (D) The answer depends on whether there are infjnite paths in the search tree.

  21. 21/34 CQ: Space complexity of DFS CQ: What is the space complexity of DFS? (A) O ( bd ) (B) O ( b d ) (C) O ( bm ) (D) O ( b m )

  22. 22/34 Using Depth-First Search Would you use Depth-First Search in any scenario below? Why? 1. Memory is limited. 2. Some paths have infjnite lengths. 3. The graph contains cycles. 4. Some solutions are very shallow.

  23. 23/34 Handling Repeated States states? ▶ Store visited states in a hash table. ▶ How would the properties of DFS change if we prune visited

  24. 24/34 Comparing BFS and DFS ▶ What are the advantages of BFS over DFS? ▶ What are the advantages of DFS over BFS?

  25. 25/34 CQ: BFS or DFS? CQ: Suppose that some solutions are very deep and some solutions are very shallow in the search tree of a problem. Which of BFS and DFS should we use to solve this problem? (A) BFS (B) DFS (C) Both of BFS and DFS (D) Neither of BFS and DFS

  26. 26/34 CQ: BFS or DFS? CQ: If we have very limited memory and the search graph of a problem contains cycles, which of BFS and DFS should we use to solve this problem? (A) BFS (B) DFS (C) Both of BFS and DFS (D) Neither of BFS and DFS

  27. 27/34 Learning Goals Uninformed Search Breadth-First Search Depth-First Search Iterative-Deepening Search Comparing the algorithms Revisiting the Learning Goals

  28. 28/34 The best of BFS and DFS BFS DFS requires lots of space requires little space complete not complete The best of both worlds: ▶ Run DFS until level l . ▶ If no solution found, try level l + 1, l + 2, etc.

  29. 29/34 Iterative Deepening Search Algorithm 4 Iterative Deepening Search 2: Perform depth-fjrst search up to maximum depth limit l 3: end for 1: for l = 0 to ∞ do

  30. 30/34 Iterative-Deepening Search Perform a depth-fjrst search with maximum depth l . For depth limit l = 0 , 1 , ... ▶ Complete? Yes if the branching factor is fjnite. ▶ Optimal? Yes if all arc costs are the same. ▶ Time complexity: O ( b d ) ▶ Space complexity: O ( bd )

  31. 31/34 Using Iterative-Deepening Search multiple times? ▶ How is IDS similar to/difgerent from DFS? ▶ How is IDS similar to/difgerent from BFS? ▶ Is it too costly for IDS to generate states in the upper levels

  32. 32/34 Comparing BFS, DFS, and IDS Algorithm Complete? Optimal? Time Space IDS DFS BFS * if the branching factor is fjnite. ** if the search tree does not have infjnite paths.

  33. 33/34 CQ: Comparing IDS and DFS CQ: Suppose that the search tree of a problem has no infjnite paths. Which one of DFS and IDS should we use to solve this problem? (A) DFS is better than IDS. (B) IDS is better than DFS. (C) DFS and IDS are the same.

  34. 34/34 Revisiting the learning goals By the end of the lecture, you should be able to frontier in a search tree. cost) (dealing with repeated states) complexity. optimality, time and space complexity. appropriate to use a particular search algorithm. ▶ Describe what it means to expand a node and what is a ▶ Defjne/trace/implement search algorithms (with/without ▶ Defjne completeness, optimality, time complexity and space ▶ Determine properties of search algorithms: completeness, ▶ Given a scenario, explain why it is appropriate or not

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