1 / 33

Lecture 1B: Search

Learn about problem types, search trees, uninformed and informed search strategies, heuristics, and state space graphs. Understand different search algorithms like DFS, BFS, uniform cost, greedy search, and A* search.

thome
Download Presentation

Lecture 1B: Search

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. Lecture 1B: Search

  2. Outline • Problem-solving agents (Book: 3.1) • Problem types and problem formulation • Search trees and state space graphs (3.3) • Uninformed search (3.4) • Depth-first, Breadth-first, Uniform cost • Search graphs • Informed search (3.5) • Greedy search, A* search • Heuristics, admissibility

  3. Agents act = AgentFn(percept) sensors agent fn actuators

  4. Problem types • Fully observable, deterministic • single-belief-state problem • Non-observable • sensorless (conformant) problem • Partially observable/non-deterministic • contingency problem • interleave search and execution • Unknown state space • exploration problem • execution first

  5. Search Problems • A searchproblem consists of: • A state space • A transition model • A start state, goal test, and path cost function • A solution is a sequence of actions (a plan) which transforms the start state to a goal state N, 1 E, 1

  6. Transition Models • Successor function • Successors( ) = {(N, 1, ), (E, 1, )} • Actions and Results • Actions( ) = {N, E} • Result( , N) = ; Result( , E) = • Cost( , N, ) = 1; Cost( , E, ) = 1

  7. Example: Romania • State space: • Cities • Successor function: • Go to adj city with cost = dist • Start state: • Arad • Goal test: • Is state == Bucharest? • Solution?

  8. G a c b e d f S h p r q State Space Graphs • State space graph: A mathematical representation of a search problem • For every search problem, there’s a corresponding state space graph • The successor function is represented by arcs • This can be large or infinite, so we won’t create it in memory Ridiculously tiny search graph for a tiny search problem

  9. Search Trees • A search tree: • This is a “what if” tree of plans and outcomes • Start state at the root node • Children correspond to successors • Nodes contain states, correspond to paths to those states • For most problems, we can never actually build the whole tree N, 1 E, 1

  10. Another Search Tree • Search: • Expand out possible plans • Maintain a frontier of unexpanded plans • Try to expand as few tree nodes as possible

  11. General Tree Search • Important ideas: • Frontier (aka fringe) • Expansion • Exploration strategy • Main question: which frontier nodes to explore?

  12. G a c b e d f S h S e e p d p r q q h h r r b c p p q q f f a a q q c c G G a a State Space vs. Search Tree • Each NODE in in the search tree is an entire PATH in the state space. • We construct both on demand – and we construct as little as possible.

  13. States vs. Nodes • Nodes in state space graphs are problem states • Represent an abstracted state of the world • Have successors, can be goal / non-goal, have multiple predecessors • Nodes in search trees are paths • Represent a path (sequence of actions) which results in the node’s state • Have a problem state andone parent, a path length, (a depth) & a cost • The same problem state may be achieved by multiple search tree nodes State Space Graph Search Tree Parent Depth 5 Action Node Depth 6

  14. G a c b e d f S S e e p h d Search Tiers q h h r r b c p r q p p q q f f a a q q c c G G a a Breadth First Search • Strategy: expand shallowest node first • Implementation: Fringe is a FIFO queue

  15. Santayana’s Warning • “Those who cannot remember the past are condemned to repeat it.” – George Santayana • Failure to detect repeated states can cause exponentially more work (why?)

  16. S e e p d q h h r r b c p p q q f f a a q q c c G G a a Graph Search • In BFS, for example, we shouldn’t bother expanding the circled nodes (why?)

  17. Graph Search • Very simple fix: never expand a state twice • Can this wreck completeness? Lowest cost?

  18. Graph Search Hints • Graph search is almost always better than tree search (when not?) • Implement explored as a dict or set • Implement frontier as priority Q and set

  19. G a c b a c b e d f e d f S h S h e e p d p r p q q q h h r r b c p p q q f f a a q q c c G G a a Depth First Search Strategy: expand deepest node first Implementation: Frontier is a LIFO stack r

  20. Notice that BFS finds the shortest path in terms of number of transitions. It does not find the least-cost path. We will quickly cover an algorithm which does find the least-cost path. GOAL a 2 2 c b 3 2 1 8 e 2 d 3 f 9 8 2 START h 4 1 1 4 15 p r q Costs on Actions

  21. G a c b e d f S h S e e p d p r q q h h r r b c p p q q f f a a q q c c G G a a Uniform Cost Search 2 8 1 Expand cheapest node first: Frontier is a priority queue 2 2 3 1 9 8 1 1 15 0 1 9 3 16 11 5 17 4 11 Cost contours 7 6 13 8 11 10

  22. Remember: explores increasing cost contours The good: UCS is complete and optimal! The bad: Explores options in every “direction” No information about goal location Uniform Cost Issues c  1 … c  2 c  3 Start Goal

  23. What will UCS do for this graph? What does this mean for completeness? Uniform Cost Search b 0 1 0 START a 1 GOAL

  24. AI Lesson To do more, Know more

  25. Heuristics

  26. Expand the node that seems closest to goal… What can go wrong? Greedy Best First Search

  27. Greedy goes wrong S G

  28. Uniform-costorders by path cost, or backward cost g(n) Best-firstorders by distance to goal, or forward cost h(n) A* Search orders by the sum: f(n) = g(n) + h(n) Combining UCS and Greedy 5 e h=1 1 1 3 2 S a d G h=6 h=5 1 h=2 h=0 1 c b h=7 h=6

  29. Should we stop when we enqueue a goal? No: only stop when we dequeue a goal When should A* terminate? A 2 2 h = 2 G S h = 3 h = 0 B 3 2 h = 1

  30. What went wrong? Actual bad path cost (5) < estimate good path cost (1+6) We need estimates (h=6) to be less than actual (3) costs! Is A* Optimal? 1 A 3 h = 6 h = 0 S G h = 7 5

  31. A heuristic h is admissible(optimistic) if: where is the true cost to a nearest goal Never overestimate! Admissible Heuristics

  32. Path finding / routing problems Resource planning problems Robot motion planning Language analysis Machine translation Speech recognition … Other A* Applications

  33. A* uses both backward costs, g(n), and (estimates of) forward costs, h(n) A* is optimal with admissible heuristics A* is not the final word in search algorithms(but it does get the final word for today) Summary: A*

More Related