Constraint Satisfaction Problems
Subset of search
Find values for a set of variables, subject to constraints
Variables can be discrete or continuous
Key terms
Assignment
- Consistent/Legal Assignment
- Partial Assignment
- Complete Assignment
Solution
Constraint Types
Unary
Binary
N-ary
Consider Sudoku
Let's write this as a CSP
Recall N Queens
Let's write this as a CSP
Think about Class Scheduling
Graph-Coloring/Map-Coloring
How can we solve these?
Consider this graph
Try BFS/DFS
Consider this graph
Try BFS/DFS
Better Ordering
Min Remaining Values (vertex)
Degree (vertex)
Least Constraining Value (var value)
Forward Checking / Look Ahead
Constraint Propagation
Choices for one variable limit choices for the next ...
Local consistency $\rightarrow$ Global consistency
Consider Binary constraints
Constraint Propagation
Node Consistency
Every value in domain satisfies unary constraints
E.g.,
$X=\{x\}$
$D(x) = \mathbb{Z^+}$
$C=\{(x < 8), (x\ge 5)\}$
The restricted domain $D(x)=\{5,6,7\}$ makes $x$ node-consistent
Constraint Propagation
Arc/Edge Consistency
Applies to binary constraints and defined over pairs of variables
$\forall\ x\in D(x), \exists\ y\in D(y)$ such that $(x,y)$ satisfy all binary constraints over $x$ and $y$
(Every value in domain of $x$ has a legal value in domain of $y$)
A CSP is arc-consistent if all pairs of variables are arc-consistent
Constraint Propagation
Arc/Edge Consistency
(Every value in domain of $x$ has a legal value in domain of $y$)
E.g.,
$X=\{x, y\}$
$D(x) = D(y) = \mathbb{Z}_{[0,9]}$
$C=\{(y = x^2)\}$
The following restricted domain set makes $x$ arc-consistent wrt $y$
$D(x) = \{0,1,2,3\}$
$D(y) = \{0,1,4,9\}$
Constraint Propagation
Arc/Edge Consistency
Is arc-consistency symmetric?
$X=\{x, y\}$
$D(x) = \{2,3,4,5\}, D(y) = \{1,3,4,5,6\}$
$C=\{(x < y)\}$
$\forall\ x\in D(x), \exists\ y\in D(y);\; x < y$
However...
$\nexists\ x\in D(x)\ \forall\ y\in D(y);\; x < y$
Constraint Propagation
Path Consistency
A 2-variable set $(x, y)$ is path-consistent with a third variable, $z$ if
$\forall\ \textrm{valid assignments } (x=a, y=b), \exists\ (z=c)$
that satisfies constraints on $(x, z)$ and $(z, y)$
Constraint Propagation
Path Consistency
$\forall\ \textrm{valid assignments } (x=a, y=b), \exists\ (z=c)$
that satisfies constraints on $(x, z)$ and $(z, y)$
Constraint Propagation
Path Consistency
$\forall\ \textrm{valid assignments } (x=a, y=b), \exists\ (z=c)$
that satisfies constraints on $(x, z)$ and $(z, y)$
Constraint Propagation
$k$-Consistency
For every valid assignment to a set of $k-1$ variables,
there exists a valid assignment to the $k^{th}$ variable
Does not imply $k-1$ consistency
$x < 3$
$x < y$
$x + y = z$
$D(x) = \{2, 4\}$
$D(y) = \{1, 3\}$
$D(z) = \{3, 4, 5\}$