solving problems by searching
play

Solving problems by searching Chapter 3 Some slide credits to Hwee - PowerPoint PPT Presentation

Solving problems by searching Chapter 3 Some slide credits to Hwee Tou Ng (Singapore) Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms Heuristics 2013 CS 325 -


  1. Solving problems by searching Chapter 3 Some slide credits to Hwee Tou Ng (Singapore)

  2. Outline  Problem-solving agents  Problem types  Problem formulation  Example problems  Basic search algorithms  Heuristics 2013 CS 325 - Ch3 Search 2

  3. Intelligent agent solves problems by? 2013 CS 325 - Ch3 Search 3

  4. Problem-solving agents 2013 CS 325 - Ch3 Search 4

  5. Example: Romania  On holiday in Romania; currently in Arad.  Flight leaves tomorrow from Bucharest  Formulate goal:  be in Bucharest  Formulate problem:  states: various cities  actions: drive between cities  Find solution:  sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest 2013 CS 325 - Ch3 Search 5

  6. Example: Romania 2013 CS 325 - Ch3 Search 6

  7. Romania: problem type? 2013 CS 325 - Ch3 Search 7

  8. Romania: Problem type  Deterministic, fully observable  single-state problem  Agent knows exactly which state it will be in; solution is a sequence  Non-observable  sensorless problem (conformant problem)  Agent may have no idea where it is; solution is a sequence  Nondeterministic and/or partially observable  contingency problem  percepts provide new information about current state  often interleave} search, execution  Unknown state space  exploration problem 2013 CS 325 - Ch3 Search 8

  9. Single-state problem formulation A problem is defined by four items: initial state e.g., "at Arad" 1. actions or successor function S(x) = set of action–state pairs 2. e.g., S(Arad) = { <Arad  Zerind, Zerind>, … }  goal test, can be 1. explicit, e.g., x = "at Bucharest"  implicit, e.g., Checkmate(x)  path cost (additive) 1. e.g., sum of distances, number of actions executed, etc.  c(x,a,y) is the step cost, assumed to be ≥ 0  A solution is a sequence of actions leading from the initial  state to a goal state 2013 CS 325 - Ch3 Search 9

  10. Tree search algorithms  Basic idea:  offline, simulated exploration of state space by generating successors of already-explored states (a.k.a. expanding states) 2013 CS 325 - Ch3 Search 10

  11. Tree search example 2013 CS 325 - Ch3 Search 11

  12. Tree search example 2013 CS 325 - Ch3 Search 12

  13. Tree search example 2013 CS 325 - Ch3 Search 13

  14. Implementation: general tree search 2013 CS 325 - Ch3 Search 14

  15. Uninformed search strategies  Uninformed search strategies use only the information available in the problem definition  Breadth-first search  Uniform-cost search  Depth-first search  Depth-limited search  Iterative deepening search 2013 CS 325 - Ch3 Search 15

  16. Breadth-first search  Expand shallowest unexpanded node  Implementation:  fringe is a FIFO queue, i.e., new successors go at end 2013 CS 325 - Ch3 Search 16

  17. Breadth-first search  Expand shallowest unexpanded node  Implementation:  fringe is a FIFO queue, i.e., new successors go at end 2013 CS 325 - Ch3 Search 17

  18. Breadth-first search  Expand shallowest unexpanded node  Implementation:  fringe is a FIFO queue, i.e., new successors go at end 2013 CS 325 - Ch3 Search 18

  19. Breadth-first search  Expand shallowest unexpanded node  Implementation:  fringe is a FIFO queue, i.e., new successors go at end 2013 CS 325 - Ch3 Search 19

  20. Example: Romania (Q) 2013 CS 325 - Ch3 Search 20

  21. Search strategies  A search strategy is defined by picking the order of node expansion  Strategies are evaluated along the following dimensions:  completeness: does it always find a solution if one exists?  time complexity: number of nodes generated  space complexity: maximum number of nodes in memory  optimality: does it always find a least-cost solution?  Time and space complexity are measured in terms of  b: maximum branching factor of the search tree  d: depth of the least-cost solution  m : maximum depth of the state space (may be ∞) 2013 CS 325 - Ch3 Search 21

  22. Properties of breadth-first search  Complete? Yes (if b is finite)  Time? 1+b+b 2 +b 3 +…+ b d + b(b d -1 ) = O (b d+1 )  Space? O(b d+1 ) (keeps every node in memory)  Optimal? Yes (if cost = 1 per step)  Space is the bigger problem (more than time) 2013 CS 325 - Ch3 Search 22

  23. Uniform-cost search Video 2013 CS 325 - Ch3 Search 23

  24. Uniform-cost search  Expand least-cost unexpanded node  Implementation:  fringe = queue ordered by path cost  Equivalent to breadth-first if step costs all equal  Complete? Yes, if step cost ≥ ε  Time? # of nodes with g ≤ cost of optimal solution, O(b ceiling(C*/ ε) ) where C * is the cost of the optimal solution  Space? # of nodes with g ≤ cost of optimal solution, O(b ceiling(C*/ ε) )  Optimal? Yes – nodes expanded in increasing order of g(n) 2013 CS 325 - Ch3 Search 24

  25. Comparison of Searches So far:  Breadth-first search  Uniform-cost (cheapest) search  New: Depth-first search Optimal? 2013 CS 325 - Ch3 Search 25

  26. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 26

  27. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 27

  28. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 28

  29. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 29

  30. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 30

  31. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 31

  32. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 32

  33. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 33

  34. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 34

  35. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 35

  36. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 36

  37. Depth-first search  Expand deepest unexpanded node  Implementation:  fringe = LIFO queue, i.e., put successors at front 2013 CS 325 - Ch3 Search 37

  38. Why depth-first? 2013 CS 325 - Ch3 Search 38

  39. Properties of depth-first search  Complete? No: fails in infinite-depth spaces, spaces with loops  Modify to avoid repeated states along path  complete in finite spaces  Time? O(b m ) : terrible if m >> d  but if solutions are dense, may be much faster than breadth-first  Space? O(bm), i.e., linear space!  Optimal? No 2013 CS 325 - Ch3 Search 39

  40. Summary of algorithms 2013 CS 325 - Ch3 Search 40

  41. Limitations Video 2013 CS 325 - Ch3 Search 41

  42. Best-first search Idea: use an evaluation function f(n) for each node estimate of "desirability"  Expand most desirable unexpanded node Implementation: Order the nodes in fringe in decreasing order of desirability Special cases: greedy best-first search A * search

  43. Romania with step costs in km

  44. Greedy best-first search Evaluation function f(n) = h(n) (heuristic) = estimate of cost from n to goal e.g., h SLD (n) = straight-line distance from n to Bucharest Greedy best-first search expands the node that appears to be closest to goal

  45. Greedy best-first search example

  46. Greedy best-first search example

  47. Greedy best-first search example

  48. Greedy best-first search example

  49. Properties of greedy best- first search • Complete? No – can get stuck in loops, e.g., Iasi  Neamt  Iasi  Neamt  • Time? O(b m ) , but a good heuristic can give dramatic improvement • Space? O(b m ) -- keeps all nodes in memory • Optimal? No

  50. A * search Idea: avoid expanding paths that are already expensive Evaluation function f(n) = g(n) + h(n) g(n) = cost so far to reach n h(n) = estimated cost from n to goal f(n) = estimated total cost of path through n to goal

  51. A * search example

  52. A * search example

  53. A * search example

  54. A * search example

  55. A * search example

  56. A * search example

  57. State Spaces

  58. Example: vacuum world  Single-state, start in #5. Solution? 2013 CS 325 - Ch3 Search 58

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