1 / 45

CS 8520: Artificial Intelligence

CS 8520: Artificial Intelligence. Solving Problems by Searching Paula Matuszek Spring, 2013. Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are in turn based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA.

lawson
Download Presentation

CS 8520: Artificial Intelligence

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. CS 8520: Artificial Intelligence Solving Problems by Searching Paula Matuszek Spring, 2013 Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are in turn based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  2. Problem-Solving Agents • A goal-based agent is essentially solving a problem • Given some state and some goal, • Figure out how to get from the current state to the goal • By taking some sequence of actions. • The problem is defined as a state space and a goal. Solving the problem consists of searching the state space for the sequence of actions that leads to the goal. Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  3. 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 Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  4. Example: Romania Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  5. Single-state problem formulation • A problem is defined by five items: • initial state e.g., "at Arad" • actions or successor function S(x) = set of action–state pairs • e.g., S(Arad) = {<Arad to Zerind, Zerind>, … } • transition model: new state resulting from action • 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 Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  6. Selecting a state space • Real world is absurdly complex • therefore state space must be abstracted for problem solving • (Abstract) state = set of real states • (Abstract) action = complex combination of real actions • e.g., "Arad to Zerind" represents a complex set of possible routes, detours, rest stops, etc. • For guaranteed realizability, any real state "in Arad“ must get to some real state "in Zerind" • (Abstract) solution = • set of real paths that are solutions in the real world • Each abstract action should be "easier" than the original problem Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  7. Vacuum world state space graph • States? Actions? Transition Models? Goal Test? Path Cost? Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  8. Vacuum world state space graph • states? integer dirt and robot location • actions? Left, Right, Suck • transition models? In A, in B, clean • goal test? no dirt at all locations • path cost? 1 per action Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  9. Example: The 8-puzzle • states? • actions? • transition model? • goal test? • path cost? Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  10. Example: The 8-puzzle • states? locations of tiles • actions? move blank left, right, up, down • transition model? square with tile moved. • goal test? = goal state (given) • path cost? 1 per move [Note: optimal solution of n-Puzzle family is NP-hard] Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  11. Search • The basic concept of search views the state space as a search tree • Initial state is the root node • Each possible action leads to a new node defined by the transition model • Some nodes are identified as goals • Search is the process of expanding some portion of the tree in some order until we get to a goal node • The strategy we use to choose the order to expand nodes defines the type of search Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  12. Tree search algorithms • Basic idea: • offline, simulated exploration of state space by generating successors of already-explored states (a.k.a.~expanding states) Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  13. Tree search example Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  14. Tree search example Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  15. Tree search example Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  16. Implementation: general tree search Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  17. Implementation: states vs. nodes • A state is a (representation of) a physical configuration • A node is a data structure constituting part of a search tree includes state, parent node, action, path cost g(x), depth • The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states. Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  18. Search strategies • A search strategy is defined by picking the order of node expansion. (e.g., breadth-first, depth-first) • 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 infinite) Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  19. Summary • Problem-solving agents search through a problem or state space for an acceptable solution. • A state space can be specified by • An initial state • Actions • A transition model or successor function S(x) describing the results of actions • A goal test or goal state • A path cost • A solution is a sequence of actions leading from the initial state to a goal state • The formalization of a good state space is hard, and critical to success. It must abstract the essence of the problem so that • It is easier than the real-world problem. • A solution can be found. • The solution maps back to the real-world problem and solves it. Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  20. 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 Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  21. Implementation: general tree search Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  22. Breadth-first search • Expand shallowest unexpanded node • Implementation: • fringe is a FIFO queue, i.e., new successors go at end Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  23. Breadth-first search • Expand shallowest unexpanded node • Implementation: • fringe is a FIFO queue, i.e., new successors go at end Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  24. Breadth-first search • Expand shallowest unexpanded node • Implementation: • fringe is a FIFO queue, i.e., new successors go at end Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  25. Breadth-first search • Expand shallowest unexpanded node • Implementation: • fringe is a FIFO queue, i.e., new successors go at end Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  26. 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) Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  27. 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 >= epsilon (otherwise can loop) • Time and space? O(b(ceiling(C*/ epsilon))) where C* is the cost of the optimal solution and epsilon is the smallest step cost. Can be much worse than breadth-first if many small steps not on optimal path • Optimal? Yes – nodes expanded in increasing order of g(n) Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  28. Uniform Cost Search Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  29. Depth-first search • Expand deepest unexpanded node • Implementation: • fringe = LIFO queue, i.e., put successors at front Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  30. Depth-first search • Expand deepest unexpanded node • Implementation: • fringe = LIFO queue, i.e., put successors at front Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  31. Depth-first search • Expand deepest unexpanded node • Implementation: • fringe = LIFO queue, i.e., put successors at front Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  32. Depth-first search • Expand deepest unexpanded node • Implementation: • fringe = LIFO queue, i.e., put successors at front Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  33. Depth-first search • Expand deepest unexpanded node • Implementation: • fringe = LIFO queue, i.e., put successors at front Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  34. Depth-first search • Expand deepest unexpanded node • Implementation: • fringe = LIFO queue, i.e., put successors at front Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  35. Properties of depth-first search • Complete? No: fails in infinite-depth spaces, spaces with loops • Modify to avoid repeated states along path • then complete in finite spaces • Time? O(bm): terrible if m is much larger than d • but if solutions are dense, may be much faster than breadth-first • Space? O(bm), i.e., linear space! • Optimal? No Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  36. Depth-limited search • = depth-first search with depth limit l • Nodes at depth l have no successors • Solves problem of infinite depth • Incomplete • Recursive implementation: Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  37. Iterative deepening search • Repeated Depth-Limited search, incrementing limit l until a solution is found or failure. • Repeats earlier steps at each new level, so inefficient -- but never more than doubles cost • No longer incomplete Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  38. Iterative deepening search l =0 Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  39. Iterative deepening search l =1 Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  40. Iterative deepening search l =2 Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  41. Iterative deepening search l =3 Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  42. Properties of iterative deepening • Complete? Yes • Time? (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd) • Space? O(bd) • Optimal? Yes, if step cost = 1 Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  43. Summary of Algorithms for Uninformed Search Where: b is branching factor d is depth of shallowest solution, m is max depth of search tree C* is cost of optimal solution ε is the smallest step size Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  44. A Caution: Repeated States • Failure to detect repeated states can turn a linear problem into an exponential one, or even an infinite one. • For example: 8-puzzle • Simple repeat -- empty square simply moves back and forth • More complex repeats also possible. • Save list of expanded states -- the closed list. • Add new state to fringe only if it's not in closed list. Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

  45. Summary: Uninformed Search • Problem formulation usually requires abstracting away real-world details to define a state space that can feasibly be explored • There exists a variety of uninformed search strategies • Search strategies can be evaluated by • whether they find a solution if one exists: completeness • how long they take: time complexity • how much memory they take: space complexity • whether they find the best solution: optimality • Iterative deepening search uses linear space and not much more time than other algorithms: usual choice Slides based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf. Diagrams are based on AIMA. CSC 8520 Spring 2013. Paula Matuszek

More Related