cs 188 artificial intelligence
play

CS 188: Artificial Intelligence Search Instructor: Anca Dragan - PowerPoint PPT Presentation

CS 188: Artificial Intelligence Search Instructor: Anca Dragan University of California, Berkeley [These slides adapted from Dan Klein and Pieter Abbeel] Today o Agents that Plan Ahead o Search Problems o Uninformed Search Methods o Depth-First


  1. CS 188: Artificial Intelligence Search Instructor: Anca Dragan University of California, Berkeley [These slides adapted from Dan Klein and Pieter Abbeel]

  2. Today o Agents that Plan Ahead o Search Problems o Uninformed Search Methods o Depth-First Search o Breadth-First Search o Uniform-Cost Search

  3. Agents that Plan

  4. Reflex Agents o Reflex agents: o Choose action based on current percept (and maybe memory) o May have memory or a model of the world’s current state o Do not consider the future consequences of their actions o Consider how the world IS o Can a reflex agent be rational? [Demo: reflex optimal (L2D1)] [Demo: reflex optimal (L2D2)]

  5. Video of Demo Reflex Optimal

  6. Video of Demo Reflex Odd

  7. Planning Agents o Planning agents: o Ask “what if” o Decisions based on (hypothesized) consequences of actions o Must have a model of how the world evolves in response to actions o Must formulate a goal (test) o Consider how the world WOULD BE o Optimal vs. complete planning o Planning vs. replanning [Demo: re-planning (L2D3)] [Demo: mastermind (L2D4)]

  8. Video of Demo Replanning

  9. Video of Demo Mastermind

  10. Search Problems

  11. Search Problems o A search problem consists of: o A state space “N”, 1.0 o A successor function (with actions, costs) “E”, 1.0 o A start state and a goal test o A solution is a sequence of actions (a plan) which transforms the start state to a goal state

  12. Search Problems Are Models

  13. Example: Traveling in Romania o State space: o Cities o Successor function: o Roads: Go to adjacent city with cost = distance o Start state: o Arad o Goal test: o Is state == Bucharest? o Solution?

  14. What’s in a State Space? The world state includes every last detail of the environment A search state keeps only the details needed for planning (abstraction) o Problem: Pathing o Problem: Eat-All-Dots o States: (x,y) location o States: {(x,y), dot booleans} o Actions: NSEW o Actions: NSEW o Successor: update location o Successor: update location only and possibly a dot boolean o Goal test: is (x,y)=END o Goal test: dots all false

  15. State Space Sizes? o World state: o Agent positions: 120 o Food count: 30 o Ghost positions: 12 o Agent facing: NSEW o How many o World states? 120x(2 30 )x(12 2 )x4 o States for pathing? 120 o States for eat-all-dots? 120x(2 30 )

  16. Safe Passage o Problem: eat all dots while keeping the ghosts perma-scared o What does the state space have to specify? o (agent position, dot booleans, power pellet booleans, remaining scared time)

  17. State Space Graphs and Search Trees

  18. State Space Graphs o State space graph: A mathematical representation of a search problem o Nodes are (abstracted) world configurations o Arcs represent successors (action results) o The goal test is a set of goal nodes (maybe only one) o In a state space graph, each state occurs only once! o We can rarely build this full graph in memory (it’s too big), but it’s a useful idea

  19. State Space Graphs o State space graph: A mathematical G a representation of a search problem c b o Nodes are (abstracted) world configurations o Arcs represent successors (action results) e d o The goal test is a set of goal nodes (maybe only f one) S h p r q o In a search graph, each state occurs only once! Tiny search graph for a tiny search problem o We can rarely build this full graph in memory (it’s too big), but it’s a useful idea

  20. Search Trees This is now / start “N”, 1.0 “E”, 1.0 Possible futures o A search tree: o A “what if” tree of plans and their outcomes o The start state is the root node o Children correspond to successors o Nodes show states, but correspond to PLANS that achieve those states o For most problems, we can never actually build the whole tree

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

  22. State Space Graphs vs. Search Trees Consider this 4-state graph: How big is its search tree (from S)? a G S b

  23. State Space Graphs vs. Search Trees Consider this 4-state graph: How big is its search tree (from S)? s a a b G S b G a G a G b G b … … Important: Lots of repeated structure in the search tree!

  24. Tree Search

  25. Search Example: Romania

  26. Searching with a Search Tree o Search: o Expand out potential plans (tree nodes) o Maintain a fringe of partial plans under consideration o Try to expand as few tree nodes as possible

  27. General Tree Search o Important ideas: o Fringe o Expansion o Exploration strategy o Main question: which fringe nodes to explore?

  28. Example: Tree Search G a c b e d f S h p r q

  29. Example: Tree Search G a c b e e d d f f S h p r r q s S s à d e p s à e d s à p q e h r c s à d à b b s à d à c h r p q f a a s à d à e s à d à e à h q c G p q f s à d à e à r s à d à e à r à f a q c G s à d à e à r à f à c s à d à e à r à f à G a

  30. Depth-First Search

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

  32. Search Algorithm Properties

  33. Search Algorithm Properties o Complete: Guaranteed to find a solution if one exists? o Optimal: Guaranteed to find the least cost path? o Time complexity? 1 node o Space complexity? b b nodes … b 2 nodes o Cartoon of search tree: m tiers o b is the branching factor o m is the maximum depth o solutions at various depths b m nodes o Number of nodes in entire tree? o 1 + b + b 2 + …. b m = O(b m )

  34. Depth-First Search (DFS) Properties o What nodes DFS expand? o Some left prefix of the tree. 1 node b o Could process the whole tree! b nodes … o If m is finite, takes time O(b m ) b 2 nodes m tiers o How much space does the fringe take? o Only has siblings on path to root, so O(bm) o Is it complete? b m nodes o m could be infinite, so only if we prevent cycles (more later) o Is it optimal? o No, it finds the “leftmost” solution, regardless of depth or cost

  35. Breadth-First Search

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

  37. Breadth-First Search (BFS) Properties o What nodes does BFS expand? o Processes all nodes above shallowest 1 node b solution b nodes … s tiers o Let depth of shallowest solution be s b 2 nodes o Search takes time O(b s ) b s nodes o How much space does the fringe take? b m nodes o Has roughly the last tier, so O(b s ) o Is it complete? o s must be finite if a solution exists, so yes! o Is it optimal? o Only if costs are all 1 (more on costs later)

  38. Quiz: DFS vs BFS

  39. DFS vs BFS o When will BFS outperform DFS? o When will DFS outperform BFS? [Demo: dfs/bfs maze water (L2D6)]

  40. Video of Demo Maze Water DFS/BFS (part 1)

  41. Video of Demo Maze Water DFS/BFS (part 2)

  42. Iterative Deepening o Idea: get DFS’s space advantage with BFS’s time / shallow-solution b advantages … o Run a DFS with depth limit 1. If no solution… o Run a DFS with depth limit 2. If no solution… o Run a DFS with depth limit 3. ….. o Isn’t that wastefully redundant? o Generally most work happens in the lowest level searched, so not so bad!

  43. Cost-Sensitive Search GOAL a 2 2 c b 3 2 1 8 2 e d 3 f 9 8 2 START h 4 2 1 4 p r 15 q BFS finds the shortest path in terms of number of actions. How? It does not find the least-cost path. We will now cover a similar algorithm which does find the least-cost path.

  44. Uniform Cost Search

  45. Uniform Cost Search 2 G a Strategy: expand a c b 8 1 cheapest node first: 2 2 e 3 d f 9 2 Fringe is a priority queue 8 S h 1 (priority: cumulative cost) 1 p r q 15 0 S 9 1 e p 3 d q 16 11 5 17 e h r b 4 c 11 Cost 6 13 7 h r p q f a a contours q c 8 p q f G a q c 11 10 G a

  46. Uniform Cost Search (UCS) Properties o What nodes does UCS expand? o Processes all nodes with cost less than cheapest solution! b c £ 1 o If that solution costs C* and arcs cost at least e , then the … “effective depth” is roughly C*/ e c £ 2 C*/ e “tiers” o Takes time O(b C*/ e ) (exponential in effective depth) c £ 3 o How much space does the fringe take? o Has roughly the last tier, so O(b C*/ e ) o Is it complete? o Assuming best solution has a finite cost and minimum arc cost is positive, yes! o Is it optimal? o Yes! (Proof next lecture via A*)

  47. Uniform Cost Issues o Remember: UCS explores increasing c £ 1 … cost contours c £ 2 c £ 3 o The good: UCS is complete and optimal! o The bad: o Explores options in every “direction” Start Goal o No information about goal location [Demo: empty grid UCS (L2D5)] [Demo: maze with deep/shallow o We’ll fix that soon! water DFS/BFS/UCS (L2D7)]

  48. Video of Demo Empty UCS

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