Consistency & Propagation with Multiset Constraints Toby Walsh 4C, UCC & Uppsala Outline Multiset vars vars which take a multiset (or bag) of values Representing multiset vars Consistency of multiset vars Global constraints over multiset vars Conclusions Multiset variables Assigned a multiset or bag of values Useful in design & configuration E.g. template design (prob002 in CSPLib) Multiset of labels on each printing template: {{tuna, tuna, tuna, chicken, liver, liver}} Multiset variables Assigned a multiset or bag of values Useful in design & configuration E.g. ILOG’s Configurator Multiset of components in home cinema system: {{plasma screen, DVD, amplifier, speaker, speaker, speaker, speaker, woofer}} Representing multiset vars Naïve, explicit representation Finite domain of all possible multisets BUT exponential More compact (but less expressive) Bounds Occurrences Fixed cardinality Bounds representation Upper and lower bounds on multiset Lower bound = must contain Upper bound = can contain E.g lb is {{DVD, speaker, speaker}} ub is {{DVD, plasma, TV, satellite dish, amplifier, speaker, speaker, speaker, speaker, woofer}} Similar bounds representation used for set vars in [Gervet 97] Occurrence representation Integer variable representing #occurrences of each value E.g. DVD = {1}, Plasma={0,1}, Speaker={2,3,4}, Woofer={0,1}, … Fixed cardinality representation For multisets with fixed (or bounded) cardinality Finite-domain variable for each element in the multiset Introduce “don’t care” value if needed E.g. M1=M2=M3= … = {Video, DVD, plasma, TV, speaker, woofer, satellite} Expressivity Disjunctive choice cannot be fully expressed E.g. none of the 3 can represent just: {{0,0,0}} or {{1,1,1}} Nested multisets are also problematic Especially for occurrence representation Consistency Central notion in CP How do we define it for multiset vars? Also for mixed constraints containing multiset, set and/or integer vars? Slogan of the local Beamish brewery: “Consistency in a world gone mad” Consistency Set of solutions for a var in a constraint C Sol(Xi) = {di | C(d1,..,dn)} C is bounds consistent iff Sol(Xi) ≠ {} For each (multi)set var lub(Xi)= di, glb(Xi)= di where di Sol(Xi) For each integer var lub(Xi)=max(di), glb(Xi)=min(di) where di Sol(Xi) Bounds consistency Representation doesn’t matter BC on bounds representation is equivalent to usual notion of BC on occurrence Existence of BC domains If problem has solution, there exist unique lub and glb that makes constraints BC Multiset constraints Simple predicates XY, XY, X=Y, XY, |X|=N, occ(N,X)=M, … Arguments can be multiset or set expressions Var, ground multiset or set XY, XY, X-Y, … Global constraints disjoint(X1,..,Xn), partition(X1,…,Xn,X), … Normal form Multiset constraints can be put in simple normal form Each constraint is at most ternary E.g. (XY)Z W is transformed to S=XY, T=SZ, T W Propagation algorithms therefore only need deal with a limited class of constraints Similar to normal form used with sets vars in [Gervet 97] Normal form Normalization hurts propagation BC on arbitrary set of constraints is strictly stronger than BC on normalized form But not always BC on normalized form is equivalent if there are no repeated variables Global constraints Important aspect of (finite-domain) CP Identify common patterns Efficient and effective propagators Decomposition usually hurts E.g. all-different = clique of not-equals GAC(all-different) > AC(not-equals) Global multiset constraints Decomposition does not always hurt BC(disjoint(X1,..,Xn) = BC(Xi Xj={}) BC(partition(X1,..,Xn,X)=BC(Xi Xj={}) & BC(Xi .. Xn = X) But can on other global constraints non-empty partition distinct(X1,..,Xn) iff Xi ≠ Xj for all i<j Future directions Multiset OPL Extend OPL to support set and multiset vars Compile down into OPL using occurrence or fixed cardinality representations (or both) Global constraint propagators distinct, non-empty partition, … What do you take home? Representing multiset vars Consistency of multiset vars Bounds, occurrence and fixed cardinality Containing multiset, set and integer vars Global constraints over multiset vars Decomposition does not always hurt What’s the bigger picture? Why stop with multisets? Strings [Golden & Pang, CP03] Fri 10.15 Sequences Trees … Why should CP have only fixed variable types? Abstract variable types