210 likes | 323 Views
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
E N D
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 • Range Constraint • Slide Constraint • Global Constraints on Sets
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 ..
GAC Schema 5-ary global constraint: • Compatible(motherboard345,intelCPU,2GHz,1GBRam,80GBdrive) • Compatible(motherboard346,intelCPU,3GHz,2GBRam,100GBdrive) • Compatible(motherboard346,amdCPU,2GHz,2GBRam,100GBdrive) • …
Crossword puzzle Word([X1,X2,X3,X4]) Word([X2,X15,X17]) … No simple way to decide acceptable words other than to put them in a table
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)
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
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
Example • X(C)={x1,x2,x3} D(xi)={a,b} • T(C)={(a,a,a),(a,b,b),(b,b,a),(b,b,b)}
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.
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
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.
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 ...
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
Exploiting constraint semantics • Speed-up the search for a support
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)
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
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
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
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
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