3
Constraint Satisfaction Problem (CSP)
±
Set of
variables
{X
1
, X
2
, …, X
n
}
±
Each variable X
i
has a
domain
D
i
of
possible values. Usually, D
i
is finite
±
Set of
constraints
{C
1
C
2
C
p
}
,
, …,
±
Each constraint relates a subset of
variables by specifying the valid
combinations of their values
±
Goal:
Assign a value to every variable such
that all constraints are satisfied
13
Map Coloring
WA
NT
SA
Q
NSW
V
±
7 variables {WA,NT,SA,Q,NSW,V,T}
±
Each variable has the same domain:
{red, green, blue}
±
No two adjacent variables have the same value:
WA
≠
NT, WA
≠
SA, NT
≠
SA, NT
≠
Q, SA
≠
Q,
SA
≠
NSW, SA
≠
V, Q
≠
NSW, NSW
≠
V
T
14
8-Queen Problem
±
8 variables X
i
, i = 1 to 8
±
The domain of each variable is: {1,2,…,8}
±
Constraints are of the forms:
•
X
i
= k
Î
X
j
≠
k
for all j = 1 to 8, j
≠
i
•
Similar constraints for diagonals
All constraints are binary
15
Street Puzzle
1
2
34
5
N
i
= {English, Spaniard, Japanese, Italian, Norwegian}
C
i
= {Red, Green, White, Yellow, Blue}
D
i
= {Tea, Coffee, Milk, Fruit-juice, Water}
J
i
= {Painter, Sculptor, Diplomat, Violinist, Doctor}
A
i
= {Dog, Snails, Fox, Horse, Zebra}
The Englishman lives in the Red house
Who owns the Zebra?
The Spaniard has a Dog
The Japanese is a Painter
The Italian drinks Tea
The Norwegian lives in the first house on the left
The owner of the Green house drinks Coffee
The Green house is on the right of the White house
The Sculptor breeds Snails
The Diplomat lives in the Yellow house
The owner of the middle house drinks Milk
The Norwegian lives next door to the Blue house
The Violinist drinks Fruit juice