Global Constraints for Lexicographic Orderings Alan Frisch Ian
Global Constraints for Lexicographic Orderings Alan Frisch, Ian Miguel (University of York) Brahim Hnich, Toby Walsh (4 C) Zeynep Kiziltan (Uppsala University)
GACLex • A new family of global constraints.
GACLex • A new family of global constraints. Non-binary constraint. Specialised propagator.
GACLex • A new family of global constraints. Non-binary constraint. Specialised propagator. GACLex maintains Generalised Arc Consistency: Given an assignment to any constrained variable, we can find consistent assignments for the remainder.
GACLex • A new family of global constraints. • Linear time complexity.
GACLex • A new family of global constraints. • Linear time complexity. • Ensures that a pair of vectors of variables are lexicographically ordered.
GACLex • A new family of global constraint. • Linear time complexity. • Ensures that a pair of vectors of variables are lexicographically ordered. 0 1 4 2 lex 2 9 8 7
Motivation • Many problems can be modelled by matrices of decision variables.
Motivation • Many problems can be modelled by matrices of decision variables. • E. g. Combinatorial Problems – Balanced Incomplete Block Design.
Motivation • Many problems can be modelled by matrices of decision variables. • E. g. Configuration Problems: – Rack Configuration.
Motivation • Many problems can be modelled by matrices of decision variables. • E. g. Scheduling Problems: – Social Golfers.
Motivation • Many problems can be modelled by matrices of decision variables. • E. g. Design Problems: – Steel Mill Slab Design.
Motivation • Many problems can be modelled by matrices of decision variables. • Frequently these matrices exhibit row and/or column symmetry.
Motivation • Many problems can be modelled by matrices of decision variables. • Frequently these matrices exhibit row and/or column symmetry. • We can permute the rows/columns in any (non)solution to obtain another (non)solution.
Motivation • Many problems can be modelled by matrices of decision variables. • Frequently these matrices exhibit row and/or column symmetry. • We can permute the rows/columns in any (non)solution to obtain another (non)solution. • It can be very expensive to search fruitless symmetric branches of the search tree.
Motivation • Many problems can be modelled by matrices of decision variables. • Frequently these matrices exhibit row and/or column symmetry. • Lexicographic ordering is an effective way to break a lot of this symmetry.
Example • Consider 2 identical bins: A B
Example • Consider 2 identical bins: A • We must pack 6 items: B 1 2 3 4 5 6
Example • Here is one solution: 5 6 3 4 1 2 A B
Example • Here is another: 6 5 4 3 2 1 A B
Example • Is there any fundamental difference? a) b) 5 3 1 A 6 4 2 B 6 4 2 A 5 3 1 B
Example • Consider a matrix model: a) b) 5 3 1 A 6 4 2 B 1 2 3 4 5 6 A 1 0 1 0 B 0 1 0 1 5 3 1 B 1 2 3 4 5 6 A 0 1 0 1 B 1 0 1 0
Example NB: ‘ 1’ means place this item in this bin: • Consider a matrix model: a) b) 5 3 1 A 6 4 2 B 1 2 3 4 5 6 A 1 0 1 0 B 0 1 0 1 5 3 1 B 1 2 3 4 5 6 A 0 1 0 1 B 1 0 1 0
Example • Consider a matrix model: If we insist that row A lex row B, we remove a) from the solution set. b) 6 4 2 A 5 3 1 B 1 2 3 4 5 6 A 1 0 1 0 B 0 1 0 1 1 2 3 4 5 6 A 0 1 0 1 B 1 0 1 0
Example • Notice that items 3 and 4 are identical. b) c) 6 4 2 A 6 3 2 A 5 3 1 B 1 2 3 4 5 6 A 0 1 0 1 B 1 0 1 0 5 4 1 B 1 2 3 4 5 6 A 0 1 1 0 0 1 B 1 0 0 1 1 0
Example • Notice that items 3 and 4 are identical. b) 6 4 2 A 5 3 1 B If we insist that col 3 lex col 4, we remove c) from the solution set. 1 2 3 4 5 6 A 0 1 0 1 B 1 0 1 0 1 2 3 4 5 6 A 0 1 1 0 0 1 B 1 0 0 1 1 0
How GACLex Works • Consider the following example. • We have two vectors of decision variables:
How GACLex Works • Consider the following example. • We have two vectors of decision variables: x {2} {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2}
How GACLex Works • Consider the following example. • We have two vectors of decision variables: x {2} {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2} • We want to enforce GAC on: x lex y.
A Tale of Two Pointers • We use two pointers, α and β, to avoid repeatedly traversing the vectors.
A Tale of Two Pointers • We use two pointers, α and β, to avoid repeatedly traversing the vectors. • We index the vectors as follows: 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2}
A Tale of Two Pointers • We use two pointers, α and β, to avoid repeatedly traversing the vectors. • We index the vectors as follows: 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2} Most Significant Index
A Tale of Two Pointers • We use two pointers, α and β, to avoid repeatedly traversing the vectors. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2} • α: index such that all variables at more significant indices are ground and equal.
A Tale of Two Pointers • We use two pointers, α and β, to avoid repeatedly traversing the vectors. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2} • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
A Tale of Two Pointers • We use two pointers, α and β, to avoid repeatedly traversing the vectors. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2} • α: index such that all variables at more significant indices are ground and equal. • β: If tails never violate the constraint:
Pointer Initialisation • Needs one traversal of the vectors (linear). • Details in the paper. • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
Pointer Initialisation • Needs one traversal of the vectors (linear). 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2} α • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
Pointer Initialisation • Needs one traversal of the vectors (linear). 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} α {0, 1, 2, 3, 4} {0, 1, 2} β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
Failure • Inconsistent if β α. • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • We maintain α and β as assignments made. • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • We maintain α and β as assignments made. • When β = α + 1 we enforce bounds consistency on: xα < yα • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • We maintain α and β as assignments made. • When β = α + 1 we enforce bounds consistency on: xα < yα The variable at the αth element of each vector. • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • We maintain α and β as assignments made. • When β = α + 1 we enforce bounds consistency on: xα < yα • When β > α + 1 we enforce bounds consistency on: xα yα • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • We maintain α and β as assignments made. • Key: we reduce GAC on vectors to BC on binary constraints. • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • 0, 1 removed from yα. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} α {0, 1, 2, 3, 4} {0, 1, 2} β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • 0, 1 removed from yα. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} α {0, 1, 2, 3, 4} {0, 1, 2} β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • Update α. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} α {0, 1, 2, 3, 4} {0, 1, 2} β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • Update α. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} α {0, 1, 2, 3, 4} {0, 1, 2} β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • 3, 4 removed from xα. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} α {0, 1, 2, 3, 4} {0, 1, 2} β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • 3, 4 removed from xα. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} α {0, 1, 2, 3, 4} {0, 1, 2} β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • Update α. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} α {0, 1, 2, 3, 4} {0, 1, 2} β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • Update α. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2} α β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • 4, 5 removed from xα, 0, 1 removed from yα. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2} α β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
How GACLex Works • 4, 5 removed from xα, 0, 1 removed from yα. 0 x {2} 1 2 3 4 {1, 3, 4} {1, 2, 3, 4, 5} {1, 2} {3, 4, 5} y {0, 1, 2} {1} {0, 1, 2, 3, 4} {0, 1, 2} α β • α: index such that all variables at more significant indices are ground and equal. • β: most significant index from which the two vectors’ tails necessarily violate the constraint.
Complexity • Initialisation: O(n)
Complexity • Initialisation: O(n) • Propagation: • We enforce bounds consistency between at most n pairs of variables: xα < yα or xα yα.
Complexity • Initialisation: O(n) • Propagation: • We enforce bounds consistency between at most n pairs of variables: xα < yα or xα yα. • Cost: b.
Complexity • Initialisation: O(n) • Propagation: • We enforce bounds consistency between at most n pairs of variables: xα < yα or xα yα. • Cost: b. • Overall cost: O(nb).
Alternative 1: Decomposition • x lex y can be decomposed into n nonbinary constraints: • x 0 y 0
Alternative 1: Decomposition • x lex y can be decomposed into n nonbinary constraints: • x 0 y 0 • x 0 = y 0 x 1 y 1
Alternative 1: Decomposition • x lex y can be decomposed into n nonbinary constraints: • x 0 y 0 • x 0 = y 0 x 1 y 1 • x 0 = y 0 x 1 = y 1 x 2 y 2
Alternative 1: Decomposition • x lex y can be decomposed into n nonbinary constraints: • • • x 0 y 0 x 0 = y 0 x 1 y 1 x 0 = y 0 x 1 = y 1 x 2 y 2 … x 0 = y 0 x 1 = y 1 … xn-2 = yn-2 xn-1 yn-1
Alternative 1: Decomposition • x lex y can be decomposed into n nonbinary constraints: • Usually, only forward checking is performed on such non-binary constraints.
Alternative 1: Decomposition • x lex y can be decomposed into n nonbinary constraints: • Usually, only forward checking is performed on such non-binary constraints. • They are also cumbersome.
Alternative 2: Arithmetic Constraints • To ensure that x lex y with domain size d: • dn-1 x 0 + dn-2 x 1 + … + d 0 xn-1 dn-1 y 0 + dn-2 y 1 + … + d 0 yn-1
Alternative 2: Arithmetic Constraints • To ensure that x lex y with domain size d: • dn-1 x 0 + dn-2 x 1 + … + d 0 xn-1 dn-1 y 0 + dn-2 y 1 + … + d 0 yn-1 • Bounds consistency on this expression is equivalent to GAC on x lex y.
Alternative 2: Arithmetic Constraints • To ensure that x lex y with domain size d: • dn-1 x 0 + dn-2 x 1 + … + d 0 xn-1 dn-1 y 0 + dn-2 y 1 + … + d 0 yn-1 • Bounds consistency on this expression is equivalent to GAC on x lex y. • When n and d are large, dn-1 is greater than the word size of the computer.
Alternative 2: Arithmetic Constraints • To ensure that x lex y with domain size d: • dn-1 x 0 + dn-2 x 1 + … + d 0 xn-1 dn-1 y 0 + dn-2 y 1 + … + d 0 yn-1 • Bounds consistency on this expression is equivalent to GAC on x lex y. • When n and d are large, dn-1 is greater than the word size of the computer. • This method is only feasible for small vectors/domain size.
Multiple Lex Constraints • All rows/columns of a matrix might be lex ordered.
Multiple Lex Constraints • All rows/columns of a matrix might be lex ordered. • Can treat as a single global constraint.
Multiple Lex Constraints • All rows/columns of a matrix might be lex ordered. • Can treat as a single global constraint. • GAC on such a constraint is future work. • Can approximate with GACLex between all pairs, or adjacent pairs. • GACLex on all pairs = GAC on whole set for 0/1 vectors.
Experimental Results: BIBD • Standard combinatorial problem. 0 0 1 1 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 1 1 0 0 1 • • • Symmetrical rows and columns v rows. b columns. r 1 s per row. k 1 s per column. λ is scalar product between every pair of rows.
Results: BIBD Decomposition takes About 9 times longer on each of these instances.
Results: BIBD • Fails, Choice-points very similar: • GACLex Decomposition. • Why? • We are using a good static variable ordering. • So substantially decreased run-times due to efficiency gains in this case.
Results: Social Golfers • • Schedule a golf tournament of w weeks. In each week, divide golfers into g groups, size s. Every golfer plays once per week. Every pair of golfers can meet at most once.
Results: Social Golfers • • • Schedule a golf tournament of w weeks. In each week, divide golfers into g groups, size s. Every golfer plays once per week. Every pair of golfers can meet at most once. 3 d 0/1 model: Players Groups Weeks
Results: Social Golfers • • • Schedule a golf tournament of w weeks. In each week, divide golfers into g groups, size s. Every golfer plays once per week. Every pair of golfers can meet at most once. 3 d 0/1 model: Players, groups and weeks all symmetrical Groups Weeks
Results: Social Golfers Decomposition takes between 10 and 56 times longer (at least) on these instances.
Results: Social Golfers More complex interactions in 3 d model result in greater pruning with GACLex. This explains the even greater runtime improvements.
Results: Tournament Scheduling • • n teams play over n-1 weeks. Each week divided into n/2 periods. Each period divided into 2 slots (home/away). Every team: • Plays once a week. • Plays at most twice in the same period. • Plays every other team. Slots, Periods, Weeks are symmetrical Periods Slots(2) Periods Channel Weeks
Results: Tournament Scheduling • Search tree similar. • Variable/value ordering compatible with lex. • Speed increase around 3 x. • Vectors much smaller.
Results: Adjacent v All-pairs • In theory, enforcing lex between all pairs of vectors gives more propagation. • We have seen no evidence of this. • Perhaps conditions appear infrequently.
Conclusion • Global constraints for lexicographic orderings. • Linear time complexity. • Decompositions carry a penalty in the amount or cost of propagation.
Future Work • GACLex for multiple vectors. • Other types of ordering, e. g. multisets. • Compare with other decompositions: • x 0 y 0 (x 0 = y 0 (x 1 y 1 (x 1 = y 1 …
Resources • Solver code coming soon at: • http: //www-users. cs. york. ac. uk/~ianm/
- Slides: 85