Presentation is loading. Please wait.

Presentation is loading. Please wait.

Global Constraints Toby Walsh National ICT Australia and University of New South Wales www.cse.unsw.edu.au/~tw/global/

Similar presentations


Presentation on theme: "Global Constraints Toby Walsh National ICT Australia and University of New South Wales www.cse.unsw.edu.au/~tw/global/"— Presentation transcript:

1 Global Constraints Toby Walsh National ICT Australia and University of New South Wales www.cse.unsw.edu.au/~tw/global/

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 Lex ordering ● Widely useful – Especially for symmetry breaking – Breaking row and column symmetry in matrix models – Available in most (all?) solvers ● Good example of pointer based global constraint – Pointers save re-doing work – Good incremental behaviour – O(n) in general, but amortised O(1) cost at each node down a branch

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

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

6 Motivation ● Many problems can be modelled by matrices of decision variables. ● E.g. Configuration Problems: – Rack Configuration – Matrix is Xij iff jth card on ith rack

7 Motivation ● Many problems can be modelled by matrices of decision variables. ● E.g. Scheduling Problems: – Social Golfers – 32 golfers want to play in 8 foursomes each day of the week – No two golfers shall meet twice in a foursome – Matrix is Pijk=1 iff player i plays in jth foursome on day k

8 Motivation ● Many problems can be modelled by matrices of decision variables. ● E.g. Design Problems: – Steel Mill Slab Design – Slab[o,j] iff order o is on jth slab – IBM solved this problem for the largest steel maker in Korea

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

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

11 Motivation ● An important class of symmetries in CP – matrices of decision variables – rows/columns represent indistinguishable objects, hence symmetric ● Rows and columns are subject to permutation ● An n X m matrix model with row and column symmetry has n! X m! symmetries – grows super-exponentially ● Too many symmetric search states ● It can be very expensive to visit all the symmetric branches of a search tree

12 Motivation ● Breaking symmetry is very important! ● Breaking all row and column symmetries is difficult – No one has an effective way of dealing with all row and column symmetries. – Symmetry breaking methods have to deal with very large number of symmetries. – The effort required could easily be exponential.

13 Symmetry Frequently occurs –Combinatorial problems like covering arrays Rows and columns can be permuted –Messy real world problems like nurse rostering Nurses with same skills can be swapped Tough for IP –Very active research area within CP –Some effective techniques have been developed

14 Modelling adds symmetry Divide 32 golfers into 8 foursomes so that each week they play with different players –Xijk = ith player in jth group in kth week In this model, we can permute –players within group –groups –weeks Representing a set like a foursome by 4 variables, introduces symmetries (their permutations)!

15 Symmetry in CP ● Add symmetry breaking constraints – Leave at least one solution – Eliminate some/all symmetric solutions ● Modify search algorithm – Ignore symmetric parts of the search space ● Adapt branching heuristic – To explore branches which are most likely not to be symmetric

16 Example ● Consider 2 identical bins: BA

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

18 Example ● Here is one solution: 12 3 65 4 BA

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

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

21 Example ● Consider a matrix model: 1 3 5 2 6 4 a) b) AB BA 1 3 5 2 6 4

22 Example ● Consider a matrix model: 1 3 5 2 6 4 a) b) AB BA 1 3 5 2 6 4 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

23 Example ● Consider a matrix model: If we insist that row A  lex row B, we remove a) from the solution set. b) BA 1 3 5 2 6 4 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

24 Example ● Notice that items 3 and 4 are identical. b) BA 1 3 5 2 6 4 c) 1 4 5 2 6 3 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 1 0 0 1 B 1 0 0 1 1 0

25 Example ● Notice that items 3 and 4 are identical. b) BA 1 3 5 2 6 4 If we insist that col 3  lex col 4, we remove c) from the solution set. 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 1 0 0 1 B 1 0 0 1 1 0

26 Lexicographic Ordering Used to order dictionaries [A,B,C] ≤ lex [D,E,F] –A<D or –(A=D and B<E ) or –(A=D and B=E and C<F) or –(A=D and B=E and C=F)

27 ● Lexicographic ordering is total ● Forcing the rows to be lexicographically ordered breaks all row symmetry Breaking Row (Column) Symmetry ABC DEF GHI [A B C]  lex [D E F]  lex [G H I] [G H I]  lex [D E F]  lex [A B C] lexicographic ordering anti-lexicographic ordering

28 Breaking Row and Column Symmetries Breaking both row and column symmetries is difficult Rows and columns intersect After constraining the rows to be lexicographically ordered –we distinguish the columns –the columns are not symmetric anymore!

29 Good News Each symmetry class of assignments has at least one element where both the rows and the columns are lexicographically ordered –But there may be no element with rows lex ordered and columns anti-lex ordered To break row and column symmetries, we can insist that the rows and columns are both lexicographically ordered (double-lex) Extends to higher dimensions

30 Bad News  A symmetry class of assignments may have more than one element where both the rows and the columns are lexicographically ordered Double-lex does not break all row and column symmetries 01 01 10 01 10 10 swap the columns swap row 1 and row 3

31 Special Cases ● All symmetry can be broken – When variables take distinct values ● Simply push largest value to a particular corner ● Order 1st row and 1st col – 0/1 variables, 1 occurs once in each row/col ● Double LEX then leaves an unique solution

