Upload
malcolm-gaines
View
221
Download
0
Tags:
Embed Size (px)
Citation preview
Constraint Satisfaction Basics
strongly influenced by
Rina Dechter, “Constraint Processing” , 2003
complete search space of a problem
variables V = {v1, v2, …., vn}
domains D = {D1, D2, …., Dn}, vi Di
search space T = D1 X D2 X…. X Dn
size of search space |D1|.|D2|.…..|Dn|
if there are no constraints,
any solution in T is feasible
constraint satisfaction problems
variables V = {v1, v2, …., vn} domains D = {D1, D2, …., Dn}, vi Di constraints C = {C1, C2, …., Ck}
Ci is a relation on scope Si V Ci puts constraints on some variables in the problem
search space T = D1 X D2 X…. X Dn
a solution in the search space Twhose values violate a constraint is infeasible
a constraint satisfaction problem is often called a constraint network
example: Sudoku puzzle variables V = {v11, v12, v13, ..., v99} domains D1= D2= D3= ... = D99 = {1,2,3,4,5,6,7,8,9} constraints: “no repeated values in row, columns or
squares; pre-assigned values” C = {C1, C2, …., C810} Ci is a relation on scope Si = {vi1, vi2}
algebraic: { (vi1,vi2) | vi1 ≠ vi2} Cj on Sj = {vj1}: { vj1 | vj1 = k }
for particular puzzle:
example: Sudoku puzzle
4 8 2 5
5 3 4
7 ●● 8
5 9
2 7 1
2 6
8 9
9 7 6
8 1 7 4
81 variables Vi
Di = {1,2,3,4,5,6,7,8,9} i∀
each square is subject to 20 binary constraints of form Vi ≠ Vj
total = 81 * 20 / 2 = 810
a particular game also has ~ 25 constraints of form Vi = k
describing constraints
scope Si:the set of variables on which a constraint Ci is defined
scheme S = {S1, S2, …, Sk } set of all scopes on which constraints are defined
arity of a constraint Ci is size of its scope |Si| unary constraint on one variable binary constraint on two variables n-ary constraint on n variables*
*n-ary constraints can be rewritten as (many) binaries
simple scheduling problem
five tasks to schedule, T1, T2, T3, T4, T5 each lasts one hour each may start at 1PM, 2PM, 3PM tasks can be executed simultaneously except:
T1 starts after T3 T3 starts before T4 and after T5 T2 cannot be concurrent with T1 or T4 T4 cannot start at 2PM
simple scheduling problem
five tasks to schedule, T1, T2, T3, T4, T5 variables? domains? constraints? scopes? arity?
constraint graphs
vertices: variables edges: (binary) variable scopes
TSP scheduling problem
v1v1 v2v2
v4v4 v3v3
T1T1
T2T2
T3T3
T4T4
T5T5
crossword puzzle (after Dechter)
HOSES LASER SHEET SNAIL
STEER ALSO EARN HIKE
IRON SAME EAT LET
RUN SUN TEN YES
ME IT NO US
11 22 33 44 55
7766
88 99
1212
1010 1111
1313
crossword puzzleHOSES LASER SHEET SNAIL
STEER ALSO EARN HIKE
IRON SAME EAT LET
RUN SUN TEN YES
ME IT NO US
11 22 33 44 55
7766
88 99
1212
1010 1111
1313
variables: 13 (letters)
domains: alphabet
constraints:
S1 {1,2,3,4,5}
C1 {(H,O,S,E,S), (L,A,S,E,R), (S,H,E,E,T), (S,N,A,I,L), (S,T,E,E,R)}
crossword puzzleHOSES LASER SHEET SNAIL
STEER ALSO EARN HIKE
IRON SAME EAT LET
RUN SUN TEN YES
ME IT NO US
11 22 33 44 55
7766
88 99
1212
1010 1111
1313
S1 {1,2,3,4,5} arity 5
S2 {3,6,9,12}
S3 {5,7,11}
S4 {8,9,10,11}
S5 {10,13}
S6 {12,13}
crossword puzzleHOSES LASER SHEET SNAIL
STEER ALSO EARN HIKE
IRON SAME EAT LET
RUN SUN TEN YES
ME IT NO US
11 22 33 44 55
7766
88 99
1212
1010 1111
1313
partial solution
satisfying C4 and C5
over S4 S5 {8,9,10,11,13}
{(S,A,M,E,E)}
graphs for arity > 2
hypergraph multiple nodes per “hyperedge”
11 22 33 44 55
7766
88 99
1212
1010 1111
1313
graphs for arity > 2
hypergraph
11 22 33 44 55
7766
88 99
1212
1010 1111
1313
11 22 33 44 55
7766
88 99
1212
1010 1111
1313
graphs for arity > 2
dual of hypergraph nodes are constraints edges are common variables 11 22 33 44 55
7766
88 99
1212
1010 1111
1313
1,2,3,4,5
5,7,11
3,6,9,12
8,9,10,11
12,13
10,13
3
11
12
10
5 9 13
crossword puzzleanother formulation
HOSES LASER SHEET SNAIL
STEER ALSO EARN HIKE
IRON SAME EAT LET
RUN SUN TEN YES
ME IT NO US
11 22 33 44 55
7766
88 99
1212
1010 1111
1313
variables: 6: 1 3 5 8 10 12
domains: words by length
constraints: crossings
S1 {1,3} S2 {1,5} S3 {10,12}
S4 {3,8} S5 {3,12} S6 {5,8}
S7 {10,8}
all binary constraints
binary constraint networksonly unary and binary constraints
constraint deduction inferring new constraints from initial set
1. constraints between unconstrained variables
2. tightening of existing constraints
constraint deduction example:
V = { v1,v2,v3}
D1 = D2 = D3 = { red, green}
C1: {(v2,v1)|v2 ≠v1} = {(red, green),(green, red)}
C2: {(v1,v3)|v1 ≠v3} = {(red, green),(green, red)}solutions: {(red, green, green), (green, red, red)}
redgreen
redgreen
redgreen
v1
v2 v3
constraint deduction example:
new constraint network with same solutions--> better for partial solutions (more later)
redgreen
redgreen
redgreen
v1
v2 v3
redgreen
redgreen
redgreen
v1
v2 v3
inferred constraint: v2 = v3
constraint composition
given two binary* constraints C1, C2
on scopes S1 = {x,y} and S2 = {y,z} then
the composition C3 =C1.C2 is defined on S3 = {x,z}
C3 = {(a,b)| a Dx, b Dz, cDy such that (a,c) C1 and (c,b) C2}
e.g., C1 = {(red, green),(green, red)}
C2 = {(red, green),(green, red)}
C3 =C1.C2 = {(red, red), (green, green)}
*also works for a unary and a binary
inferring with constraints
Who owns the zebra? p.225
variables
domains
constraints
constraint graph
Who owns the zebra?
variables
Who owns the zebra?
variables and domains 25 variables
5 cars 5 pets 5 house colours 5 drinks 5 nationalities
the houses?? they are the elements of the domains
Who owns the zebra?
variables and domains 25 variables, D = {1, 2, 3, 4, 5} for each variable
5 cars 5 pets 5 house colours 5 drinks 5 nationalities
Who owns the zebra?
constraints explicit implicit assuming all binary, how many?
Who owns the zebra?
constraints explicit 14 implicit 50 assuming all unary or binary,
how many?64
Who owns the zebra?
binary constraint graph a 5-permutation as 10 binary constraints
milk
o.j.water
cocoaeggnog
Who owns the zebra? binary constraint graph
5 permutations
drinks
colours
cars
petsnationalities
Who owns the zebra? binary constraint graph
14 explicit constraints
drinks
colours
cars
petsnationalities
Who owns the zebra?
drinks
colours
cars
pets
nationalities
1 2 3 4 5
horse
snail
dog
fox
zebra