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
Think about
Map Coloring
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
}
X=\{x\}
X
=
{
x
}
D
(
x
)
=
Z
+
D(x) = \mathbb{Z^+}
D
(
x
)
=
Z
+
C
=
{
(
x
<
8
)
,
(
x
≥
5
)
}
C=\{(x < 8), (x\ge 5)\}
C
=
{(
x
<
8
)
,
(
x
≥
5
)}
The restricted domain
D
(
x
)
=
{
5
,
6
,
7
}
D(x)=\{5,6,7\}
D
(
x
)
=
{
5
,
6
,
7
}
makes
x
x
x
node-consistent
Constraint Propagation
Arc/Edge Consistency
Applies to binary constraints and defined over pairs of variables
∀
x
∈
D
(
x
)
,
∃
y
∈
D
(
y
)
\forall\ x\in D(x), \exists\ y\in D(y)
∀
x
∈
D
(
x
)
,
∃
y
∈
D
(
y
)
such that
(
x
,
y
)
(x,y)
(
x
,
y
)
satisfy all binary constraints over
x
x
x
and
y
y
y
(Every value in domain of
x
x
x
has a legal value in domain of
y
y
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
x
x
has a legal value in domain of
y
y
y
)
E.g.,
X
=
{
x
,
y
}
X=\{x, y\}
X
=
{
x
,
y
}
D
(
x
)
=
D
(
y
)
=
Z
[
0
,
9
]
D(x) = D(y) = \mathbb{Z}_{[0,9]}
D
(
x
)
=
D
(
y
)
=
Z
[
0
,
9
]
C
=
{
(
y
=
x
2
)
}
C=\{(y = x^2)\}
C
=
{(
y
=
x
2
)}
The following restricted domain set makes
x
x
x
arc-consistent wrt
y
y
y
D
(
x
)
=
{
0
,
1
,
2
,
3
}
D(x) = \{0,1,2,3\}
D
(
x
)
=
{
0
,
1
,
2
,
3
}
D
(
y
)
=
{
0
,
1
,
4
,
9
}
D(y) = \{0,1,4,9\}
D
(
y
)
=
{
0
,
1
,
4
,
9
}
Constraint Propagation
Arc/Edge Consistency
Is arc-consistency symmetric?
X
=
{
x
,
y
}
X=\{x, y\}
X
=
{
x
,
y
}
D
(
x
)
=
{
2
,
3
,
4
,
5
}
,
D
(
y
)
=
{
1
,
3
,
4
,
5
,
6
}
D(x) = \{2,3,4,5\}, D(y) = \{1,3,4,5,6\}
D
(
x
)
=
{
2
,
3
,
4
,
5
}
,
D
(
y
)
=
{
1
,
3
,
4
,
5
,
6
}
C
=
{
(
x
<
y
)
}
C=\{(x < y)\}
C
=
{(
x
<
y
)}
∀
x
∈
D
(
x
)
,
∃
y
∈
D
(
y
)
;
x
<
y
\forall\ x\in D(x), \exists\ y\in D(y);\; x < y
∀
x
∈
D
(
x
)
,
∃
y
∈
D
(
y
)
;
x
<
y
However...
∄
x
∈
D
(
x
)
∀
y
∈
D
(
y
)
;
x
<
y
\nexists\ x\in D(x)\ \forall\ y\in D(y);\; x < y
∄
x
∈
D
(
x
)
∀
y
∈
D
(
y
)
;
x
<
y
Constraint Propagation
Path Consistency
A 2-variable set
(
x
,
y
)
(x, y)
(
x
,
y
)
is path-consistent with a third variable,
z
z
z
if
∀
valid assignments
(
x
=
a
,
y
=
b
)
,
∃
(
z
=
c
)
\forall\ \textrm{valid assignments } (x=a, y=b), \exists\ (z=c)
∀
valid assignments
(
x
=
a
,
y
=
b
)
,
∃
(
z
=
c
)
that satisfies constraints on
(
x
,
z
)
(x, z)
(
x
,
z
)
and
(
z
,
y
)
(z, y)
(
z
,
y
)
Constraint Propagation
Path Consistency
∀
valid assignments
(
x
=
a
,
y
=
b
)
,
∃
(
z
=
c
)
\forall\ \textrm{valid assignments } (x=a, y=b), \exists\ (z=c)
∀
valid assignments
(
x
=
a
,
y
=
b
)
,
∃
(
z
=
c
)
that satisfies constraints on
(
x
,
z
)
(x, z)
(
x
,
z
)
and
(
z
,
y
)
(z, y)
(
z
,
y
)
Constraint Propagation
Path Consistency
∀
valid assignments
(
x
=
a
,
y
=
b
)
,
∃
(
z
=
c
)
\forall\ \textrm{valid assignments } (x=a, y=b), \exists\ (z=c)
∀
valid assignments
(
x
=
a
,
y
=
b
)
,
∃
(
z
=
c
)
that satisfies constraints on
(
x
,
z
)
(x, z)
(
x
,
z
)
and
(
z
,
y
)
(z, y)
(
z
,
y
)
Constraint Propagation
k
k
k
-Consistency
For every valid assignment to a set of
k
−
1
k-1
k
−
1
variables,
there exists a valid assignment to the
k
t
h
k^{th}
k
t
h
variable
Does not imply
k
−
1
k-1
k
−
1
consistency
x
<
3
x < 3
x
<
3
x
<
y
x < y
x
<
y
x
+
y
=
z
x + y = z
x
+
y
=
z
D
(
x
)
=
{
2
,
4
}
D(x) = \{2, 4\}
D
(
x
)
=
{
2
,
4
}
D
(
y
)
=
{
1
,
3
}
D(y) = \{1, 3\}
D
(
y
)
=
{
1
,
3
}
D
(
z
)
=
{
3
,
4
,
5
}
D(z) = \{3, 4, 5\}
D
(
z
)
=
{
3
,
4
,
5
}
Resume presentation