CSPs
CSPs
(CSPs)
Constraint satisfaction problems (CSPs)
• Standard search problem: state is a "black box“ – any
data structure that supports successor function and goal test
– state is defined by variables Xi with values from domain
Di
– goal test is a set of constraints specifying allowable
combinations of values for subsets of variables
• Continuous variables
– e.g., start/end times for Hubble Space Telescope observations
– linear constraints solvable in polynomial time by LP
Varieties of constraints
• Unary constraints involve a single variable,
– e.g., SA ≠ green
• Variables: F T U W R O X1 X2 X3
• Domains: {0,1,2,3,4,5,6,7,8,9}
• Constraints: Alldiff (F,T,U,W,R,O)
O + O = R + 10 · X1
X1 + W + W = U + 10 · X2
X2 + T + T = O + 10 · X3
X =F
Real-world CSPs
• Assignment problems
– e.g., who teaches what class
• Timetabling problems
– e.g., which class is offered when and
where?
• Transportation scheduling
• Factory scheduling
• Notice that many real-world problems
involve real-valued variables
Standard search formulation (incremental)
Let's start with the straightforward approach, then fix it
States are defined by the values assigned so far
• Initial state: the empty assignment { }
• Successor function: assign a value to an unassigned variable that does
not conflict with current assignment
fail if no legal assignments
• Goal test: the current assignment is complete
•
Backtracking search
• Variable assignments are commutative, i.e.,
[ WA = red then NT = green ] same as [ NT = green
then WA = red ]
• => Only need to consider assignments to a single
variable at each node
–
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
–
•
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
• To apply to CSPs:
– allow states with unsatisfied constraints
– operators reassign variable values
• Given random initial state, can solve n-queens in almost constant time
for arbitrary n with high probability (e.g., n = 10,000,000)
•
•
•
Summary
• CSPs are a special kind of problem:
– states defined by values of a fixed set of variables
– goal test defined by constraints on variable values