210 likes | 363 Vues
Constraint Satisfaction Basics. strongly influenced by Dr. Rina Dechter: “Constraint Processing”. complete search space of a problem. variables V = {v 1 , v 2 , …., v n } domains D = {D 1 , D 2 , …., D n }, v i D i search space T = D 1 X D 2 X…. X D n
E N D
Constraint Satisfaction Basics strongly influenced by Dr. Rina Dechter: “Constraint Processing”
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 T whose values violate a constraint is infeasible a constraint satisfaction problem is often called a constraint network
v1 v2 v3 v4 1 2 3 4 example: 4 queens problemcolumn version • variables V = {v1, v2, v3, v4} • domains D1= D2= D3= D4 = {1,2,3,4} • constraints: “no two queens should attack one another” • C = {C1, C2, …., C6} • C1 is a relation on scope S1= {v1, v2} (constraint between first and second queens) enumerated: {(1,3),(1,4),(2,4),(3,1),(4,1),(4,2)} algebraic: { (v1,v2) | v1 ≠ v2, v1 ≠ v2 ± 1 } • others defined likewise
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 the size of its scope |Si| • unary constraint on one variable • binary constraint on two variables (4 queens eg) • 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 4 queens scheduling problem v1 v2 T1 T3 T5 v4 v3 T2 T4
1 2 3 4 5 6 7 8 9 10 11 12 13 crossword puzzle (after Dechter) HOSES LASER SHEET SNAIL STEER ALSO EARN HIKE IRON SAME EAT LET RUN SUN TEN YES ME IT NO US
1 2 3 4 5 6 7 8 9 10 11 12 13 crossword puzzle HOSES LASER SHEET SNAIL STEER ALSO EARN HIKE IRON SAME EAT LET RUN SUN TEN YES ME IT NO US 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)}
1 2 3 4 5 6 7 8 9 10 11 12 13 crossword puzzle HOSES LASER SHEET SNAIL STEERALSO EARN HIKE IRON SAME EAT LET RUN SUN TEN YES ME IT NO US 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}
1 2 3 4 5 6 7 8 9 10 11 12 13 crossword puzzle HOSES LASER SHEET SNAIL STEERALSO EARN HIKE IRON SAME EAT LET RUN SUN TEN YES ME IT NO US 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” 1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13 graphs for arity > 2 • dual of hypergraph • nodes are constraints • edges are common variables 3 12 1,2,3,4,5 3,6,9,12 12,13 13 5 9 11 10 5,7,11 8,9,10,11 10,13
1 2 3 4 5 6 7 8 9 10 11 12 13 crossword puzzleanother formulation HOSES LASER SHEET SNAIL STEER ALSO EARN HIKE IRON SAME EAT LET RUN SUN TEN YES ME IT NO US variables: 6 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 • constraints between unconstrained variables • 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)} v1 red green v2 v3 red green red green
constraint deduction example: v1 v1 new constraint network with same solutions --> better for partial solutions (more later) red green red green v2 v3 v2 v3 red green red green red green red green inferred constraint: v2 = v3
constraint composition given two binary* constraints C1, C2on 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? variables domains constraints constraint graph