Download presentation
Presentation is loading. Please wait.
Published byRiley Everard Modified over 10 years ago
1
Global Constraints Toby Walsh National ICT Australia and University of New South Wales www.cse.unsw.edu.au/~tw
2
Course outline ● Introduction ● All Different ● Lex ordering ● Value precedence ● Complexity ● GAC-Schema ● Soft Global Constraints ● Global Grammar Constraints ● Roots Constraint ● Range Constraint ● Slide Constraint ● Global Constraints on Sets
3
Value precedence ● Global constraint proposed to deal with value symmetry – Hot off the press! – Propagator first described here [ECAI 06] ● Good example of “global” constraint where we can use an efficient encoding – Encoding gives us GAC – Asymptotically optimal, achieve GAC in O(nd) time
4
Value symmetry ● 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] …
5
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
6
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 …
7
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
8
Value precedence ● Suppose all values from 1 to m are interchangeable – Might as well let X1=1
9
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
10
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
11
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
12
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
13
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
14
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
15
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])
16
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
17
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
18
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
19
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}
20
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
21
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
22
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
23
Propagating Precedence ● Simple ternary encoding ● Introduce sequence of variables, Yi – Record largest value used so far – Y1=0
24
Propagating Precedence ● Simple ternary encoding ● Post sequence of constraints C(Xi,Yi,Yi+1) for each 1<=i<=n These hold iff Xi<=1+Yi and Yi+1=max(Yi,Xi)
25
Propagating Precedence ● Simple ternary encoding ● Post sequence of constraints ● Easily implemented within most solvers ● Implication and other logical primitives ● GAC-Schema (alias “table” constraint) ● …
26
Propagating Precedence ● Simple ternary encoding ● Post sequence of constraints – C(Xi,Yi,Yi+1) for each 1<=i<=n – This decomposition is Berge-acyclic – Constraints overlap on one variable and form a tree
27
Propagating Precedence ● Simple ternary encoding ● Post sequence of constraints – C(Xi,Yi,Yi+1) for each 1<=i<=n – This decomposition is Berge-acyclic – Constraints overlap on one variable and form a tree – Hence enforcing GAC on the decomposition achieves GAC on Precedence([X1,..Xn]) – Takes O(n) time – Also gives excellent incremental behaviour
28
Propagating Precedence ● Simple ternary encoding ● Post sequence of constraints – C(Xi,Yi,Yi+1) for each 1<=i<=n – These hold iff Xi<=1+Yi and Yi+1=max(Yi,Xi) – Consider Y1=0, X1 in {1,2,3}, X2 in {1,2,3} and X3=3
29
Precedence and matrix symmetry ● Alternatively, could map into 2d matrix – Xij=1 iff Xi=j ● Value precedence now becomes column symmetry – Can lex order columns to break all such symmetry – Alternatively view value precedence as ordering the columns of a matrix model
30
Precedence and matrix symmetry ● Alternatively, could map into 2d matrix – Xij=1 iff Xi=j ● Value precedence now becomes column symmetry ● However, we get less pruning this way – Additional constraint that rows have sum of 1 – Consider, X1=1, X2 in {1,2,3} and X3=1
31
Precedence for set variables ● Social golfers problem – Each foursome can be represented by a set of cardinality 4 – Values (golfers) within this set are interchangeable ● Value precedence can be applied to such set variables – But idea is now conceptually more complex!
32
Precedence for set variables ● We might as well start with X1={1,2,3}
33
Precedence for set variables ● We might as well start with X1={1,2,3,4} ● Now 1, 2, 3 and 4 are still symmetric
34
Precedence for set variables ● We might as well start with X1={1,2,3,4} ● Let’s try X2={2,5,6,7}
35
Precedence for set variables ● We might as well start with X1={1,2,3,4} ● Let’s try X2={2,5,6,7} ● But if we permute 1 with 2 we get – X1’={1,2,3,4} and X2’={1,5,6,7} – And X2’ is lower than X2 in the multiset ordering
36
Precedence for set variables ● We might as well start with X1={1,2,3,4} ● Let’s try X2={1,5,6,7}
37
Precedence for set variables ● We might as well start with X1={1,2,3,4} ● Let’s try X2={1,5,6,7} ● Let’s try X3={1,2,4,5}
38
Precedence for set variables ● We might as well start with X1={1,2,3,4} ● Let’s try X2={1,5,6,7} ● Let’s try X3={1,2,4,5} ● But if we permute 3 with 4 we get – X1’={1,2,3,4}, X2’={1,5,6,7} and X3’={1,2,3,5} – This is again lower in the multiset ordering
39
Precedence for set variables ● We might as well start with X1={1,2,3,4} ● Let’s try X2={1,5,6,7} ● Let’s try X3={1,2,3,5} ● …
40
Precedence for set variables ● Precedence([S1,..Sn]) iff min(i, {i | j in Si & not(k in Si) or i=n+1}) < min(i, {i | k in Si & not(j in Si) or i=n+2}) for all j<k ● In other words – The first time we distinguish apart j and k (by one appearing on its own), j appears and k does not
41
Precedence for set variables ● Precedence([S1,..Sn]) iff min(i, {i | j in Si & not(k in Si) or i=n+1}) < min(i, {i | k in Si & not(j in Si) or i=n+2}) for all j<k ● To enforce BC – Consider 2d matrix, Xij=1 iff j in Si – This has column symmetry – Apply lex to this! – No longer row sum=1 and no loss in pruning
42
Precedence for set variables ● Precedence([S1,..Sn]) iff min(i, {i | j in Si & not(k in Si) or i=n+1}) < min(i, {i | k in Si & not(j in Si) or i=n+2}) for all j<k ● To enforce BC – Consider 2d matrix, Xij=1 iff j in Si – This has column symmetry – Apply lex to this! – {1} subseteq S1 subseteq {1,2}, S2={2}, S3={1,2,3}
43
Precedence for set variables ● Set variables may have cardinality information – E.g. every set variable has 4 values – Solvers often include finite domain variable for the cardinality of a set variable ● If we add such cardinality information, enforcing BC on Precedence([S1,..Sn]) is NP-hard! – More about this in the Complexity lecture
44
Partial value precedence ● Values may partition into equivalence classes ● Values within each equivalence class are interchangeable ● E.g. Shift1=nursePaul, Shift2=nursePeter, Shift3=nurseJane, Shift4=nursePaul..
45
Partial value precedence ● Values may partition into equivalence classes ● Values within each equivalence class are interchangeable ● E.g. Shift1=nursePaul, Shift2=nursePeter, Shift3=nurseJane, Shift4=nursePaul.. If Paul and Jane have the same skills, we might be able to swap them (but not with Peter who is less qualified) Shift1=nurseJane, Shift2=nursePeter, Shift3=nursePaul, Shift4=nurseJane …
46
Partial value precedence ● Values may partition into equivalence classe ● Value precedence easily generalized to cover this case – Within each equivalence class, vi occurs before vj for all i<j (ignore values from other equivalence classes)
47
Partial value precedence ● Values may partition into equivalence classe ● Value precedence easily generalized to cover this case – Within each equivalence class, vi occurs before vj for all i<j (ignore values from other equivalence classes) – For example ● Suppose vi are one equivalence class, and ui another
48
Partial value precedence ● Values may partition into equivalence classe ● Value precedence easily generalized to cover this case – Within each equivalence class, vi occurs before vj for all i<j (ignore values from other equivalence classes) – For example ● Suppose vi are one equivalence class, and ui another ● X1=v1, X2=u1, X3=v2, X4=v1, X5=u2
49
Partial value precedence ● Values may partition into equivalence classe ● Value precedence easily generalized to cover this case – Within each equivalence class, vi occurs before vj for all i<j (ignore values from other equivalence classes) – For example ● Suppose vi are one equivalence class, and ui another ● X1=v1, X2=u1, X3=v2, X4=v1, X5=u2 ● Since v1, v2, v1 … and u1, u2, …
50
Wreath value precedence ● Variables are assigned pair of values in D1 x D2 ● Values in D1 are interchangeable ● Given a fixed value in D1, values in D2 are interchangeable
51
Wreath value precedence ● Variables are assigned pair of values in D1 x D2 – Values in D1 are interchangeable – Given a fixed value in D1, values in D2 are interchangeable ● For example, – Scheduling a conference – Days of week might be interchangeable – Given a day of week, rooms might then be interchangeable
52
Wreath value precedence ● Variables are assigned pair of values in D1 x D2 – Values in D1 are interchangeable – Given a fixed value in D1, values in D2 are interchangeable ● For example, – Scheduling a conference – Session1=, Session2=, Session3= …
53
Wreath value precedence ● Variables are assigned pair of values in D1 x D2 – Values in D1 are interchangeable – Given a fixed value in D1, values in D2 are interchangeable ● For example, – Scheduling a conference – Session1=, Session2=, Session3= …
54
Wreath value precedence ● Variables are assigned pair of values in D1 x D2 – Values in D1 are interchangeable – Given a fixed value in D1, values in D2 are interchangeable ● Value precedence again generalizes to this case min(i, {Xi[1]=uj or i=n+1}) < min(i, {Xi[1]=uj+1 or i=n+2}) and min(i, {Xi=(uj,vk) or i=n+1}) < min(i, {Xi=(uj,vk+1) or i=n+2})
55
Variable and value precedence ● Value precedence compatible with other symmetry breaking methods – Interchangeable values and lex ordering of rows and columns in a matrix model
56
Variable and value precedence ● Value precedence compatible with other symmetry breaking methods – Interchangeable values and lex ordering of rows and columns in a matrix model – Interchangeable values and variables ● But does not break all symmetry ● Consider [1.2,2] and [1,1,2] ● Use instead IncreasingSeq([X1,…Xn]) ● Values and number of occurrences increase
57
Variable and value precedence ● Value precedence compatible with other symmetry breaking methods – Interchangeable values and lex ordering of rows and columns in a matrix model – Interchangeable values and variables ● But does not break all symmetry ● Consider [1.2,2] and [1,1,2] ● Use instead IncreasingSeq([X1,…Xn]) ● Values and number of occurrences increase – Interchangeable values and rotation symmetry on variables ● But does not break all symmetry: [1,1,2,1,2] and [1,2,1,2,2]
58
Conclusions ● Symmetry of interchangeable values can be broken with value precedence constraints ● Value precedence can be decomposed into ternary constraints – Efficient and effective method to propagate ● Closely related to lex ordering columns – But combines row sum=1 ● Can be generalized in many directions – Partial interchangeability – Set variables – …
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.