Download presentation
Presentation is loading. Please wait.
1
Two Set-Constraints For Modeling and Efficiency Willem-Jan van HoeveAshish Sabharwal Carnegie Mellon Univ.Cornell Univ. ModRef workshop at CP-07 Sept 23, 2007
2
ModRef Workshop at CP-072 CSPs, Global Constraints CSP: Given variables x, y, z, … with domains D(x), D(y), D(z), … and constraints over variables, find variable values such that all constraints are satisfied. Typical single-valued variable domains: discrete or continuous sets, e.g. {1,2,3,4,5}, {Su,Mo,Tu,…,Sa}, [0,1] Key to the success of CP: many useful global constraints with efficient, non-trivial filtering/propagation Very different from, say, SAT or integer programming
3
Sept 23, 2007ModRef Workshop at CP-073 Constraints on Set Variables Set variable: domain values are sets E.g. domain(S) = {{1,2}, {1,3},{2,3},{1,2,3}} Arise naturally in many settings, e.g. A graph (V,E) is a set of vertices and a set of edges (representation of Dooms-Katriel ’06 for MST) A set of jobs to be scheduled on a set of machines A set of packages to be moved using a set of trucks Often “grounded-down” to single-valued variables, especially in SAT and integer programming
4
Sept 23, 2007ModRef Workshop at CP-074 Set Variables: The Challenge A constraint on a single set variable may capture a structure that must otherwise be represented by a global constraint on multiple single-valued variables Filtering constraints on a single set may be as complex as global filtering on multiple single-valued variables Known that combining two overlapping global constraints can easily make them NP-complete Implication: constraints on multiple set variables can be significantly harder to filter
5
Sept 23, 2007ModRef Workshop at CP-075 Our Contribution Efficient filtering algorithms establishing bounds consistency for set-constraints sum-free, pair-atmost1 Experiments with the Schur Number problem and the Social Golfer problem Message: in addition to providing modeling convenience, set constraints can help Significantly reduce memory requirements Increase efficiency through better filtering
6
Background
7
Sept 23, 2007ModRef Workshop at CP-077 Constraints, Filtering, Propagation Variables x, y, z, … with domains D(x), D(y), D(z), … E.g. D(x) = {1,2,3,4,5} Constraints: e.g. x < max(y,z), y z, alldiff(x,y,z), … Key step in constraint programming: Filtering Given current variable domains and constraint C, remove domain values that do not belong to any solution to C Note: considers C in isolation, thus not too difficult Domain-delta (x) : change in D(x) between two successive filtering events
8
Sept 23, 2007ModRef Workshop at CP-078 Good Filtering Algorithm 1.Is efficient: usually called at every node of the search tree where relevant domains changed 2.Makes C domain consistent: provably removes all variable values that do not belong to a solution to C -- all remaining values can be extended to a solution 3.Is incremental: re-uses computation from parent nodes in the search tree, e.g., thru domain-deltas Goal: find efficient (near-linear time), incremental filtering algorithms that achieve domain consistency
9
Sept 23, 2007ModRef Workshop at CP-079 Set Variables: Representation If elements of S come, e.g., from {1, 2, …, k}, |D(S)| = 2 k Naïve domain representation too costly “Interval” representation: [L(S), U(S)] Semantics: D(S) = {s | L(S) s U(S)} E.g. L(S) = {2,3}, U(S) = {1,…,k} \ {5} all subsets containing 2 and 3 but not 5 All elements of L(S) must be in S --- lower bound No element not in U(S) may be in S --- upper bound Domain-delta: provides L (S) and U (S) (Alternative: length-lex representation)
10
Sept 23, 2007ModRef Workshop at CP-0710 Bounds Consistency Consistency notion for constraints on set variables (using the interval representation) : C(S 1, S 2, …, S n ) is bounds consistent if A.x L(S i ) iff x S i for all solutions to C B.x U(S i ) iff x S i for some solution to C Note: L(S i ) and U(S i ) themselves may not satisfy C Partial filtering: no bounds consistency Goal: establish bounds consistency efficiently “roughly speaking”
11
Part 1: The sum-free constraint Application: The Schur Number problem Filtering algorithm: fairly straightforward Advantage: natural model enormous space savings! can solve problems couldn’t be modeled in 2GB
12
Sept 23, 2007ModRef Workshop at CP-0712 sum-free (S) Variable : set S with positive integer elements Constraint: i, j S i+j S Note: j may equal i, so that i S 2i S Filtering algorithm, establishing bounds consistency: for i L (S), for j L(S) remove i+j and |i j| from U(S) Amortized complexity: O(n 2 ) for any path from root to leaf (assuming linear-time element listing for L (S) and L(S), and constant-time deletion for U(S) )
13
Sept 23, 2007ModRef Workshop at CP-0713 Experiments: Schur Number Given k 0, Schur number of k is the largest integer n s.t. {1, 2, …, n} can be partitioned into k sum-free subsets. Decision problem: given k, n, is such a partition possible? Model #1: integer vars x 1, …, x n with domain [k] O(kn 2 ) constraints: (x i = s) and (x j = s) (x i+j s) Model #2: set vars S 1, …, S k with domain [ , [n]] k+1 constraints: i sum-free (S i ), partition (S 1,…,S k, [n]) Also added shadow integer vars of Model #1 to better control the search heuristic {1, …, k}
14
Sept 23, 2007ModRef Workshop at CP-0714 Experiments: Schur Number Significantly reduced memory requirement (esp. n > 500) Often 4x speed-up schur-k-n Using ILOG Solver 6.3
15
Part 2: The atmost1 constraint Application: The Social Golfer problem Filtering algorithm: in general: complete filtering NP-hard (known) for pair-atmost1: constant time algorithm (after preprocessing) Advantage: efficiency thru better filtering
16
Sept 23, 2007ModRef Workshop at CP-0716 atmost1 (S 1, …, S n, c 1, …, c n ) Variables: Sets S 1, S 2, …, S n sets of integers Integers c 1, c 2, …, c n cardinalities Constraints: |S i | = c i 1 ≤ i ≤ n |S i S j | ≤ 11 ≤ i < j ≤ n Example: D(S 1 ) = [{1,2}, {1,2,3,5,6}], D(S 2 ) = [{3}, {1,2,3,4}], |S 1 | = |S 2 | = c 1 = c 2 = 3 Solutions: S 1 = {1,2,5} or {1,2,6} S 2 = {1,3,4} or {2,3,4} [Sadler-Gervet ’01] (“softer alldifferent ”)
17
Sept 23, 2007ModRef Workshop at CP-0717 Filtering atmost1 NP-complete in general [Bessiere-Hebrard-Hnich-Walsh ’04] Poly-time partial filtering algorithm known [Sadler-Gervet ’01] Achieves partial filtering even for atmost1 (S 1,S 2,c 1,c 2 ) How hard is the problem for two sets, i.e. pair-atmost1 ? We propose BC-FilterPairAtmost1 for bounds consistency Uses somewhat complex data structures and reasoning But eventual filtering steps very simple!
18
Sept 23, 2007ModRef Workshop at CP-0718 pair-atmost1 : Standard Decomposition Implement as three separate standard set constraints: |S 1 | = c 1, |S 2 | = c 2, |S 1 S 2 | ≤ 1 Disadvantage: Treats cardinality and intersection constraints separately Does not achieve bounds consistency (e.g. no element ever added to L(S i ) ) Example: D(S 1 ) = [{1,2}, {1,2,3,5,6}], D(S 2 ) = [{3}, {1,2,3,4}], c i = 3 Standard decomposition does not filter anything However, could have concluded 4 L(S 2 ) and 3 U(S 1 )
19
Sept 23, 2007ModRef Workshop at CP-0719 pair-atmost1 : Bounds Consistency L1 : elements already in S 1 U1 : elements available to be added to S 1 U1 = U(S 1 ) \ L(S 1 ) U2 = U(S 2 ) \ L(S 2 ) L1 = L(S 1 ) L2 = L(S 2 ) S 1 : S 2 :
20
Sept 23, 2007ModRef Workshop at CP-0720 Partitioning into Classes 9 classes of elements E.g. if x U1L2 must be removed from U(S 1 ) then all y U1L2 must be removed from U(S 1 ) Need to process only a constant number of classes! Options: add class to L(S i ) or remove class from U(S i ) L1restU1L2U1U2 L2restU2L1U2U1U2only U1only L1L2 S 1 : S 2 : Key observation: all elements within a class are indistinguishable w.r.t. pair-atmost1 =
21
Sept 23, 2007ModRef Workshop at CP-0721 The Filtering Process Implicitly go thru every “kind” of solution, maintaining two flags for each class T: T.can-have : solution with some x T in S i T.not-necessary : solution without needing all of T in S i 1.Initialize flags to False 2.Implicitly process all solutions 3.If T.can-have is still False, remove T from U(S i ) 4.If T.not-necessary is still False, add T to L(S i ) (typo on page 7 of paper)
22
Sept 23, 2007ModRef Workshop at CP-0722 Updating Flags: “Case0” Case0: S 1 and S 2 do not share any element (other cases easily reduce to Case0 on a smaller problem) Note: cannot use elements from U1L2 and U2L1 Compute “slacks” slack1 = (|U1only| + |U1U2|) (c 1 |L1|) Similarly slack2 slack3 = (|U1only|+|U2only|+|U1U2|) (c 1 +c 2 |L1|+|L2|) elements available elements needed
23
Sept 23, 2007ModRef Workshop at CP-0723 Updating Flags: “Case0” If solution exists, it can always use U1only, U2only (never hurts) it cannot use U1L2, U2L1 at all (no shared elements) Therefore, set U1only.can-have = True U2only.can-have = True U1L2.not-necessary = True U2L1.not-necessary = True Further, e.g., if slack1 > 0, U2U1.can-have = True U1U2.not-necessary = True (A few other similar updates.) There exists a solution in Case0 iff slack1 0, slack2 0, and slack3 0
24
Sept 23, 2007ModRef Workshop at CP-0724 BC-FilterPairAtmost1 Processing 9 classes takes constant time Don’t need all elements of U1L2, etc. --- only their cardinalities and a representative element! Eventual filtering of elements, of course, takes time proportional to class size Filtering complexity: O(n + k log n) n : integer domain size of elements k : #elements added to L(S i ) or removed from U(S i ) Stronger amortized analysis using domain-deltas: O(n log n) combined for any path from root to leaf
25
Sept 23, 2007ModRef Workshop at CP-0725 Experiments: Social Golfer golf-g-s-w: for each of w weeks, partition n golfers into g groups of size s each (g s = n), such that no two golfers are in the same group more than once Example: 1 2 34 5 67 8 9week 1 1 4 72 5 83 6 9week 2 1 5 92 6 73 4 8week 3 Well-studied problem: surprisingly challenging! Techniques based on symmetry, local search Our work: orthogonal to these --- improve basic filtering [prob010 in CSPLib]
26
Sept 23, 2007ModRef Workshop at CP-0726 Set-Based Model One set variable for each group S ij (week i, group j) Constraints: partition (S i1, S i2, …, S ig, [n])week i atmost1 (S ij, S kl, s, s)weeks i k; groups j,l For efficiency, we also have shadow integer variables x ia with domain [g] for each week i and golfer a Use x ia ’s to control search strategy Add a redundant global cardinality constraint ( gcc ): each group in [g] must be assigned to exactly s x ia ’s
27
Sept 23, 2007ModRef Workshop at CP-0727 Results: Social Golfer Using ILOG Solver 6.3
28
Sept 23, 2007ModRef Workshop at CP-0728 Conclusion Discussed sum-free (S) and pair-atmost1 (S 1,S 2,c 1,c 2 ) Results generalize to atmost k and to k sets, for constant k Demonstrated that set constraints not only offer convenience in modeling, they can also Significantly reduce memory requirements Provide much faster solutions Observed that efficiently filtering set constraints to bounds consistency can be somewhat tricky, but does pay off
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.