280 likes | 441 Views
Chapter 5. Constraint Satisfaction Problems (CSPs). Date:2004/3/17 Presenter: Shih, Ya-Ting. Outline. CSPs Backtracking search for CSPs Local search for CSP Problem structure. 1 CSPs. a type of Assignment Problems for problem solving
E N D
Chapter 5 Constraint Satisfaction Problems (CSPs) Date:2004/3/17Presenter: Shih, Ya-Ting
Outline • CSPs • Backtracking search for CSPs • Local search for CSP • Problem structure
1 CSPs • a type of Assignment Problems for problem solving • states & goal test : a standard, structured, & very simple representation • CSP is defined by –a set of variables, X1,X2,…,Xn,with values from domain D1,D2,…,Dn,and a set of constraints, C1,C2,…,Cn,specifying allowance combinations of values for subsets of variables
1 CSPs (cont.) • State is defined by an assignment of values to some or all of the variables,{ Xii= vi , Xjj= vj , … } • Consistent ( or legal) assignment is an assignment that does not violate any constraints. • Complete assignment is one in which every variable is mentioned. • Solution is a complete assignment that satisfies all the constraints.
1.1 Example: Map-Coloring NT Q WA SA NSW V T
1.3 Varieties of CSPs • Discrete variables- finite domains:eg. Mapping coloring、8-Queens puzzle - infinite domains: (integers , strings , etc.)need a constraint language eg. Job scheduling ,StartJob1+5<StartJob3 • Continuous variables eg. Hubble Space Telescope observation Linear programming problems
1.4 Varieties of Constraints • Unary constraint:involves a single variableeg. SA ≠ green • Binary constraint:involves pairs of variableseg. SA ≠ WA • Higher-order constraint:involves 3 or more variableseg. Cryptarithemetic puzzles (F5.2(a))(p.148) • Preference constrainteg. red is better than greenoften representable by a cost for each variable assignment constrained optimization problems
2 Backtracking search for CSPs • In all CSPs, variable assignment are commutative. (if…)eg. [ WA = red then NT = green ] same as [ NT = green then WA = red ] • Only need to consider assignment to a single value at each node. • Backtracking search-- a form of DSF search for CSP with single–variable assignments
2.2 Some Key Questions of Backtracking Search • Variable and value orderingwhich variable should be assigned next, and in what order should its values be tried? • Propagating information through constraintswhat are the implications of the current variable assignments for the other unassigned variables? • Intelligent backtrackingwhen a path fails– that is, a state is reached in which a variable has no legal value – can the search avoid repeating this failure in subsequent paths?
2.2.1 Most constrained variable • Minimum remaining variable (MRV) heuristicor Most constrained variable heuristicor Fail-First heuristic-- choose the variable with the fewer legal values
2.2.2 Most constraining variable • Degree heuristic-- tie-breaker among most constrained variables-- choose the variable with the most constrains on remaining variables
2.2.3 Least constraining value • Least-constraining-value heuristic-- try to leave the maximum flexibility for subsequent variable assignment-- prefer the value that rules out the fewest choices for the neighboring variables in the constraint graph
2.3 Constraint Propagation • Propagation the implications of a constraint on one variable onto other variables -- Forward checking-- Arc consistency (more stronger)
2.3.1 Forward Checking • Idea:Keep track of remaining legal values for unassigned variables. Terminate search when any variable has no legal values. • Whenever a variable X is assigned, the forward checking process looks at each unassigned variable Y that is connected to X by a constraint and deletes from Y’s domain. Any value that is inconsistent with the value chosen for X.
2.3.1 Forward Checking (cont.) WA NT Q NSW V SA T Initial domains After WA=red After Q=green After V=blue Figure 5.6 Partial assignment { WA=red, Q=green V=blue } is inconsistent with the constraint of the problem
2.3.2 Arc Consistency • Simplest form of propagation makes each arc consistent. • X→Y is consistent iff for every value x of X, there is some allowed y • Applying arc consistency has result in early detection of an inconsistency that is not detected by pure forward checking.
2.3.2 Arc Consistency (cont.-1) Consistent!!
2.3.2 Arc Consistency (cont.-2) Inconsistent!!
2.4 Intelligent backtracking • called chronological backtrackingcause the most recent decision point is revisited-- to go all the way back to one of the set of variables that caused the failure-- conflict set • The backjumping method backtracks to the most recent variable in the conflict set • Backjumping occurs when every value in a domain is in conflict with the current assignment .
2.4 Intelligent backtracking (cont.) • fixed variable ordering Q, NSW, V, T, SA, WA, NT • partial assignment {Q=red, NSW=green, V=blue, T=red} (conflict set for SA) every value violates a constraint 7 1 6 2 5 3 4
3 Local Search for CSP • min-conflicts heuristic choose value that violates the fewest constraints • 8-Queens problem