Download
sliding constraints n.
Skip this Video
Loading SlideShow in 5 Seconds..
Sliding Constraints PowerPoint Presentation
Download Presentation
Sliding Constraints

Sliding Constraints

103 Views Download Presentation
Download Presentation

Sliding Constraints

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Toby Walsh National ICT Australia and University of New South Wales www.cse.unsw.edu.au/~tw Joint work with Christian Bessiere, Emmanuel Hebrard, Brahim Hnich, Zeynep Kiziltan Sliding Constraints

  2. SLIDE meta-constraint • Hot off the press • Some of this is to appear at ECAI 06 • Some is even under review for IJCAI 07!

  3. SLIDE meta-constraint • A constructor for generating many sequencing and related global constraints • REGULAR [Pesant 04] • AMONG SEQ [Beldiceanu and Contegjean 94] • CARD PATH [Beldiceanu and Carlsson 01] • VALUE PRECEDENCE [Lee and Law 04] • … • Slides a constraint down one or more sequences of variables • Ensuring constraint holds at every point • Fixed parameter tractable

  4. Basic SLIDE • SLIDE(C,[X1,..Xn]) holds iff • C(Xi,..Xi+k) holds for every I • INCREASING([X1,..Xn]) • SLIDE(<=,[X1,..Xn]) • Unfolds into X1 <= X2, X2 <= X3, … Xn-1 <= Xn

  5. Basic SLIDE • SLIDE(C,[X1,..Xn]) holds iff • C(Xi,..Xi+k) holds for every I • ALWAYS_CHANGE([X1,..Xn]) • SLIDE(=/=,[X1,..Xn]) • Unfolds into X1 =/= X2, X2 =/= X3, … Xn-1 =/= Xn

  6. Basic SLIDE • AMONG SEQ constraint [Beldiceanu and Contegjean 94] • Car sequencing, staff rostering, … • E.g. at most 1 in 3 cars have a sun roof, at most 3 in 7 night shifts, … • SLIDE(C,[X1,..Xn]) where C(X1..,Xk) holds iff AMONG([X1,..,Xk],l,u,v)

  7. Basic SLIDE • AMONG SEQ constraint [Beldiceanu and Contegjean 94] • Car sequencing, staff rostering, … • E.g. at most 1 in 3 cars have a sun roof, at most 3 in 7 night shifts, … • SLIDE(C,[X1,..Xn]) where C(X1..,Xk) holds iff AMONG([X1,..,Xk],l,u,v) • E.g. l=u=2, k=3 and v={a} • SLIDE(C,[X1,..X5]) where X1=a, X2, .. X5 in {a,b}

  8. Basic SLIDE • AMONG SEQ constraint [Beldiceanu and Contegjean 94] • Car sequencing, staff rostering, … • E.g. at most 1 in 3 cars have a sun roof, at most 3 in 7 night shifts, … • SLIDE(C,[X1,..Xn]) where C(X1..,Xk) holds iff AMONG([X1,..,Xk],l,u,v) • E.g. l=u=2, k=3 and v={a} • SLIDE(C,[X1,..X5]) where X1=a, X2, .. X5 in {a,b} • Enforcing GAC sets X4=a since only satisfying tuples are a,a,b,a,a and a,b,a,a,b. Enforcing GAC on decomposition does nothing!

  9. GSC • Global sequence constraint in ILOG Solver • Combines AMONG SEQ with GCC • Regin and Puget have given partial propagator

  10. GSC • Global sequence constraint in ILOG Solver • Combines AMONG SEQ with GCC • Regin and Puget have given partial propagator • We can show why! • It is NP-hard to enforce GAC on GSC • Can actually prove this when GSC is AMONG SEQ plus an ALL DIFFERENT • ALL DIFFERENT is a special case of GCC

  11. GSC • Reduction from 1in3 SAT on positive clauses • The jth block of 2N clauses will ensure jth clause satisfied • Even numbered CSP vars represent truth assignment • Odd numbered CSP vars “junk” to ensure N odd values in each block • X_2jN+2i odd iff xi true • AMONG SEQ([X1,…],N,N,2N,{1,3,..}) • This ensures truth assignment repeated along variables!

  12. GSC • Reduction from 1in3 SAT on positive clauses • Suppose jth clause is (x or y or z) • X_2jN+2x, X_2jN+2y, X_2jN+2z in {4NM+4j, 4NM+4j+1, 4NM+4j+2} • As ALL DIFFERENT, only one of these odd • For i other than x, y or z, X_2jN+2i in {4jN+4i, 4jN+4i+1} and X_2jN+2i+1 in {4jN+4i+2, 4jn+4i+3}

  13. SLIDE down multiple sequences • Can SLIDE down more than one sequence at a time • LEX([X1,..Xn],[Y1,..Yn]) [Frisch et al CP 02] • Introduce sequence of Boolean vars [B1,..Bn+1] • Play role of alpha in LEX propagator

  14. SLIDE down multiple sequences • Can SLIDE down more than one sequence at a time • LEX([X1,..Xn],[Y1,..Yn]) • Set B1=0 • Bn+1=1 (strict lex), Bn+1 in {0,1} (lex) • SLIDE(C,[X1..Xn],[Y1,..Yn],[B1,..Bn+1]) holds iff C(Xi,Yi,Bi,Bi+1) holds for each i

  15. SLIDE down multiple sequences • Can SLIDE down more than one sequence at a time • LEX([X1,..Xn],[Y1,..Yn]) • Set B1=0 • Bn+1=1 (strict lex), Bn+1 in {0,1} (lex) • SLIDE(C,[X1..Xn],[Y1,..Yn],[B1,..Bn+1]) • C(Xi,Yi,Bi,Bi+1) holds iff Bi=Bi+1=1 or (Bi=Bi+1=0 and Xi=Yi) or (Bi=0, Bi+1=1 and Xi<Yi)

  16. SLIDE down multiple sequences • Can SLIDE down more than one sequence at a time • LEX([X1,..Xn],[Y1,..Yn]) • Set B1=0 • Bn+1=1 (strict lex), Bn+1 in {0,1} (lex) • SLIDE(C,[X1..Xn],[Y1,..Yn],[B1,..Bn+1]) • C(Xi,Yi,Bi,Bi+1) holds iff Bi=Bi+1=1 or (Bi=Bi+1=0 and Xi=Yi) or (Bi=0, Bi+1=1 and Xi<Yi) • {2} {1,3,4} {2,3,4} {1} {3,4,5} • {0,1,2} {1} {1,2,3} {0} {0,1,2}

  17. SLIDE down multiple sequences • Can SLIDE down more than one sequence at a time • LEX([X1,..Xn],[Y1,..Yn]) • Set B1=0 • Bn+1=1 (strict lex), Bn+1 in {0,1} (lex) • SLIDE(C,[X1..Xn],[Y1,..Yn],[B1,..Bn+1]) • C(Xi,Yi,Bi,Bi+1) holds iff Bi=Bi+1=1 or (Bi=Bi+1=0 and Xi=Yi) or (Bi=0, Bi+1=1 and Xi<Yi) • {2} {1,3,4}{2,3,4} {1} {3,4,5} • {2} {1} {1,2,3} {0} {0,1,2}

  18. SLIDE down multiple sequences • Can SLIDE down more than one sequence at a time • LEX([X1,..Xn],[Y1,..Yn]) • Set B1=0 • Bn+1=1 (strict lex), Bn+1 in {0,1} (lex) • SLIDE(C,[X1..Xn],[Y1,..Yn],[B1,..Bn+1]) • C(Xi,Yi,Bi,Bi+1) holds iff Bi=Bi+1=1 or (Bi=Bi+1=0 and Xi=Yi) or (Bi=0, Bi+1=1 and Xi<Yi) • {2} {1} {2,3,4} {1} {3,4,5} • {2} {1} {1,2,3} {0} {0,1,2}

  19. SLIDE down multiple sequences • Can SLIDE down more than one sequence at a time • LEX([X1,..Xn],[Y1,..Yn]) • Set B1=0 • Bn+1=1 (strict lex), Bn+1 in {0,1} (lex) • SLIDE(C,[X1..Xn],[Y1,..Yn],[B1,..Bn+1]) • C(Xi,Yi,Bi,Bi+1) holds iff Bi=Bi+1=1 or (Bi=Bi+1=0 and Xi=Yi) or (Bi=0, Bi+1=1 and Xi<Yi) • {2} {1} {2} {1} {3,4,5} • {2} {1} {3} {0} {0,1,2}

  20. SLIDE down multiple sequences • Can SLIDE down more than one sequence at a time • LEX([X1,..Xn],[Y1,..Yn]) • Set B1=0 • Bn+1=1 (strict lex), Bn+1 in {0,1} (lex) • SLIDE(C,[X1..Xn],[Y1,..Yn],[B1,..Bn+1]) • C(Xi,Yi,Bi,Bi+1) holds iff Bi=Bi+1=1 or (Bi=Bi+1=0 and Xi=Yi) or (Bi=0, Bi+1=1 and Xi<Yi) • Highly efficient, incremental, ..

  21. SLIDE down multiple sequences • CONTIGUITY([X1,..Xn]) [Maher 02] • 0…01…10…0 • Two simple SLIDEs

  22. SLIDE down multiple sequences • CONTIGUITY([X1,..Xn]) • 0…01…10…0 • Two simple SLIDEs • Introduce Yi in {0,1,2} • SLIDE(<=,[Y1,..Yn])

  23. SLIDE down multiple sequences • CONTIGUITY([X1,..Xn]) • 0…01…10…0 • Two simple SLIDEs • Introduce Yi in {0,1,2} • SLIDE(<=,[Y1,..Yn]) • SLIDE(C,[X1,..Xn],[Y1,..Yn]) where C(Xi,Yi) holds iff Xi=1 <-> Yi=1

  24. SLIDE down multiple sequences • REGULAR(A,[X1,..Xn]) [Pesant 04] • X1 .. Xn is a string accepted by FDA A • Can encode many useful constraints including LEX, AMONG, STRETCH, CONTIGUITY …

  25. SLIDE down multiple sequences • REGULAR(A,[X1,..Xn]) [Pesant 04] • X1 .. Xn is a string accepted by FDA A • Encodes into simple SLIDE • Introduce Qi to represent state of the automaton after i symbols

  26. SLIDE down multiple sequences • REGULAR(A,[X1,..Xn]) • X1 .. Xn is a string accepted by FDA A • Introduce Qi to represent state of the automaton after i symbols • SLIDE(C,[X1,..Xn],[Q1,..Qn+1]) where • Q1 is starting state of A • Qn+1 is limited to accepting states of A • C(Xi,Qi,Qi+1) holds iff A moves from state Qi to state Qi+1 on seeing Xi

  27. SLIDE down multiple sequences • REGULAR(A,[X1,..Xn]) • X1 .. Xn is a string accepted by FDA A • Introduce Qi to represent state of the automaton after i symbols • SLIDE(C,[X1,..Xn],[Q1,..Qn+1]) where • Q1 is starting state of A • Qn+1 is limited to accepting states of A • C(Xi,Qi,Qi+1) holds iff A moves from state Qi to state Qi+1 on seeing Xi • Gives highly efficient and effective propagator! • Introducing Qi also gives modelling access to state variables

  28. SLIDE with counters • AMONG([X1,..Xn],v,N) • Introduce sequence of counts, Yi • SLIDE(C,[X1,..Xn],[Y1,..Yn+1]) where • Y1=0, Yn+1=N • C(Xi,Yi,Yi+1) holds iff (Xi in v and Yi+1=1+Yi) or (Xi not in v and Yi+1=Yi)

  29. SLIDE with counters • CARD PATH [Beldiceanu and Carlsson 01] • SLIDE is a special case of CARD PATH • SLIDE(C,[X1,..Xn]) iff CARD PATH(C,[X1,..Xn],n-k+1)

  30. SLIDE with counters • CARD PATH • SLIDE is a special case of CARD PATH • SLIDE(C,[X1,..Xn]) iff CARD PATH(C,[X1,..Xn],n-k+1) • CARD PATH is a special case of SLIDE • SLIDE(D,[X1,..Xn],[Y1,..Yn+1]) where Y1=0, Yn+1=N, and D(Xi,..Xi+k,Yi,Yi+1) holds iff (Yi+1=1+Yi and C(Xi,..Xi+k)) or (Yi+1=Yi and not C(Xi,..Xi+k))

  31. Global constraints for symmetry breaking • Decision variables: • Col[Italy], Col[France], Col[Austria] ... • Domain of values: • red, yellow, green, ... • Constraints • binary relations like Col[Italy]=/=Col[France] Col[Italy]=/=Col[Austria] …

  32. Value symmetry • Solution: • Col[Italy]=green Col[France]=red Col[Spain]=green … • Values (colours) are interchangeable: • Swap red with green everywhere will still give us a solution

  33. Value symmetry • Solution: • Col[Italy]=green Col[France]=red Col[Spain]=green … • Values (colours) are interchangeable: • Col[Italy]=red Col[France]=green Col[Spain]=red …

  34. Value precedence • Old idea • Used in bin-packing and graph colouring algorithms • Only open the next new bin • Only use one new colour • Applied now to constraint satisfaction [Law and Lee 04]

  35. Value precedence • Suppose all values from 1 to m are interchangeable • Might as well let X1=1

  36. Value precedence • Suppose all values from 1 to m are interchangeable • Might as well let X1=1 • For X2, we need only consider two choices • X2=1 or X2=2

  37. Value precedence • Suppose all values from 1 to m are interchangeable • Might as well let X1=1 • For X2, we need only consider two choices • Suppose we try X2=2

  38. Value precedence • Suppose all values from 1 to m are interchangeable • Might as well let X1=1 • For X2, we need only consider two choices • Suppose we try X2=2 • For X3, we need only consider three choices • X3=1, X3=2, X3=3

  39. Value precedence • Suppose all values from 1 to m are interchangeable • Might as well let X1=1 • For X2, we need only consider two choices • Suppose we try X2=2 • For X3, we need only consider three choices • Suppose we try X3=2

  40. Value precedence • Suppose all values from 1 to m are interchangeable • Might as well let X1=1 • For X2, we need only consider two choices • Suppose we try X2=2 • For X3, we need only consider three choices • Suppose we try X3=2 • For X4, we need only consider three choices • X4=1, X4=2, X4=3

  41. Value precedence • Global constraint • Precedence([X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) for all j<k • In other words • The first time we use j is before the first time we use k

  42. Value precedence • Global constraint • Precedence([X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) for all j<k • In other words • The first time we use j is before the first time we use k • E.g • Precedence([1,1,2,1,3,2,4,2,3]) • But not Precedence([1,1,2,1,4])

  43. Value precedence • Global constraint • Precedence([X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) for all j<k • In other words • The first time we use j is before the first time we use k • E.g • Precedence([1,1,2,1,3,2,4,2,3]) • But not Precedence([1,1,2,1,4]) • Proposed by [Law and Lee 2004] • Pointer based propagator (alpha, beta, gamma) but only for two interchangeable values at a time

  44. Value precedence • Precedence([i,j],[X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) • Of course • Precedence([X1,..Xn]) iff Precedence([i,j],[X1,..Xn]) for all i<j

  45. Value precedence • Precedence([i,j],[X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) • Of course • Precedence([X1,..Xn]) iff Precedence([i,j],[X1,..Xn]) for all i<j • Precedence([X1,..Xn]) iff Precedence([i,i+1],[X1,..Xn]) for all i

  46. Value precedence • Precedence([i,j],[X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) • Of course • Precedence([X1,..Xn]) iff Precedence([i,j],[X1,..Xn]) for all i<j • But this hinders propagation • GAC(Precedence([X1,..Xn])) does strictly more pruning than GAC(Precedence([i,j],[X1,..Xn])) for all i<j • Consider X1=1, X2 in {1,2}, X3 in {1,3} and X4 in {3,4}

  47. Puget’s method • Introduce Zj to record first time we use j • Add constraints • Xi=j implies Zj <= i • Zj=i implies Xi=j • Zi < Zi+1

  48. Puget’s method • Introduce Zj to record first time we use j • Add constraints • Xi=j implies Zj < I • Zj=i implies Xi=j • Zi < Zi+1 • Binary constraints • easy to implement

  49. Puget’s method • Introduce Zj to record first time we use j • Add constraints • Xi=j implies Zj < I • Zj=i implies Xi=j • Zi < Zi+1 • Unfortunately hinders propagation • AC on encoding may not give GAC on Precedence([X1,..Xn]) • Consider X1=1, X2 in {1,2}, X3 in {1,3}, X4 in {3,4}, X5=2, X6=3, X7=4

  50. Propagating Precedence • Simple SLIDE encoding • Introduce sequence of variables, Yi • Record largest value used so far • Y1=0