Title: Global Constraints for Lexicographic Orderings
1Global Constraints for Lexicographic Orderings
- Alan Frisch, Ian Miguel (University of York)
- Brahim Hnich, Toby Walsh (4C)
- Zeynep Kiziltan (Uppsala University)
2GACLex
- A new family of global constraints.
3GACLex
- A new family of global constraints.
Non-binary constraint. Specialised propagator.
4GACLex
- 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.
5GACLex
- A new family of global constraints.
- Linear time complexity.
6GACLex
- A new family of global constraints.
- Linear time complexity.
- Ensures that a pair of vectors of variables are
lexicographically ordered.
7GACLex
- 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
8Motivation
- Many problems can be modelled by matrices of
decision variables.
9Motivation
- Many problems can be modelled by matrices of
decision variables. - E.g. Combinatorial Problems
- Balanced Incomplete Block Design.
10Motivation
- Many problems can be modelled by matrices of
decision variables. - E.g. Configuration Problems
- Rack Configuration.
11Motivation
- Many problems can be modelled by matrices of
decision variables. - E.g. Scheduling Problems
- Social Golfers.
12Motivation
- Many problems can be modelled by matrices of
decision variables. - E.g. Design Problems
- Steel Mill Slab Design.
13Motivation
- Many problems can be modelled by matrices of
decision variables. - Frequently these matrices exhibit row and/or
column symmetry.
14Motivation
- 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.
15Motivation
- 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.
16Motivation
- 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.
17Example
- Consider 2 identical bins
B
A
18Example
- Consider 2 identical bins
B
A
3
4
1
6
5
2
19Example
6
5
3
4
1
2
B
A
20Example
5
6
3
4
1
2
B
A
21Example
- Is there any fundamental difference?
5
6
a)
3
4
1
2
A
B
5
6
b)
3
4
1
2
B
A
22Example
1 2 3 4 5 6
A 1 0 1 0 1 0
B 0 1 0 1 0 1
5
6
a)
3
4
1
2
A
B
1 2 3 4 5 6
A 0 1 0 1 0 1
B 1 0 1 0 1 0
5
6
b)
3
4
1
2
B
A
23Example
NB 1 means place this item in this bin
1 2 3 4 5 6
A 1 0 1 0 1 0
B 0 1 0 1 0 1
5
6
a)
3
4
1
2
A
B
1 2 3 4 5 6
A 0 1 0 1 0 1
B 1 0 1 0 1 0
5
6
b)
3
4
1
2
B
A
24Example
1 2 3 4 5 6
A 1 0 1 0 1 0
B 0 1 0 1 0 1
1 2 3 4 5 6
A 0 1 0 1 0 1
B 1 0 1 0 1 0
5
6
b)
3
4
1
2
B
A
25Example
- Notice that items 3 and 4 are identical.
1 2 3 4 5 6
A 0 1 0 1 0 1
B 1 0 1 0 1 0
5
6
b)
3
4
1
2
B
A
1 2 3 4 5 6
A 0 1 1 0 0 1
B 1 0 0 1 1 0
5
6
c)
4
3
1
2
B
A
26Example
- Notice that items 3 and 4 are identical.
1 2 3 4 5 6
A 0 1 0 1 0 1
B 1 0 1 0 1 0
5
6
b)
3
4
1
2
B
A
1 2 3 4 5 6
A 0 1 1 0 0 1
B 1 0 0 1 1 0
27How GACLex Works
- Consider the following example.
- We have two vectors of decision variables
28How 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 0,1,2
29How 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 0,1,2
- We want to enforce GAC on x ?lex y.
30A Tale of Two Pointers
- We use two pointers, a and ß, to avoid repeatedly
traversing the vectors.
31A Tale of Two Pointers
- We use two pointers, a and ß, to avoid repeatedly
traversing the vectors. - We index the vectors as follows
0 1 2 3 4
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 0,1,2
32A Tale of Two Pointers
- We use two pointers, a and ß, to avoid repeatedly
traversing the vectors. - We index the vectors as follows
0 1 2 3 4
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 0,1,2
33A Tale of Two Pointers
- We use two pointers, a and ß, to avoid repeatedly
traversing the vectors.
0 1 2 3 4
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 0,1,2
- a index such that all variables at more
significant indices are ground and equal.
34A Tale of Two Pointers
- We use two pointers, a and ß, to avoid repeatedly
traversing the vectors.
0 1 2 3 4
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 0,1,2
- a 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.
35A Tale of Two Pointers
- We use two pointers, a and ß, to avoid repeatedly
traversing the vectors.
0 1 2 3 4
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 0,1,2
- a index such that all variables at more
significant indices are ground and equal. - ß If tails never violate the constraint ?
36Pointer Initialisation
- Needs one traversal of the vectors (linear).
- Details in the paper.
- a 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.
37Pointer Initialisation
- Needs one traversal of the vectors (linear).
0 1 2 3 4
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 0,1,2
a
- a 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.
38Pointer Initialisation
- Needs one traversal of the vectors (linear).
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
39Failure
- a 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.
40How GACLex Works
- We maintain a and ß as assignments made.
- a 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.
41How GACLex Works
- We maintain a and ß as assignments made.
- When ß a 1 we enforce bounds consistency on
xa lt ya
- a 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.
42How GACLex Works
- We maintain a and ß as assignments made.
- When ß a 1 we enforce bounds consistency on
xa lt ya
- a 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.
43How GACLex Works
- We maintain a and ß as assignments made.
- When ß a 1 we enforce bounds consistency on
xa lt ya - When ß gt a 1 we enforce bounds consistency on
xa ? ya
- a 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.
44How GACLex Works
- We maintain a and ß as assignments made.
- Key we reduce GAC on vectors to BC on binary
constraints.
- a 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.
45How GACLex Works
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
46How GACLex Works
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
47How GACLex Works
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
48How GACLex Works
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
49How GACLex Works
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
50How GACLex Works
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
51How GACLex Works
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
52How GACLex Works
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
53How GACLex Works
- 4, 5 removed from xa, 0, 1 removed from ya.
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
54How GACLex Works
- 4, 5 removed from xa, 0, 1 removed from ya.
0 1 2 3 4
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 0,1,2
a
ß
- a 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.
55Complexity
56Complexity
- Initialisation O(n)
- Propagation
- We enforce bounds consistency between at most n
pairs of variables xa lt ya or xa ? ya.
57Complexity
- Initialisation O(n)
- Propagation
- We enforce bounds consistency between at most n
pairs of variables xa lt ya or xa ? ya. - Cost b.
58Complexity
- Initialisation O(n)
- Propagation
- We enforce bounds consistency between at most n
pairs of variables xa lt ya or xa ? ya. - Cost b.
- Overall cost O(nb).
59Alternative 1 Decomposition
- x ?lex y can be decomposed into n non-binary
constraints - x0 ? y0
60Alternative 1 Decomposition
- x ?lex y can be decomposed into n non-binary
constraints - x0 ? y0
- x0 y0 ? x1 ? y1
61Alternative 1 Decomposition
- x ?lex y can be decomposed into n non-binary
constraints - x0 ? y0
- x0 y0 ? x1 ? y1
- x0 y0 ? x1 y1 ? x2 ? y2
62Alternative 1 Decomposition
- x ?lex y can be decomposed into n non-binary
constraints - x0 ? y0
- x0 y0 ? x1 ? y1
- x0 y0 ? x1 y1 ? x2 ? y2
-
- x0 y0 ? x1 y1 ? xn-2 yn-2 ? xn-1 ? yn-1
63Alternative 1 Decomposition
- x ?lex y can be decomposed into n non-binary
constraints - Usually, only forward checking is performed on
such non-binary constraints.
64Alternative 1 Decomposition
- x ?lex y can be decomposed into n non-binary
constraints - Usually, only forward checking is performed on
such non-binary constraints. - They are also cumbersome.
65Alternative 2 Arithmetic Constraints
- To ensure that x ?lex y with domain size d
- dn-1 ? x0 dn-2 ? x1 d0 ? xn-1 ?
- dn-1 ? y0 dn-2 ? y1 d0 ? yn-1
66Alternative 2 Arithmetic Constraints
- To ensure that x ?lex y with domain size d
- dn-1 ? x0 dn-2 ? x1 d0 ? xn-1 ?
- dn-1 ? y0 dn-2 ? y1 d0 ? yn-1
- Bounds consistency on this expression is
equivalent to GAC on x ?lex y.
67Alternative 2 Arithmetic Constraints
- To ensure that x ?lex y with domain size d
- dn-1 ? x0 dn-2 ? x1 d0 ? xn-1 ?
- dn-1 ? y0 dn-2 ? y1 d0 ? 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.
68Alternative 2 Arithmetic Constraints
- To ensure that x ?lex y with domain size d
- dn-1 ? x0 dn-2 ? x1 d0 ? xn-1 ?
- dn-1 ? y0 dn-2 ? y1 d0 ? 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.
69Multiple Lex Constraints
- All rows/columns of a matrix might be lex ordered.
70Multiple Lex Constraints
- All rows/columns of a matrix might be lex
ordered. - Can treat as a single global constraint.
71Multiple 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.
72Experimental Results BIBD
- Standard combinatorial problem.
- v rows.
- b columns.
- r 1s per row.
- k 1s per column.
- ? is scalar product between every pair of rows.
0 0 0 0 1 1 1
0 0 1 1 0 0 1
0 1 0 1 0 1 0
0 1 1 0 1 0 0
1 0 0 1 1 0 0
1 0 1 0 0 1 0
1 1 0 0 0 0 1
73Results BIBD
Decomposition takes About 9 times longer on each
of these instances.
74Results 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.
75Results 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.
76Results 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.
- 3d 0/1 model
Players
Groups
Weeks
77Results 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.
- 3d 0/1 model
Players
Players, groups and weeks all symmetrical
Groups
Weeks
78Results Social Golfers
Decomposition takes between 10 and 56 times
longer (at least) on these instances.
79Results Social Golfers
More complex interactions in 3d model result in
greater pruning with GACLex.
This explains the even greater run-time
improvements.
80Results 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.
Periods
Slots(2)
Channel
Periods
Weeks
Weeks
81Results Tournament Scheduling
- Search tree similar.
- Variable/value ordering compatible with lex.
- Speed increase around 3x.
- Vectors much smaller.
82Results 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.
83Conclusion
- Global constraints for lexicographic orderings.
- Linear time complexity.
- Decompositions carry a penalty in the amount or
cost of propagation.
84Future Work
- GACLex for multiple vectors.
- Other types of ordering, e.g. multisets.
- Compare with other decompositions
- x0 ? y0 ? (x0 y0 ? (x1 ? y1 ? (x1 y1 ?
85Resources
- Solver code coming soon at
- http//www-users.cs.york.ac.uk/ianm/