Presentation is loading. Please wait.

Presentation is loading. Please wait.

Global Constraints for Lexicographic Orderings Alan Frisch, Ian Miguel (University of York) Brahim Hnich, Toby Walsh (4C) Zeynep Kiziltan (Uppsala University)

Similar presentations


Presentation on theme: "Global Constraints for Lexicographic Orderings Alan Frisch, Ian Miguel (University of York) Brahim Hnich, Toby Walsh (4C) Zeynep Kiziltan (Uppsala University)"— Presentation transcript:

1 Global Constraints for Lexicographic Orderings Alan Frisch, Ian Miguel (University of York) Brahim Hnich, Toby Walsh (4C) Zeynep Kiziltan (Uppsala University)

2 GACLex A new family of global constraints.

3 GACLex A new family of global constraints. Non-binary constraint. Specialised propagator.

4 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.

5 GACLex A new family of global constraints. Linear time complexity.

6 GACLex A new family of global constraints. Linear time complexity. Ensures that a pair of vectors of variables are lexicographically ordered.

7 GACLex A new family of global constraint. Linear time complexity. Ensures that a pair of vectors of variables are lexicographically ordered. 0142 2987  lex

8 Motivation Many problems can be modelled by matrices of decision variables.

9 Motivation Many problems can be modelled by matrices of decision variables. E.g. Combinatorial Problems –Balanced Incomplete Block Design.

10 Motivation Many problems can be modelled by matrices of decision variables. E.g. Configuration Problems: –Rack Configuration.

11 Motivation Many problems can be modelled by matrices of decision variables. E.g. Scheduling Problems: –Social Golfers.

12 Motivation Many problems can be modelled by matrices of decision variables. E.g. Design Problems: –Steel Mill Slab Design.

13 Motivation Many problems can be modelled by matrices of decision variables. Frequently these matrices exhibit row and/or column symmetry.

14 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.

15 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.

16 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.

17 Example Consider 2 identical bins: BA

18 Example Consider 2 identical bins: We must pack 6 items: 341652 BA

19 Example Here is one solution: 12 3 65 4 BA

20 Example Here is another: BA 1 3 5 2 6 4

21 Example Is there any fundamental difference? 1 3 5 2 6 4 a) b) AB BA 1 3 5 2 6 4

22 Example Consider a matrix model: 123456 A101010 B010101 123456 A010101 B101010 1 3 5 2 6 4 a) b) AB BA 1 3 5 2 6 4

23 Example Consider a matrix model: NB: ‘1’ means place this item in this bin: 123456 A101010 B010101 123456 A010101 B101010 1 3 5 2 6 4 a) b) AB BA 1 3 5 2 6 4

24 Example Consider a matrix model: If we insist that row A  lex row B, we remove a) from the solution set. 123456 A101010 B010101 123456 A010101 B101010 b) BA 1 3 5 2 6 4

25 Example Notice that items 3 and 4 are identical. 123456 A010101 B101010 b) BA 1 3 5 2 6 4 123456 A011001 B100110 c) BA 1 4 5 2 6 3

26 Example Notice that items 3 and 4 are identical. 123456 A010101 B101010 b) BA 1 3 5 2 6 4 123456 A011001 B100110 If we insist that col 3  lex col 4, we remove c) from the solution set.

27 How GACLex Works Consider the following example. We have two vectors of decision variables:

28 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}{0,1,2}

29 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}{0,1,2} We want to enforce GAC on: x  lex y.

30 A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors.

31 A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. We index the vectors as follows: 01234 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}

32 A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. We index the vectors as follows: 01234 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} Most Significant Index

33 A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. 01234 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} α: index such that all variables at more significant indices are ground and equal.

34 A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. 01234 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} α: 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.

35 A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. 01234 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} α: index such that all variables at more significant indices are ground and equal. β: If tails never violate the constraint: 

36 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.

37 Pointer Initialisation Needs one traversal of the vectors (linear). 01234 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} α: 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. α

38 Pointer Initialisation Needs one traversal of the vectors (linear). 01234 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} α β α: 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.

39 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.

40 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.

41 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.

42 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.

43 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.

44 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.

45 How GACLex Works 01234 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} α β α: 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. 0, 1 removed from y α.

46 How GACLex Works 01234 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} α β α: 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. 0, 1 removed from y α.

47 How GACLex Works 01234 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} α β α: 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. Update α.

48 How GACLex Works 01234 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} α β α: 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. Update α.

49 How GACLex Works 01234 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} α β α: 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. 3, 4 removed from x α.

