1 / 107

Reasoning with global constraints

Reasoning with global constraints. Christian Bessiere LIRMM (CNRS/U. Montpellier) France. Background. Constraint networks. A set X={X1,…,Xn} of variables A set D={D(X1),…D(Xn)} of domains, where D(Xi) is the finite set of values for Xi A set C={C1,…Ce} of constraints.

diem
Download Presentation

Reasoning with global constraints

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Reasoning with global constraints Christian Bessiere LIRMM (CNRS/U. Montpellier) France

  2. Background

  3. Constraint networks • A set X={X1,…,Xn} of variables • A set D={D(X1),…D(Xn)} of domains, where D(Xi) is the finite set of values for Xi • A set C={C1,…Ce} of constraints

  4. Agreements on domains • Domains are given in extension to allow any type of reasoning  If ||D(Xi)|| denotes the size of the encoding, ||D(Xi)|| = |D(Xi)| • Example: • D(X)={1,..,100} • ||D(X)|| = 100 (not log2(100))

  5. Agreements on domains • Domains are subsets of the set Z of integers  We inherit the total ordering on integers • Example: • D(X)={1,..,100} • Special values: min(X)=1, max(X)=100

  6. ub(S) S1:{1} S2:{1} S3:{0,1} S4:{0,1} S5:{0} lb(S) 1 2 3 4 1 2 Set variables • It is sometimes convenient to consider a Boolean vector <S1,…,Sn> as a set variable S with domain 2{1..n} • In this case, D(S) is represented by its required values lb(S) and possible values ub(S) S can take values: {1,2}, {1,2,3}, {1,2,4}, {1,2,3,4} [Gervet94]

  7. Y X 1 2 4 7 9 3 7 8 10 Constraints • A constraint c specifies the allowed combinations of values on a sequence X(c)=(Xi1,…,Xiq) of variables • Classical definition in CSPs: • c  D(Xi1) x ... X D(Xiq) • Example: • c  X < Y D(X)={3, 7, 8, 10} D(Y)={1, 2, 4, 7, 9} c={(3,4), (3,7), (3,9), (7,9), (8,9)}

  8. 1 2 4 7 9 3 7 8 10 …Not satisfactory • because it does not fit what is done in practice: X < Y is not encoded as a set of pairs! • And even if it was, we do not want to remove all pairs (v,w) from c each time a value v is removed from D(X) because it does not permit to express all types of local consistencies (see bound consistency in [Dechter03])

  9. Constraints • A constraint c specifies the allowed combinations of values on a sequence X(c)=(Xi1,…,Xiq) of variables c  Z|X(c)| c = {allowed tuples on X(c)} c is independent of the effective domains of its variables So, a constraint c is defined by any Boolean function fc with domain Z|X(c)| c X < Y is the set {…(-11,-7),…, (0,4), (0,5), (0,6),…, (7,9), (7,10)…} of all tuples (v,w) where v<w.

  10. Non-binary versus global constraints • Non-binary: c with scope X(c), |X(c)|>2 • Global constraint: class G of constraints defined by a Boolean function fG with domain Z* • alldiff : fG(t)=1 iff v,w  t, v  w • A constraint c on X(c) belongs to a class G iff c = {t  Z|X(c)| | fG(t)=1} • Alldiff(X1,X2,X3)= {t  Z3 | t[1]  t[2], t[1]  t[2], t[2]  t[3]} Restriction: checking if fG(t)=1 is polynomial

  11. Some global constraints • Nvalue(X1..Xn,N)  number of values taken by Xi’s is equal to N • (2,1,3,3, 3) is allowed • Alldiff(X1..Xn) Nvalue(X1..Xn,n) • Atmost[k,v](X1..Xn)  at most k variables take value v • (2,5,1,4) is allowed if k=2, v=2 • See Beldiceanu’s catalog (>200 global constraints) [Bel&al05]

  12. Do we need global constraints? • …or at least: ‘do we need all of them when specifying a CP toolkit?’ • Why global constraints? • Expressiveness (semantic globality)  expressing new things • Effectiveness of propagation (operational globality) producing powerful effects • Efficiency of propagation (algorithmic globality) producing the result with little wasted effort [BesVanH03]

  13. Part 1: Semantic Globality

  14. Expressiveness • Global constraints permit a high-level programming approach: a whole pattern in a single constraint • Allowed shifts in a nurse rostering •  Strech constraint: at most 5 working days and not morning after night • N N R R M M A A A A R N M M R R • But are they all necessary? • does each permit to express what others can’t? [Pesant04]

  15. Early work • Encode non-binary constraints as binary ones • Primal representation • Hidden representation • Dual representation [Montanari74, DecPea89, Jan&al89, Dechter90, Ros&al90]

  16. X1 X2       X3 X4 Early work: Primal graph • Keep the same variables/domains • Replace non-binary constraints by their binary projections (inside DX(c)) • Alldiff(X1,..X4): • sol(N)=alldiff(X1..X4)

  17. sol(N)= 13 15 17 35 37 X X Y Z 1 2 3 1 2 5 1 4 5 1 4 7 1 6 7 3 2 5 3 4 7 12 14 16 32 34 X+Y=Z 1 2 3 1 4 5 1 6 7 3 2 5 3 4 7 Z 23 25 45 47 67 Y Early work: Primal graph • But, it does not always work • X + Y = Z with D(X)={1, 2, 3} D(Y)={2, 4, 6} D(Z)={1, 3, 5, 7}

  18. Hc Z • 3 • 145 5 • 167 7 • 325 5 • 347 7 Hc2 W Early work: Hidden repr. • Keep the original variables • Add a new variable Hc for each original constraint c • D(Hc)={t | t  c  DX(c)} • Binary constraints between Hc and Xi  X(c) that accept (t,v) iff t[Xi]=v Hc X Y Z

  19. Early work: Hidden repr. • D(Hc)={t | t  c  DX(c)}  |D(Hc)|O(dk) • Exponential size of the representation

  20. Vc1 123 145 167 325 347 Vc2 475 655 675 676 Vc1 Vc2 c1 W c2 X Y Z Early work: Dual repr. • Forget original variables • Add a new variable Vc for each original constraint c • D(Vc)={t | t  c  DX(c)} • X(c1)  X(c2)  c(Vc1,Vc2) • (t1,t2)  c(Vc1,Vc2) iff t1[X(c1)X(c2)] = t2[X(c1)X(c2)] Y+Z>2W, D(W)={5,6}

  21. Early work: Dual repr. • D(Vc)={t | t  c  DX(c)}  |D(Vc)|O(dk) • Exponential size of the representation

  22. Semantic globality (relative to L) • When does a global constraint help expressing something new in a language L?  If it cannot be polynomially decomposed with constraints in L

  23. A sample language • Range, Roots, and basic arithmetic primitives [Comics05]

  24. S T A sample language • Range(X1,...,Xn,S,T)  X(S)=T, where X({i})=Xi 1 v1 vj i n vm

  25. S S T T A sample language • Roots(X1,...,Xn,S,T)  S=X-1(T)

  26. Semantic globality (relative to L) • When does a global constraint help expressing something new in a language L? • If it cannot be polynomially decomposed with constraints in L • On the same variables • With extra variables

  27. Decomposition (relative to L) • alldiff(X1,..,Xn): • Atmost[1,1](X1,..,Xn) • Atmost[1,2](X1,..,Xn) • Atmost[1,3](X1,..,Xn) • … • Atmost[1,v](X1,..,Xn), vD(Xi), i

  28. X1 X2 X3 X4 1 1 2 2 2 2 3 3 3 3 4 4 5 5 S={2,3,4} S={} Decomposition with extra variables (relative to L) • atmost[k,v](X1,..Xn) ( k=2, v=2 ) X1…X4 1 1 2 2 1 1 2 3 … 1 2 2 2 … 2 2 2 2 … 4 4 5 5 |S|>k Roots(X1,..Xn,S,{v})  |S|k atmost is decomposable in L |S|≤k

  29. X1…X4 N 1 1 2 2 2 1 1 2 3 3 1 1 2 5 3 … 1 2 3 5 4 … 4 4 5 5 2 1 2 3 4 5 T X1 X2 X3 X4 X1 X2 X3 X4 1 1 2 2 2 2 3 3 3 3 4 4 5 5 Decomposition with extra variables (relative to L) • Nvalue(X1,..Xn,N) N 1 2 3 4 Range(X1,..Xn,{1..n},T)  |T|=N Nvalue is decomposable in L

  30. Decomposition relative to L • G decomposable relative to L if: • c  G, D on X(c), N=(X(c)Y,D’,C) such that • XiX(c), D’(Xi)=D(Xi) • c’  C, c’  L • sol(N)[X(c)] = sol(X(c),D,{c}) • ||N|| is poly in ||c||+||D||

  31. Absolute semantic globality • When does a global constraint help expressing something new? (independently of any language)  If it cannot be polynomially decomposed with constraints of bounded arity • On the same variables • With extra variables

  32. Absolute decomposition • G k-decomposable if • c  G, D on X(c), N=(X(c)Y,D’,C) such that • XiX(c), D’(Xi)=D(Xi) • c’  C, |X(c’)|  k • sol(N)[X(c)] = sol(X(c),D,{c}) • ||N|| is poly in ||c||+||D|| • G is decomposable if k s.t. G is k-decomposable

  33. X1 X2       X3 X4 Absolute decomposition • Alldiff  clique of binary inequalities • Alldiff(X1..X4) Alldiff is decomposable

  34. 1 1 2 2 1 1 2 3 … 4 4 5 5 X1 X2 U U U U U U X3 X4 Absolute decomposition • Atmost[k,v](X1..Xn)? Atmost[3,2]: Atmost 3 among 4  atmost 3 among 3  universal constraint Atmost is not decomposable on the same variables

  35. Absolute decomposition with extra variables • Atmost[k,v](X1..Xn): • B0…Bn, D(Bi)={0,…,n} • (Xi=v & Bi=Bi-1+1)(Xiv & Bi = Bi-1), i • B0=0, Bn  k X1 X2 Xi …… Xn-1 Xn B0 B1 Bi-1 Bi …… Bn-1 Bn atmost is 3-decomposable

  36. X1 X2 Xi …… Xn-1 Xn Y0 Y1 Yi-1 Yi …… Yn-1 Yn Absolute decomposition with extra variables • c  (Xi = k): • Y0…Yn, D(Yi)={0,…,k} • Yi = Yi-1+Xi, i • Y0=0, Yn = k ||D(Yi)|| exponential in ||(X,D,{c}) || Xi = k is not decomposable

  37. Part 2: Complexity of Reasoning

  38. X Y Z 1 2 1 2 4 3 3 6 5 7 Reasoning with global constraints c is X+Y=Z • All CP solvers propagate constraints • ‘propagate’ usually means: remove value v in D(Xi), XiX(c) if not tc, t[Xi]=v and t[Xj]D(Xj) j • This is the maximum amount of inconsistency information a constraint taken alone can project on a variable, aka: Generalized Arc Consistency (GAC )

  39. X + Y = Z 1 2 1 2 4 3 3 6 5 7 Questions related to GAC • GACSupport[c,D,X,v]: • Does value v for X have a support on c in D? • GACSupport[X,1]?  yes • GACSupport[X,2]?  no

  40. X + Y = Z 1 2 1 2 4 3 3 6 5 7 Questions related to GAC • IsItGAC[c,D]: • Does GACSupport[c, D, X, v] answer ‘yes’ for each X  X(c) and each value v  D(X)? • IsItGAC[D]?  no • IsItGAC[D1]?  yes

  41. X + Y = Z 1 2 1 2 4 3 3 6 5 7 Questions related to GAC • NoGACWipeOut[c,D]: • Is there any non empty D’  D on which IsItGAC[D’] answers yes? • NoGACWipeOut[D]?  yes • NoGACWipeOut[D2]?  no

  42. X + Y = Z 1 2 1 2 4 3 3 6 5 7 Questions related to GAC • maxGAC[c,D’,D]: • Is it the case that IsItGAC[c, D’] answers ‘yes’ and not  D’’, D’  D’’  D such that IsItGAC[D’’]? • maxGAC[D,D]?  no • maxGAC[D1,D]?  no

  43. X + Y = Z 1 2 1 2 4 3 3 6 5 7 Questions related to GAC • maxGAC[c,D’,D]: • Is it the case that IsItGAC[c, D’] answers ‘yes’ and not  D’’, D’  D’’  D such that IsItGAC[D’’]? • maxGAC[D,D]?  no • maxGAC[D1,D]?  no • maxGAC[D3,D]?  yes

  44. X + Y = Z 1 2 1 2 4 3 3 6 5 7 Questions related to GAC • GACDomain[c,D]: • The domain D’ such that maxGAC[D’,D] answers yes • GACDomain[D]?  D3

  45. GAC reasoning is intractable • GACSupport is in NP (poly certificate) • Let G be the class of constraints defined by X1 , where  is a 3Sat formula • GACSupport(c,{0,1}n,X,1) solves the SAT problem  GACSupport is NP-complete

  46. GAC reasoning is intractable • GACSupportis NP-complete • IsItGACis NP-complete • NoGACWipeOutis NP-complete • GACDomainis NP-hard • maxGAC?

  47. maxGAC is DP-complete • A decision problem P is DP-complete iff there exists two problems Q1 (NP-c) and Q2 (coNP-c) such that P answers ‘yes’ when Q1 answers ‘yes’ and Q2 answers ‘no’ • Let G1 and G2 be two 3Col problems (on the nodes s1..sn): X1 X2 …… Xn 1,2,3 1,2,3 1,2,3 4,5,6 4,5,6 4,5,6 c(Xi,Xj) forbids (v,w) if v(1,2,3) and w(4,5,6) or vice versa (si,sj) G1  c(Xi,Xj) forbids (11), (22), (33) on Xi,Xj (si,sj) G2  c(Xi,Xj) forbids (44), (55), (66) on Xi,Xj • maxGAC(c,{1..3}n,{1..6}n) answers yes iff G1 is 3colorable and G2 is not

  48. Complexity summary

  49. Questions related to GAC • Let G be a class of constraints • GACSupport(G) • IsItGAC(G) • NoGACWipeOut(G) • maxGAC(G) • GACDomain(G) …are the same as before but constraints must belong to G

  50. Dependencies between GAC questions • Suppose GACSupport(G) is NP-complete • NoGACWipeOut is in NP • GACSupport(G)[c,D,X,v] can be solved by a call to NoGACWipeOut(G)[c,DX=v]  NoGACWipeOut(G) is NP-complete

More Related