Global Constraints

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

description

Toby Walsh National ICT Australia and University of New South Wales www.cse.unsw.edu.au/~tw. Global Constraints. Course outline. Introduction All Different Lex ordering Value precedence Complexity GAC-Schema Soft Global Constraints Global Grammar Constraints Roots Constraint - PowerPoint PPT Presentation

Transcript of Global Constraints

Page 1: Global Constraints

Global Constraints

Toby WalshNational ICT Australia and

University of New South Waleswww.cse.unsw.edu.au/~tw

Page 2: Global Constraints

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

Page 3: Global Constraints

GAC Schema

● Not all global constraints have nice semantics we can exploit to devise an efficient propagator

● Consider product configuration– Compatibility constraints on hardware components– Only certain combinations of components work

together– Compatibility may not be a simple pairwise

relationship● Video cards supported function of motherboard, CPU, clock

speed, O/S ..

Page 4: Global Constraints

GAC Schema

5-ary global constraint:– Compatible(motherboard345

,intelCPU,2GHz,1GBRam,80GBdrive)

– Compatible(motherboard346,intelCPU,3GHz,2GBRam,100GBdrive)

– Compatible(motherboard346,amdCPU,2GHz,2GBRam,100GBdrive)

– …

Page 5: Global Constraints

Crossword puzzle

Word([X1,X2,X3,X4])Word([X2,X15,X17])…

No simple way to decide acceptable words other than toput them in a table

Page 6: Global Constraints

GAC schema

● Generic propagator

– Enforces GAC on global constraint given by

● Set of allowed tuples OR● Set of disallowed tuples OR● Predicate answering if a constraint is satisfied or not● ..

– Sometimes called the “table” constraint (e.g. user supplies table of acceptable values)

Page 7: Global Constraints

GAC-Schema

● Bessiere and Regin, IJCAI’97● You just have to say how to compute a solution.● Works incrementally (notion of support)

– Keeps supports found to save re-finding them– Exploits multi-directionality

● If we find support for X=a and this contains Y=b ● Then we automatically have a support for Y=b

Page 8: Global Constraints

GAC-Schema

● Idea: tuple = solution of the constraintsupport = valid tuple- while the tuple remains: do nothing

- if the tuple is no longer possible, then search for a new support for the values it contains

● a solution (support) can be computed by any algorithm

Page 9: Global Constraints

Example

● X(C)={x1,x2,x3} D(xi)={a,b}● T(C)={(a,a,a),(a,b,b),(b,b,a),(b,b,b)}

Page 10: Global Constraints

Example

● X(C)={x1,x2,x3} D(xi)={a,b}● T(C)={(a,a,a),(a,b,b),(b,b,a),(b,b,b)}● Support for (x1,a): (a,a,a) is computed and (a,a,a) is added to S(x2,a) and S(x3,a),

(x1,a) in (a,a,a) is marked as supported.

Page 11: Global Constraints

Example

● X(C)={x1,x2,x3} D(xi)={a,b}● T(C)={(a,a,a),(a,b,b),(b,b,a),(b,b,b)}● Support for (x1,a): (a,a,a) is computed and (a,a,a) is added to S(x2,a) and S(x3,a),

(x1,a) in (a,a,a) is marked as supported.● Support for (x2,a): (a,a,a) is in S(x2,a) it is valid, therefore it is a support.

(Multidirectionnality). No need to compute a solution

Page 12: Global Constraints

Example

● X(C)={x1,x2,x3} D(xi)={a,b}● T(C)={(a,a,a),(a,b,b),(b,b,a),(b,b,b)}● Support for (x1,a): (a,a,a) is computed and (a,a,a) is added to S(x2,a) and S(x3,a),

(x1,a) in (a,a,a) is marked as supported.● Value a is removed from x1, then all the tuples in S(x1,a) are no longer valid:

(a,a,a) for instance. The validity of the values supported by this tuple must be

reconsidered.

Page 13: Global Constraints

Example

● X(C)={x1,x2,x3} D(xi)={a,b}● T(C)={(a,a,a),(a,b,b),(b,b,a),(b,b,b)}● Support for (x1,a): (a,a,a) is computed and (a,a,a) is added to S(x2,a) and S(x3,a),

(x1,a) in (a,a,a) is marked as supported.● Support for (x1,b): (b,b,a) is computed, and updated ...

Page 14: Global Constraints

GAC-Schema: complexity

● In worst case, GAC schema enforces GAC in – O(d^k) time and – O(k^2d) space

● Hence, k cannot be too large!– ILOG Solver limits it to 3 or so– Recall want local consistency to be O(d^2) or less– Hence all this work on specialized propagators that exploit

the constraint semantics to be faster than O(d^k) for k>3

Page 15: Global Constraints

Exploiting constraint semantics

● Speed-up the search for a support

Page 16: Global Constraints

Exploiting constraint semantics

● Speed-up the search for a support ● x < y, D(x)=[0..10000], D(y)=[0..10000]

– support for (x,9000)– immediate any value greater than 9000 in D(y)

Page 17: Global Constraints

Semantics of a constraint

● Design of an ad-hoc filtering algorithm:x < y :

● Two invariants (a) max(x) = max(y) -1

(b) min(y) = min(x) +1

Page 18: Global Constraints

Exploiting constraint semantics

● Design of an ad-hoc filtering algorithm:x < y :

● Two invariants (a) max(x) = max(y) -1

(b) min(y) = min(x) +1● Triggering of the filtering algorithm:

no possible pruning of D(x) while max(y) is not modifiedno possible pruning of D(y) while min(x) is not modified

Page 19: Global Constraints

Building constraint propagators

● When to wake constraint?– Only want this to happen when it is likely to prune

● When any domain changes?● When upper bound changes?● …

● When is a constraint no longer useful?– If a constraint is logically entailed, it can no longer

prune– Never want it to wake up– Set flag and ignore till backtrack out of this point

Page 20: Global Constraints

Building constraint propagators

● How to avoid re-doing work?– When constraint re-awakes, how do we re-build all the

data structures it needs– Remember the network flow for the GCC constraint or

the Hall intervals in the AllDifferent constraint– Remember the pointers used in the LEX constraint to

avoid re-traversing the vectors

Page 21: Global Constraints

Conclusions

● GAC Schema is a generic propagator for global constraints– Useful when constraints lacks any special semantics

we can exploit– Time complexity is O(d^k) in general where k is the

constraint arity– Only useful than for relatively small k– Useful nevertheless for product configuration and other

real world domans