CS 188: Artificial Intelligence Spring 2006AdministriviaTodayExample: RomaniaSingle State ProblemsSearch Gone Wrong?Example: Vacuum WorldExample: 8-PuzzleExample: N-QueensExample: AssemblySlide 11A Search TreeTree SearchSlide 14States vs. NodesA Search GraphDepth First SearchSearch Algorithm PropertiesDFSSlide 20Breadth First SearchBFSComparisonsCosts on ActionsUniform Cost SearchPriority Queue RefresherSlide 27Slide 28Iterative DeepeningExtra Work?Graph SearchSlide 32Uniform Cost IssuesGreedy SearchSlide 35Euclidian HeuristicBest First Greedy SearchCS 188: Artificial IntelligenceSpring 2006Lecture 3: Search1/24/2006Dan Klein – UC BerkeleyMany slides from either Stuart Russell or Andrew MooreAdministriviaFinal Exam IssuesSections: starting 1/30101 (M 10am): B0051 Hildebrand104 (M 4pm): 002 EvansWritten Assignment 1Reminder: can solve in groupsBut: individual write-upsTodayFormulating Search ProblemsUniformed SearchDepth-First SearchBreadth-First SearchUniform-Cost SearchProperties of Search AlgorithmsExample: RomaniaSingle State ProblemsA search problem is defined by four items:Initial state: e.g. AradSuccessor function S(x) = set of action–state pairs:e.g., S(Arad) = {<Arad Zerind, Zerind>, … }Goal test, can beexplicit, e.g., x = Bucharestimplicit, 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 ≥ 0A solution is a sequence of actions leading from the initial state to a goal stateSearch Gone Wrong?Example: Vacuum WorldCan represent problem as a state graphNodes are statesArcs are actionsArc weights are costsExample: 8-PuzzleWhat are the states?What are the actions?What states can I reach from the start state?What should the costs be?Example: N-QueensWhat are the states?What is the start?What is the goal?What are the actions?What should the costs be?Example: AssemblyWhat are the states?What is the goal?What are the actions?What should the costs be?Example: RomaniaA Search TreeSearch trees:Represent the branching paths through a state graph.Usually much larger than the state graph.Can a finite state graph give an infinite search tree?Tree SearchBasic solution method for graph problemsOffline simulated exploration of state spaceSearching a model of the space, not the real worldTree SearchStates vs. NodesProblem graphs have problem statesHave successorsSearch trees have search nodesHave parents, children, depth, path cost, etc.Expand uses successor function to create new search tree nodesThe same problem state may be in multiple search tree nodesA Search GraphHow do we get from S to G? And what’s the smallest possible number of transitions?STARTGOALdbpqcehafrDepth First SearchSabdpacephfrqq cGaqephfrqq cGaSGdbpqcehafrqphfdbacerExpand deepest node first:Fringe is a LIFO stackSearch Algorithm PropertiesComplete? Guaranteed to find a solution if one exists?Optimal? Guaranteed to find the least cost path?Time complexity?Space complexity?Variables:nNumber of states in the problembThe average branching factor B(the average number of successors)C*Cost of least cost solutionsDepth of the shallowest solutionmMax depth of the search treeDFSInfinite paths make DFS incomplete…How can we fix this?Algorithm Complete Optimal Time SpaceDFSDepth First SearchN NO(BLMAX) O(LMAX)STARTGOALabN N Infinite InfiniteDFSWith cycle checking, DFS is complete. When is DFS optimal?Algorithm Complete Optimal Time SpaceDFSw/ Path CheckingY N O(bm+1) O(bm )…b1 nodeb nodesb2 nodesbm nodesm tiersBreadth First SearchSabdpacephfrqq cGaqephfrqq cGaSGdbpqcehafrSearchTiersExpand shallowest node first:Fringe is a FIFO queueBFSWhen is BFS optimal?Algorithm Complete Optimal Time SpaceDFSw/ Path CheckingBFSY N O(bm+1) O(bm )…b1 nodeb nodesb2 nodesbm nodess tiersY N* O(bs+1) O(bs)bs nodesComparisonsWhen will BFS outperform DFS?When will DFS outperform BFS?Costs 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. STARTGOALdbpqcehafr29281823144151322Uniform Cost SearchSabdpacephfrqq cGaqephfrqq cGaExpand cheapest node first:Fringe is a priority queueSGdbpqcehafr39116411571381011171106391128811512Cost contours2Priority Queue Refresherpq.setPriority(key, value)inserts (key, value) into the queue.pq.dequeue()returns the key with the lowest value, and removes it from the queue.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 prioritiesUnlike a regular queue, insertions into a priority queue are not constant time, usually O(log n)We’ll need priority queues for most cost-sensitive search methods.Uniform Cost SearchWhat will UCS do for this graph?What does this mean for completeness?STARTGOALab1100Uniform Cost SearchAlgorithm Complete Optimal Time SpaceDFSw/ Path CheckingBFSUCSY N O(bm+1) O(bm )…bC*/ tiersY N O(bs+1) O(bs)Y* Y O(C* bC*/) O(bC*/)We’ll talk more about uniform cost search’s failure cases next class…Iterative 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.Algorithm Complete Optimal Time SpaceDFSw/ Path CheckingBFSIDY N O(bm+1) O(bm )Y N* O(bs+1) O(bs)Y N* O(bd+1) O(bd)…bExtra Work?Failure to detect repeated states can cause exponentially more work. Why?Graph SearchIn BFS, for example, we shouldn’t bother expanding the circled nodes (why?)Sabdpacephfrqq cGaqephfrqq cGaGraph SearchVery simple fix: never expand a node twiceUniform Cost IssuesWhere will uniform cost explore?Why?What is wrong here?StartGoalGreedy SearchGreedy SearchExpand the node that seems closest…What can go wrong?Euclidian HeuristicSTARTGOALdbpqcehafr299811235344151252h=12h=11h=8h=8h=5h=4h=6h=9h=0h=4h=6h=11Best First Greedy SearchAlgorithm Complete Optimal Time SpaceGreedy Best-First SearchWhat do we need to do to make it complete?Can we make it
View Full Document