DOC PREVIEW
Berkeley COMPSCI 188 - Lecture 2: Queue-Based Search

This preview shows page 1-2-3-4-5-6 out of 19 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1CS 188: Artificial IntelligenceFall 2007Lecture 2: Queue-Based Search8/31/2007Dan Klein – UC BerkeleyMany slides from either Stuart Russell or Andrew Moore Announcements Next week New room is 105 North Gate, starts Tuesday Check web page for sections (new coming) Lab Friday 10am to 5pm in Soda 275 Learn Python Come for whatever times you like Project 1.1 posted by weekend due 9/122Today Agents that Plan Ahead Search Problems Uniformed Search Methods Depth-First Search Breadth-First Search Uniform-Cost Search Heuristic Search Methods Greedy Search A* SearchReflex Agents Reflex agents: Choose action based on current percept and memory May have memory or a model of the world’s current state Do not consider the future consequences of their actions Can a reflex agent be rational?3Goal Based Agents Goal-based agents: Plan ahead Decisions based on (hypothesized) consequences of actions Must have a model of how the world evolves in response to actionsSearch Problems A search problem consists of: A state space A successor function A start state and a goal test A solution is a sequence of actions which transform the start state to a goal state“N”, 1.0“E”, 1.04Search Trees A search tree: This is a “what if” tree Start state at the root node Children correspond to successors Nodes labeled with states, correspond to PATHS to those statesFor most problems, can never actually build the whole tree So, have to find ways of using only the important parts of the tree!“E”, 1.0“N”, 1.0State Space Graphs There’s some big graph in which Each state is a node Each successor is an outgoing arc Important: For most problems we could never actually build this graph How many states in Pacman?SGdbpqcehafrLaughably tiny search graph for a tiny search problem5Example: RomaniaAnother Search Tree Search: Expand out possible plans Maintain a fringe of unexpanded plans Try to expand as few tree nodes as possible6General Tree Search Important ideas: Fringe Expansion Exploration strategy Main question: which fringe nodes to explore?Detailed pseudocodeis in the book!Example: Tree SearchSGdbpqcehafr7State Graphs vs Search TreesSabdpacephfrqq cGaqephfrqq cGaSGdbpqcehafrWe almost always construct both on demand – and we construct as little as possible.Each NODE in in the search tree is an entire PATH in the problem graph.Review: Depth First SearchSabdpacephfrqq cGaqephfrqq cGaSGdbpqcehafrqphfdbacerStrategy: expand deepest node firstImplementation: Fringe is a LIFO stack8Review: Breadth First SearchSabdpacephfrqq cGaqephfrqq cGaSGdbpqcehafrSearchTiersStrategy: expand shallowest node firstImplementation: Fringe is a FIFO queueSearch Algorithm Properties Complete? Guaranteed to find a solution if one exists?Optimal? Guaranteed to find the least cost path?Time complexity? Space complexity?Variables:Depth of the shallowest solutionsCost of least cost solutionC*Max depth of the search treemThe average branching factor B(the average number of successors)bNumber of states in the problemn9DFS Infinite paths make DFS incomplete… How can we fix this?SpaceTimeOptimalCompleteAlgorithmO(LMAX)O(BLMAX)NNDepth First SearchDFSSTARTGOALabN N Infinite InfiniteDFS With cycle checking, DFS is complete.  When is DFS optimal?w/ Path CheckingDFSSpaceTimeOptimalCompleteAlgorithmY NO(bm+1) O(bm)…b1 nodeb nodesb2nodesbmnodesm tiers10BFS When is BFS optimal?w/ Path CheckingDFSBFSSpaceTimeOptimalCompleteAlgorithmY NO(bm+1) O(bm)…b1 nodeb nodesb2nodesbmnodess tiersY N*O(bs+1) O(bs)bsnodesComparisons When will BFS outperform DFS? When will DFS outperform BFS?11Iterative DeepeningIterative deepening uses DFS as a subroutine:1. Do a DFS which only searches for paths of length 1 or less. (DFS gives up on any path of length 2)2. If “1” failed, do a DFS which only searches paths of length 2 or less.3. If “2” failed, do a DFS which only searches paths of length 3 or less.….and so on.BFSw/ Path CheckingDFSIDSpaceTimeOptimalCompleteAlgorithmY NO(bm+1) O(bm)Y N*O(bs+1) O(bs)Y N*O(bs+1) O(bs)…bCosts on ActionsNotice 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. STARTGOALdbpqcehafr2928182314415132212Uniform Cost SearchSabdpacephfrqq cGaqephfrqq cGaExpand cheapest node first:Fringe is a priority queueSGdbpqcehafr39116411571381011171106391128811512Cost contours2Priority Queue Refresherreturns the key with the lowest value, and removes it from the queue.pq.pop()inserts (key, value) into the queue.pq.push(key, value) A priority queue is a data structure in which you can insert and retrieve (key, value) pairs with the following operations: You can promote or demote keys by resetting their priorities Unlike a regular queue, insertions into a priority queue are notconstant time, usually O(log n) We’ll need priority queues for most cost-sensitive search methods.13Uniform Cost SearchBFSw/ Path CheckingDFSUCSSpaceTimeOptimalCompleteAlgorithmY NO(bm+1) O(bm)…bC*/εtiersY NO(bs+1) O(bs)Y* YO(C* bC*/ε) O(bC*/ε)We’ll talk more about uniform cost search’s failure cases later…Uniform Cost Problems Remember: explores increasing cost contours The good: UCS is complete and optimal! The bad: Explores options in every “direction” No information about goal locationStartGoal…c ≤ 3c ≤ 2c ≤ 114Best First / Greedy SearchBest First / Greedy Search Expand the node that seems closest… What can go wrong?15Best First / Greedy SearchSTARTGOALdbpqcehafr299811235344151252h=12h=11h=8h=8h=5h=4h=6h=9h=0h=4h=6h=11Best First / Greedy Search A common case: Best-first takes you straight to the (wrong) goal Worst-case: like a badly-guided DFS in the worst case Can explore everything Can get stuck in loops if no cycle checking Like DFS in completeness (finite states w/ cycle checking)…b…b16Search Gone Wrong?Extra Work? Failure to detect repeated states can cause exponentially more work. Why?17Graph Search In BFS, for example, we shouldn’t bother expanding the circled nodes (why?)Sabdpacephfrqq cGaqephfrqq cGaGraph Search Very simple fix: never expand a node twice Can this wreck completeness? Why or why not?18Best First Greedy


View Full Document

Berkeley COMPSCI 188 - Lecture 2: Queue-Based Search

Documents in this Course
CSP

CSP

42 pages

Metrics

Metrics

4 pages

HMMs II

HMMs II

19 pages

NLP

NLP

23 pages

Midterm

Midterm

9 pages

Agents

Agents

8 pages

Lecture 4

Lecture 4

53 pages

CSPs

CSPs

16 pages

Midterm

Midterm

6 pages

MDPs

MDPs

20 pages

mdps

mdps

2 pages

Games II

Games II

18 pages

Load more
Download Lecture 2: Queue-Based Search
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 2: Queue-Based Search and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 2: Queue-Based Search 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?