50 How GACLex Works 01234 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} α β α: 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. 3, 4 removed from x α.

51 How GACLex Works 01234 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} α β α: 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. Update α.

52 How GACLex Works 01234 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} α β α: 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. Update α.

53 How GACLex Works 01234 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} α β α: 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. 4, 5 removed from x α, 0, 1 removed from y α.

54 How GACLex Works 01234 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} α β α: 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. 4, 5 removed from x α, 0, 1 removed from y α.

55 Complexity Initialisation: O(n)

56 Complexity Initialisation: O(n) Propagation: We enforce bounds consistency between at most n pairs of variables: x α < y α or x α  y α.

57 Complexity Initialisation: O(n) Propagation: We enforce bounds consistency between at most n pairs of variables: x α < y α or x α  y α. Cost: b.

58 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).

59 Alternative 1: Decomposition x  lex y can be decomposed into n non- binary constraints: x 0  y 0

60 Alternative 1: Decomposition x  lex y can be decomposed into n non- binary constraints: x 0  y 0 x 0 = y 0  x 1  y 1

61 Alternative 1: Decomposition x  lex y can be decomposed into n non- binary 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

62 Alternative 1: Decomposition x  lex y can be decomposed into n non- binary 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 …  x n-2 = y n-2  x n-1  y n-1

63 Alternative 1: Decomposition x  lex y can be decomposed into n non- binary constraints: Usually, only forward checking is performed on such non-binary constraints.

64 Alternative 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.

65 Alternative 2: Arithmetic Constraints To ensure that x  lex y with domain size d: d n-1  x 0 + d n-2  x 1 + … + d 0  x n-1  d n-1  y 0 + d n-2  y 1 + … + d 0  y n-1

66 Alternative 2: Arithmetic Constraints To ensure that x  lex y with domain size d: d n-1  x 0 + d n-2  x 1 + … + d 0  x n-1  d n-1  y 0 + d n-2  y 1 + … + d 0  y n-1 Bounds consistency on this expression is equivalent to GAC on x  lex y.

67 Alternative 2: Arithmetic Constraints To ensure that x  lex y with domain size d: d n-1  x 0 + d n-2  x 1 + … + d 0  x n-1  d n-1  y 0 + d n-2  y 1 + … + d 0  y n-1 Bounds consistency on this expression is equivalent to GAC on x  lex y. When n and d are large, d n-1 is greater than the word size of the computer.

68 Alternative 2: Arithmetic Constraints To ensure that x  lex y with domain size d: d n-1  x 0 + d n-2  x 1 + … + d 0  x n-1  d n-1  y 0 + d n-2  y 1 + … + d 0  y n-1 Bounds consistency on this expression is equivalent to GAC on x  lex y. When n and d are large, d n-1 is greater than the word size of the computer. This method is only feasible for small vectors/domain size.

69 Multiple Lex Constraints All rows/columns of a matrix might be lex ordered.

70 Multiple Lex Constraints All rows/columns of a matrix might be lex ordered. Can treat as a single global constraint.

71 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.

72 Experimental Results: BIBD Standard combinatorial problem. 0000111 0011001 0101010 0110100 1001100 1010010 1100001 v rows. b columns. r 1s per row. k 1s per column. λ is scalar product between every pair of rows. Symmetrical rows and columns

73 Results: BIBD Decomposition takes About 9 times longer on each of these instances.

74 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.

75 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.

76 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. 3d 0/1 model: Groups Weeks Players

77 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. 3d 0/1 model: Groups Weeks Players Players, groups and weeks all symmetrical

78 Results: Social Golfers Decomposition takes between 10 and 56 times longer (at least) on these instances.

79 Results: Social Golfers More complex interactions in 3d model result in greater pruning with GACLex. This explains the even greater run- time improvements.

80 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. Periods Slots(2) Weeks Periods Weeks Channel Slots, Periods, Weeks are symmetrical

81 Results: Tournament Scheduling Search tree similar. Variable/value ordering compatible with lex. Speed increase around 3x. Vectors much smaller.

82 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.

83 Conclusion Global constraints for lexicographic orderings. Linear time complexity. Decompositions carry a penalty in the amount or cost of propagation.

84 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  …

85 Resources Solver code coming soon at: http://www-users.cs.york.ac.uk/~ianm/


Download ppt "Global Constraints for Lexicographic Orderings Alan Frisch, Ian Miguel (University of York) Brahim Hnich, Toby Walsh (4C) Zeynep Kiziltan (Uppsala University)"

Similar presentations


Ads by Google