1 / 87

Solving problems by searching

Chapter 3 Some slide credits to Hwee Tou Ng (Singapore). Solving problems by searching. Outline. Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms Heuristics. Intelligent agent solves problems by?. Problem-solving agents. Example: Romania.

antoinettev
Télécharger la présentation

Solving problems by searching

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. Chapter 3 Some slide credits to Hwee Tou Ng (Singapore) Solving problems by searching

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

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

  4. CS 325 - Ch3 Search Problem-solving agents

  5. CS 325 - Ch3 Search 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

  6. CS 325 - Ch3 Search Example: Romania

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

  8. CS 325 - Ch3 Search 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

  9. CS 325 - Ch3 Search Single-state problem formulation A problem is defined by four items: initial state e.g., "at Arad" actions or successor functionS(x) = set of action–state pairs e.g., S(Arad) = {<Arad  Zerind, Zerind>, … } goal test, can be explicit, e.g., x = "at Bucharest" implicit, e.g., Checkmate(x) path cost (additive) 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

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

  11. CS 325 - Ch3 Search Tree search example

  12. CS 325 - Ch3 Search Tree search example

  13. CS 325 - Ch3 Search Tree search example

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

  15. CS 325 - Ch3 Search 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

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

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

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

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

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

  21. CS 325 - Ch3 Search 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 ∞)

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

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

  24. CS 325 - Ch3 Search 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(bceiling(C*/ ε)) where C* is the cost of the optimal solution Space? # of nodes with g≤ cost of optimal solution, O(bceiling(C*/ ε)) Optimal? Yes – nodes expanded in increasing order of g(n)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  39. CS 325 - Ch3 Search 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(bm): 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

  40. CS 325 - Ch3 Search Summary of algorithms

  41. CS 325 - Ch3 Search Limitations Video

  42. Best-first search Idea: use an evaluation functionf(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., hSLD(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(bm), but a good heuristic can give dramatic improvement Space?O(bm) -- 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

More Related