32 GACLex ● A new family of global constraints.

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

34 GACLex ● A new family of global constraints. ● Linear time complexity.

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

36 How GACLex Works x{2}{1,3,4}{2,3,4}{1}{3,4,5} y{0,1,2}{1}{1,2,3}{0}{0,1,2}

37 How GACLex Works ● Consider the following example. ● We have two vectors of decision variables: x{2}{1,3,4}{2,3,4}{1}{3,4,5} y{0,1,2}{1}{1,2,3}{0}{0,1,2} We want to enforce GAC on: x  lex y.

38 A Tale of Two Pointers ● We use two pointers, alpha and beta, to avoid repeatedly traversing the vectors

39 A Tale of Two Pointers x{2}{1,3,4}{2,3,4}{1}{3,4,5} y{0,1,2}{1}{1,2,3}{0}{0,1,2} Most significant index

40 A Tale of Two Pointers alpha: index such that all variables at more significant indices are ground and equal. x{2}{1,3,4}{2,3,4}{1}{3,4,5} y{0,1,2}{1}{1,2,3}{0}{0,1,2}

41 A Tale of Two Pointers ● We use two pointers, alpha and beta, to avoid repeatedly traversing the vectors. beta: most significant index from which the two vectors’ tails necessarily violate the constraint. x{2}{1,3,4}{2,3,4}{1}{3,4,5} y{0,1,2}{1}{1,2,3}{0}{0,1,2}

42 Pointer initialization ● alpha – Scan through vector from start – At most O(n) time ● beta – Scan through vector from end – At most O(n) time

43 Failure ● Inconsistent if beta  alpha. alpha: index such that all variables at more significant indices are ground and equal. beta: most significant index from which the two vectors’ tails necessarily violate the constraint.

44 How GACLex Works ● We maintain alpha and beta as assignments made. alpha: index such that all variables at more significant indices are ground and equal. beta: most significant index from which the two vectors’ tails necessarily violate the constraint.

45 How GACLex Wroks ● We maintain alpha and beta as assignments made. ● When beta = alpha + 1 we enforce bounds consistency on: x alpha < y alpha alpha: index such that all variables at more significant indices are ground and equal. beta: most significant index from which the two vectors’ tails necessarily violate the constraint.

46 How GACLex Works ● We maintain alpha and beta as assignments made. ● When beta = alpha + 1 we enforce bounds consistency on: x alpha < y alpha ● When beta > alpha + 1 we enforce bounds consistency on: x alpha  y alpha alpha: index such that all variables at more significant indices are ground and equal. beta: most significant index from which the two vectors’ tails necessarily violate the constraint.

47 Complexity ● Initialisation: O(n) ● Propagation: We enforce bounds consistency between at most n pairs of variables: x alpha < y αalpha or x alpha  y αalpha. Cost: b. Overall cost: O(nb).

48 Why Have a Global LEX Constraint? ● Two alternatives – Arithmetic constraint – Logical decomposition ● Both limit problem size – And both can be slower! ● Both do less pruning than GAC(X0<lex X1 <lex... <lex Xn)

49 Arithmetic Constraint ● Given A=[a 1,...,a n ] B=[b 1,...,b n ] taking values from {1,...d} A ≤ lex B iff (d n-1 a 1 +... + d 0 a n ) ≤ (d n-1 b 1 +... + d 0 b n ) ● BC(≤) iff GAC(≤ lex ) ● 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. 

50 Logical Decompositions ● Or decomposition A ≤ lex B iff (a 1 < b 1 ) Or (a 1 = b 1 And a 2 < b 2 )... (a 1 = b 1 And a 2 = b 2... a n ≤ b n ) ● And decomposition A ≤ lex B iff (a 1 ≤ b 1 ) And (a 1 = b 1 -> a 2 ≤ b 2 )... (a 1 = b 1 And a 2 = b 2... -> a n ≤ b n ) Many solvers use FC –Less pruning than GAC GAC schema is expensive They are also cumbersome.

51 Results: BIBD ● Standard combinatorial problem. 0000111 0011001 0101010 011010 0 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

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

53 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 matrix model: Groups Weeks Players Players, groups and weeks all symmetrical

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

55 Value Symmetry ● Often values (as well as variables) are symmetric – E.g. Xijk = name of ith golfer, in jth group, in kth week – Values (names of golfer) can be permuted ● Value symmetry can be mapped to variable symmetry – Xijk = m maps to Yijkm = 1 – Can now break this symmetry by LEX ordering m dimension

56 Symmetry Breaking Constraints ● Where do they come from in general? – General method due to Crawford, Ginsberg and Luks ● Will break all symmetries ● But may give exponential number of constraints – Well known special cases ● E.g. row & col symmetry ● Crawford et al’s method gives exponential number of constraints with such symmetries – Black art

57 Conclusion ● Identification of row and column symmetry ● Lexicographic ordering constraints – Double-lex – Value symmetry – Higher dimension ● Global constraints for lexicographic orderings. – Maintain GAC – Linear time complexity. – Decompositions carry a penalty in the amount or cost of propagation.


Download ppt "Global Constraints Toby Walsh National ICT Australia and University of New South Wales www.cse.unsw.edu.au/~tw/global/"

Similar presentations


Ads by Google