Download presentation

Presentation is loading. Please wait.

Published byHallie Engram Modified over 2 years ago

1
Global Constraints Toby Walsh National ICT Australia and University of New South Wales

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
Conclusions ● Constraint programming is a powerful paradigm for solving many combinatorial optimization problems ● Global constraints are integral to this success ● As we shall see, there are many different types of global constraints – However, a few are central like AllDifferent, Roots, Range, Slide,...

4
All Different Example application

5
Golomb rulers ● Mark ticks on a rule – Distance between any two ticks (not just neighbouring) is distinct ● Applications – Radio-astronomy – Crystallorgraphy –... – Prob006 in CSPLib,

6
Golomb rulers ● Simple solution – Exponentially long ruler – Ticks at 0, 1, 3, 7, 15, 31,... ● Goal is to find minimal length ruler – Sequence of optimization problems – Is there a ruler of length m? – Is there a ruler of length m-1? –...

7
Optimal Golomb rulers ● Known for up to 23 ticks ● Distributed internet project to find larger – 0,1 – 0,1,3 – 0,1,4,6 – 0,1,4,9,11 – 0,1,4,10,12,17 ● Solutions grow as approximately O(n^2)

8
Golomb rulers as CSP ● Variable Xi for each tick – Value is position ● Auxiliary variable Dij for each inter-tick distance – Dij=|Xi-Xj| ● Two (global) constraints – X1

9
Golomb ruler as CSP ● Not yet achieved “dream” of declarative programming – Need to break symmetry of inverting ruler ● D12< Dn-1n – Add implied constraints ● D12

10
AllDifferent ● AllDifferent([X1,..Xn]) iff Xi=/=Xj for i

11
AllDifferent ● AllDifferent([X1,..Xn]) iff Xi=/=Xj for i

12
AllDifferent ● One of the oldest global constraints – In ALICE language [Lauriere 78] ● Found in every constraint solver today – GAC algorithm based on matching theory due to Regin [AAAI 94], runs in O(dn^3/2) – BC algorithm using combinatorics due to Puget [AAAI98], runs in O(nlogn)

13
BC on AllDifferent ● Application of Hall's Theorem – Sometimes called the “marriage” theorem – Given k sets – Then there is an unique and distinct element in each set iff any union of j of the sets has at least j elements for 0

14
Hall's theorem ● You wish to marry n men and women – Each woman declares who they are willing to marry (some set of men) – Each man will be “happy” with whoever is willing to marry them – Clearly any subset of j women, the number of men they are willing to marry must be j or more (thus this condition is necessary) – What is surprising is that it is also sufficient!

15
BC on AllDifferent ● Hall Interval – Interval of values in which as many variables as domain values – E.g. X1 in {1,2,3}, X2 in {1,2}, X3 in {1,2,3} – 3 variables in the interval [1..3] ● AllDifferent([X1,..Xn]) is BC iff – Each interval, the number of vars it covers is less than the width of the interval – No variable outside a Hall Interval has a value within it

16
BC on AllDifferent ● Consider X1 in {1,2}, X2 in {1,2}, X3 in {1,2,3}

17
BC on AllDifferent ● Consider X1 in {1,2}, X2 in {1,2}, X3 in {1,2,3} ● Then [1..2] is a Hall Interval covered by X1 and X2 ● X3 has values inside this Hall Interval ● We can prune these and make AllDifferent BC

18
BC on AllDifferent ● Naïve algorithm considers O(n^2) intervals ● Puget orders intervals – Ordering has O(nlogn) cost – Then can go through them in order

19
GAC on AllDifferent ● GAC algorithm based on matching theory due to Regin [AAAI 94] – runs in O(dn^3/2) ● Matching = set of edges with no two edges having a node in common ● Maximal matching = largest possible matching ● Value graph = bipartite graph between variables and their possible values

20
GAC on AllDifferent ● Consider X1 in {1,3}, X2 in {1,3} and X3 in {1,2}

21
GAC on AllDifferent ● Consider X1 in {1,3}, X2 in {1,3} and X3 in {1,2} X1 X2 X

22
GAC on AllDifferent ● Consider X1 in {1,3}, X2 in {1,3} and X3 in {1,2} X1 X2 X

23
GAC on AllDifferent ● Consider X1 in {1,3}, X2 in {1,3} and X3 in {1,2} X1 X2 X

24
GAC on AllDifferent ● Consider X1 in {1,3}, X2 in {1,3} and X3 in {1,2} X1 X2 X

25
GAC on AllDifferent ● Consider X1 in {1,3}, X2 in {1,3} and X3 in {2} X1 X2 X

26
GAC on AllDifferent ● How do we find edges that don't belong to any maximum matching? ● Find one maximum matching ● Identify strongly connected components ● Prune other edges ● Dominate cost is that of finding maximum matching – Augmenting path algorithm of Hopcroft and Karp

27
Beyond AllDifferent ● Symmetric AllDifferent – Xi=j iff Xj=i ● Useful in sports scheduling – Team1 plays 2 iff Team2 plays 1 ● GAC can be enforced in O(nm) time ● Again based on maximum matching but now in non-bipartite graph

28
Beyond AllDifferent ● Soft AllDifferent – Relax constraint that all values are different – Introduce “cost” variable ● Number of variables that need to change value to make it all different ● Number of binary inequalities not satisfied

29
Beyond AllDifferent ● NValues([X1,...,Xn],M) iff |{j | Xi=j}|=M ● AllDifferent is special case when M=n ● Useful when values represent a resource – Minimize the number of resources used

30
Beyond AllDifferent ● Global cardinality constraint – GCC([X1,..Xn],[a1,..am],[b1,...bm]) iff aj <= |{i | Xi=j }| <= bj for all j – In other words, j occurs between aj and bj times ● Again useful when values represent a resource – You have at least one night shift but no more than four each week

31
Propagating GCC ● Regin gives O(n^2d) flow based algorithm for achieving GAC [AAAI 96] ● Improved recently to O(n^3/2 d) using matching theory ● We'll come back to a similar flow based propagator for the RANGE constraint

32
Conclusions ● AllDifferent is one of the oldest (and most useful) global constraints ● Efficient propagators exist for achieving GAC and BC ● When to choose BC over GAC? – Heuristic choice: BC often best when many more values than variables, GAC when we are close to a permutation (number of vars=number of values)

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google