CS 188: Artificial Intelligence Fall 2009AnnouncementsTodayA* ReviewA* Graph Search Gone WrongConsistencyMazeworld Demo!What is Search For?Constraint Satisfaction ProblemsExample: N-QueensSlide 13Example: Map-ColoringConstraint GraphsExample: CryptarithmeticExample: SudokuExample: The Waltz AlgorithmVarieties of CSPsVarieties of ConstraintsReal-World CSPsStandard Search FormulationSearch MethodsBacktracking SearchSlide 28Backtracking ExampleImproving BacktrackingMinimum Remaining ValuesDegree HeuristicLeast Constraining ValueForward CheckingConstraint PropagationArc ConsistencySlide 37Limitations of Arc ConsistencyDemo: Backtracking + ACSlide 40Problem StructureTree-Structured CSPsSlide 43Nearly Tree-Structured CSPsIterative Algorithms for CSPsExample: 4-QueensPerformance of Min-ConflictsSummaryLocal Search MethodsTypes of ProblemsHill ClimbingHill Climbing DiagramSimulated AnnealingSlide 54Beam SearchCS 188: Artificial IntelligenceFall 2009Lecture 4: Constraint Satisfaction9/8/2009Dan Klein – UC BerkeleyMultiple slides adapted from Stuart Russell or Andrew MooreAnnouncementsProject 1: Search is due MondayFind partners at end of lecture, in frontWritten 1: Search and CSPs out soonNewsgroup: check it outTodaySearch ConclusionConstraint Satisfaction ProblemsA* ReviewA* uses both backward costs g and forward estimate h: f(n) = g(n) + h(n)A* tree search is optimal with admissible heuristics (optimistic future cost estimates)Heuristic design is key: relaxed problems can helpA* Graph Search Gone WrongSABCG11123h=2h=1h=4h=1h=0S (0+2)A (1+4) B (1+1)C (2+1)G (5+0)C (3+1)G (6+0)SABCGState space graphSearch treeConsistency3ACGh=4h=11The story on Consistency:• Definition: cost(A to C) + h(C) ≥ h(A)• Consequence in search tree: Two nodes along a path: NA, NC g(NC) = g(NA) + cost(A to C) g(NC) + h(C) ≥ g(NA) + h(A)• The f value along a path never decreases• Non-decreasing f means you’re optimal to every state (not just goals)Mazeworld Demo!What is Search For?Models of the world: single agents, deterministic actions, fully observed state, discrete state spacePlanning: sequences of actionsThe path to the goal is the important thingPaths have various costs, depthsHeuristics to guide, fringe to keep backupsIdentification: assignments to variablesThe goal itself is important, not the pathAll paths at the same depth (for some formulations)CSPs are specialized for identification problems9Constraint Satisfaction ProblemsStandard search problems:State is a “black box”: arbitrary data structureGoal test: any function over statesSuccessor function can be anythingConstraint satisfaction problems (CSPs):A special subset of search problemsState is defined by variables Xi with values from a domain D (sometimes D depends on i)Goal test is a set of constraints specifying allowable combinations of values for subsets of variablesSimple example of a formal representation languageAllows useful general-purpose algorithms with more power than standard search algorithms10Example: N-QueensFormulation 1:Variables:Domains:Constraints11Example: N-QueensFormulation 2:Variables:Domains:Constraints:Implicit:Explicit:-or-Example: Map-ColoringVariables:Domain:Constraints: adjacent regions must have different colorsSolutions are assignments satisfying all constraints, e.g.: 14Constraint GraphsBinary CSP: each constraint relates (at most) two variablesBinary constraint graph: nodes are variables, arcs show constraintsGeneral-purpose CSP algorithms use the graph structure to speed up search. E.g., Tasmania is an independent subproblem!15Example: CryptarithmeticVariables (circles):Domains:Constraints (boxes):16Example: SudokuVariables:Each (open) squareDomains:{1,2,…,9}Constraints:9-way alldiff for each row9-way alldiff for each column9-way alldiff for each regionExample: The Waltz AlgorithmThe Waltz algorithm is for interpreting line drawings of solid polyhedraAn early example of a computation posed as a CSP Look at all intersectionsAdjacent intersections impose constraints on each other?18Varieties of CSPsDiscrete VariablesFinite domainsSize d means O(dn) complete assignmentsE.g., Boolean CSPs, including Boolean satisfiability (NP-complete)Infinite domains (integers, strings, etc.)E.g., job scheduling, variables are start/end times for each jobLinear constraints solvable, nonlinear undecidableContinuous variablesE.g., start/end times for Hubble Telescope observationsLinear constraints solvable in polynomial time by LP methods (see cs170 for a bit of this theory)21Varieties of ConstraintsVarieties of ConstraintsUnary constraints involve a single variable (equiv. to shrinking domains):Binary constraints involve pairs of variables:Higher-order constraints involve 3 or more variables: e.g., cryptarithmetic column constraintsPreferences (soft constraints):E.g., red is better than greenOften representable by a cost for each variable assignmentGives constrained optimization problems(We’ll ignore these until we get to Bayes’ nets) 22Real-World CSPsAssignment problems: e.g., who teaches what classTimetabling problems: e.g., which class is offered when and where?Hardware configurationTransportation schedulingFactory schedulingFloorplanningFault diagnosis… lots more!Many real-world problems involve real-valued variables…23Standard Search FormulationStandard search formulation of CSPs (incremental)Let's start with the straightforward, dumb approach, then fix itStates are defined by the values assigned so farInitial state: the empty assignment, {}Successor function: assign a value to an unassigned variableGoal test: the current assignment is complete and satisfies all constraintsSimplest CSP ever: two bits, constrained to be equal 24Search MethodsWhat does BFS do?What does DFS do?[demo]What’s the obvious problem here?What’s the slightly-less-obvious problem?25Backtracking SearchIdea 1: Only consider a single variable at each pointVariable assignments are commutative, so fix orderingI.e., [WA = red then NT = green] same as [NT = green then WA = red]Only need to consider assignments to a single variable at each stepHow many leaves are there?Idea 2: Only allow legal assignments at each
View Full Document