solving problems by searching
play

Solving Problems by Searching Chapter 3 Ch. 03 p.1/49 Outline - PowerPoint PPT Presentation

Solving Problems by Searching Chapter 3 Ch. 03 p.1/49 Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms Ch. 03 p.2/49 Problem-solving agents


  1. Solving Problems by Searching Chapter 3 Ch. 03 – p.1/49

  2. Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms Ch. 03 – p.2/49

  3. � � � � � � Problem-solving agents function S IMPLE -P ROBLEM -S OLVING -A GENT ( percept ) returns an action inputs: percept a percept static: seq, an action sequence, initially empty state, some description of the current world state goal, a goal, initially null problem, a problem formulation state U PDATE -S TATE ( state,percept ) if seq is empty then do goal F ORMULATE -G OAL ( state ) problem F ORMULATE -P ROBLEM ( state,goal ) seq S EARCH ( problem ) action F IRST ( seq ) seq R EST ( seq ) return action Ch. 03 – p.3/49

  4. Problem-solving agents (cont’d) Restricted form of general agent This is offline problem solving; solution executed “eyes closed” Online problem solving involves acting without complete knowledge Assumes: static, observable, discrete, deterministic Ch. 03 – p.4/49

  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 Ch. 03 – p.5/49

  6. Example: Romania Oradea 71 Neamt 87 Zerind 151 75 Iasi Arad 140 92 Sibiu Fagaras 99 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 211 111 Pitesti Lugoj 97 70 98 Hirsova 85 146 Mehadia 101 Urziceni 86 75 138 Bucharest 120 Dobreta 90 Eforie Craiova Giurgiu Ch. 03 – p.6/49

  7. � � ✁ � ✁ ✁ � ✁ Problem types Deterministic, fully observable single-state problem Agent knows exactly which state it will be in; solution is a sequence Non-observable conformant problem Agent may have no idea where it is; solution (if any) is a sequence Nondeterministic and/or partially observable contingency problem percepts provide new information about current state solution is a tree or policy often interleave search, execution Unknown state space exploration problem (“online”) Ch. 03 – p.7/49

  8. Example: vacuum world 1 2 3 4 5 6 7 8 Ch. 03 – p.8/49

  9. � ✁ ✆ ☞ ✌ ✍ Example: vacuum world Single-state, start in #5. Solution?? ✠☛✡ ✂☎✄ ✝✟✞ Ch. 03 – p.9/49

  10. ✂ ✞ ✆ ✝ ✞ � ✝ ✞ ☎ ✝ ✁ ✞ ✟ ✠ ✌ ✞ � ✁ ✌ ☞ ✌ ☞ ☎ � ✁ ✞ ✂ ✞ ✄ ✞ ✞ ✍ ✆ ✞ ✝ ✞ ✞ ✞ ✟ ✠ ✆ Example: vacuum world Conformant, start in . e.g., goes to . ✂☎✄ Solution?? ✠☛✡ ✡☞☛ ✠☛✡ ✂☎✄ ✝✟✞ Ch. 03 – p.10/49

  11. ☞ � ✁ ✍ ✆ ✌ � ✂ ✁ ✝ Example: vacuum world Contingency, start in #5 or #7 Murphy’s Law: if a carpet can get dirty it will Local sensing: dirt, location only. Solution?? if then ✠☛✡ ✂☎✄ ✝✟✞ Ch. 03 – p.11/49

  12. ✘ ✂ ✠ ✌ ✁ ✝ ✣ ☎ ✝ ✝ ✁ ✢ ✔✘ ✝ ✘ ✙ ✑ ✟ ✆ ✂ ✔ ✦ ✥ ☎ � ✤ ☎ ✟ ✂ � ✁ ✔ ✟ ✠ ☎ � ✜ Single-state problem formulation A problem is defined by four items: initial state e.g., “at Arad” successor function ✁✄✂ = set of action–state pairs ✡☞☛ e.g., ✆✞✝ ✍✏✎ ✑✓✒ ✠✕✔ ✍✏✎ ✑✓✒ ✠✗✖ goal test , can be explicit , e.g., = “at Bucharest” implicit , e.g., ✚✏✛ path cost (additive) e.g., sum of distances, number of actions executed, etc. is the step cost , assumed to be A solution is a sequence of actions leading from the initial state to a goal state Ch. 03 – p.12/49

  13. ✁ ✌ Selecting a state space Real world is absurdly complex state space must be abstracted for problem solving (Abstract) state = set of real states (Abstract) action = complex combination of real actions e.g., “Arad 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! Ch. 03 – p.13/49

  14. Example: vacuum world state space graph R L R L S S R R L R L R L L S S S S R L R L S S Ch. 03 – p.14/49

  15. ✌ ✌ ✝ ✁ ☞ ✆ ✝ Example: vacuum world state space graph states: integer dirt and robot locations (ignore dirt amounts) actions: , , , ✡☞☛ ✠☛✡ �✂✁ ✄✆☎ ✂☎✄ goal test: no dirt path cost: 1 per action (0 for ) ✄✆☎ �✂✁ Ch. 03 – p.15/49

  16. Example: The 8-puzzle 7 2 4 1 2 5 6 3 4 5 8 3 1 6 7 8 Start State Goal State Ch. 03 – p.16/49

  17. � Example: The 8-puzzle states: integer locations of tiles (ignore intermediate positions) actions: move blank left, right, up, down (ignore unjamming etc.) goal test: = goal state (given) path cost: 1 per move Note: optimal solution of -Puzzle family is NP-hard Ch. 03 – p.17/49

  18. Example: robotic assembly P R R R R R Ch. 03 – p.18/49

  19. Example: robotic assembly states: real-valued coordinates of robot joint angles parts of the object to be assembled actions: continuous motions of robot joints goal test: complete assembly with no robot included! path cost: time to execute Ch. 03 – p.19/49

  20. Tree search algorithms Basic idea: offline, simulated exploration of state space by generating successors of already-explored states (a.k.a. expanding states) Ch. 03 – p.20/49

  21. Tree search algorithms function T REE -S EARCH ( problem, strategy ) returns a solution, or failure initialize the search tree using the initial state of problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to strategy if the node contains a goal state then return the corresponding solution else expand the node and add the resulting nodes to the search tree end Ch. 03 – p.21/49

  22. Tree search example (a) The initial state Arad Sibiu Timisoara Zerind Arad Fagaras Oradea Arad Lugoj Arad Oradea Rimnicu Vilcea (b) After expanding Arad Arad Sibiu Timisoara Zerind Arad Fagaras Oradea Arad Lugoj Arad Oradea Rimnicu Vilcea Arad (c) After expanding Sibiu Timisoara Sibiu Zerind Arad Fagaras Oradea Arad Lugoj Arad Oradea Rimnicu Vilcea Ch. 03 – p.22/49

  23. Implementation: states vs. nodes � P ARENT- N ODE A CTION = right Node 5 4 5 4 D EPTH = 6 P ATH- C OST = 6 6 1 8 6 1 8 S TATE 7 3 2 7 3 2 Ch. 03 – p.23/49

  24. ✄ � ✁ ✂ 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 parent , children , depth , path cost States do not have parents, children, depth, or path cost! The E XPAND function creates new nodes, filling in the various fields and using the S UCCESSOR F N of the problem to create the corresponding states. Ch. 03 – p.24/49

  25. � � � Implementation: general tree search function T REE -S EARCH ( problem, fringe ) returns a solution, or failure fringe I NSERT (M AKE -N ODE (I NITIAL -S TATE [ problem ]), fringe ) loop do if E MPTY ? ( fringe ) then return failure node R EMOVE -F IRST ( fringe ) if G OAL -T EST [ problem ] applied to S TATE [ node ] succeeds then return S OLUTION ( node ) fringe I NSERT -A LL (E XPAND ( node, problem ), fringe ) Ch. 03 – p.25/49

  26. � ✁ � � � � � � � Implementation: general tree search function E XPAND ( node, problem ) returns a set of nodes successors the empty set action, result for each in S UCCESSOR -F N [ problem ( S TATE [ node ]) do s a new N ODE S TATE [ s ] result P ARENT -N ODE [ s ] node A CTION [ s ] action P ATH -C OST [ s ] P ATH -C OST [ node ] + S TEP -C OST ( node,action,s ) D EPTH [ s ] D EPTH [ node ] +1 add s to successors return successors Ch. 03 – p.26/49

  27. Search strategies A 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/expanded space complexity —maximum number of nodes in memory optimality —does it always find a least-cost solution? Ch. 03 – p.27/49

  28. � � ✁ ✂ Search strategies Time and space complexity are measured in terms of —maximum branching factor of the search tree —depth of the least-cost solution —maximum depth of the state space (may be ) Ch. 03 – p.28/49

  29. Uninformed search strategies Uninformed 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 Iterative broadening search (not in the textbook) Ch. 03 – p.29/49

  30. Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end Ch. 03 – p.30/49

  31. Progress of breadth-first search A A A A B C B C B C B C E F G E F G E F G E F G D D D D Ch. 03 – p.31/49

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