CS 188: Artificial Intelligence Spring 2007AnnouncementsThe pastTodayConstraint Satisfaction ProblemsExample: Map-ColoringSlide 7Constraint GraphsExample: CryptarithmeticVarieties of CSPsVarieties of ConstraintsReal-World CSPsStandard Search FormulationSearch MethodsCSP formulation as searchBacktracking SearchSlide 17Backtracking ExampleImproving BacktrackingMinimum Remaining ValuesDegree HeuristicLeast Constraining ValueForward CheckingConstraint PropagationArc ConsistencySlide 26Summary: ConsistencyLimitations of Arc ConsistencyK-ConsistencyStrong K-ConsistencyIterative Algorithms for CSPsExample: 4-QueensPerformance of Min-ConflictsExample: Boolean SatisfiabilityExample: 3-SATCSPs: QueriesProblem StructureTree-Structured CSPsSlide 39Slide 40Nearly Tree-Structured CSPsCSP SummaryCS 188: Artificial IntelligenceSpring 2007Lecture 6: CSP2/1/2007Srini Narayanan – ICSI and UC BerkeleyMany slides over the course adapted from Dan Klein, Stuart Russell or Andrew MooreAnnouncementsAssignment 2 is up (due 2/12)Search problemsUninformed searchHeuristic search: best-first and A*Construction of heuristics Local searchThe pastTodayCSPFormulationPropagationApplicationsConstraint Satisfaction ProblemsStandard search problems:State is a “black box”: any old data structureGoal test: any function over statesSuccessors: any map from states to sets of statesConstraint satisfaction problems (CSPs):State 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 algorithmsExample: Map-ColoringVariables:Domain:Constraints: adjacent regions must have different colorsSolutions are assignments satisfying all constraints, e.g.:Example: Map-ColoringSolutions are complete and consistent assignments, e.g., WA = red, NT = green,Q = red,NSW = green,V = red,SA = blue,T = greenConstraint GraphsBinary CSP: each constraint relates (at most) two variablesConstraint 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!Example: CryptarithmeticVariables:Domains:Constraints:Varieties 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 jobNeed a constraint language, e.g., StartJob1 + 5 < StartJob3Linear 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)Varieties 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)Real-World CSPsAssignment problems: e.g., who teaches what classTimetabling problems: e.g., which class is offered when and where?Hardware configurationSpreadsheetsTransportation schedulingFactory schedulingFloorplanningMany real-world problems involve real-valued variables…Standard 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 variablefail if no legal assignmentGoal test: the current assignment is complete and satisfies all constraintsSearch MethodsWhat does DFS do?What’s the obvious problem here?What’s the slightly-less-obvious problem?CSP formulation as search1. This is the same for all CSPs2. Every solution appears at depth n with n variables use depth-first search3. Path is irrelevant, so can also use complete-state formulation4. b = (n - l )d at depth l, hence n! · dn leavesBacktracking SearchIdea 1: Only consider a single variable at each point:Variable assignments are commutativeI.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 pointI.e. consider only values which do not conflict previous assignmentsMight have to do some computation to figure out whether a value is okDepth-first search for CSPs with these two improvements is called backtracking searchBacktracking search is the basic uninformed algorithm for CSPsCan solve n-queens for n 25Backtracking SearchWhat are the choice points?Backtracking ExampleImproving BacktrackingGeneral-purpose ideas can give huge gains in speed:Which variable should be assigned next?In what order should its values be tried?Can we detect inevitable failure early?Can we take advantage of problem structure?Minimum Remaining ValuesMinimum remaining values (MRV):Choose the variable with the fewest legal valuesWhy min rather than max?Called most constrained variable“Fail-fast” orderingDegree HeuristicTie-breaker among MRV variablesDegree heuristic:Choose the variable with the most constraints on remaining variablesWhy most rather than fewest constraints?Least Constraining ValueGiven a choice of variable:Choose the least constraining valueThe one that rules out the fewest values in the remaining variablesNote that it may take some computation to determine this!Why least rather than most?Combining these heuristics makes 1000 queens feasibleForward CheckingIdea: Keep track of remaining legal values for unassigned variablesIdea: Terminate when any variable has no legal valuesWASANTQNSWVConstraint PropagationForward checking propagates information from assigned to unassigned
View Full Document