880 likes | 1.07k Views
Global Variables. Irit Katriel BRICS, University of Aarhus. Roles of Global Constraints. Syntactic: Simplify models. Roles of Global Constraints. Speed up solving (by propagation). Global Variables. Assigned structured data, e.g., A set of scalar values A graph A function …
E N D
Global Variables Irit Katriel BRICS, University of Aarhus ACP Advanced Summer School on Global Constraints - Samos, Greece.
Roles of Global Constraints • Syntactic: Simplify models ACP Advanced Summer School on Global Constraints - Samos, Greece.
Roles of Global Constraints • Speed up solving (by propagation) ACP Advanced Summer School on Global Constraints - Samos, Greece.
Global Variables • Assigned structured data, e.g., • A set of scalar values • A graph • A function • … • Same roles as global constraints • Simplify models • Improve propagation ACP Advanced Summer School on Global Constraints - Samos, Greece.
Bin Packing n items of different sizes: s1,…,sn Bin size: b ACP Advanced Summer School on Global Constraints - Samos, Greece.
Bin Packing Pack items in as few bins as possible ACP Advanced Summer School on Global Constraints - Samos, Greece.
Bin Packing - Model 1 A variable for each item: x1,…,xn At most n bins: D(x1) = {1,…,n}Constraints: Objective: ACP Advanced Summer School on Global Constraints - Samos, Greece.
Bin Packing - Model 1 A variable for each item: x1,…,xn At most n bins: D(x1) = {1,…,n}Constraints: Objective: Complicated constraints Symmetry breaking? ACP Advanced Summer School on Global Constraints - Samos, Greece.
Bin Packing - Model 2 A set for each bin: b1,…,bn D(bi) = P({1,…,n})Constraints: Objective: ACP Advanced Summer School on Global Constraints - Samos, Greece.
Bin Packing - Model 2 A set for each bin: b1,…,bn D(bi) = P({1,…,n})Constraints: Objective: Simple constraints Symmetry: lex order among sets. ACP Advanced Summer School on Global Constraints - Samos, Greece.
Shift Assignment(a generalization of GCC) Shifts [1,2] [1,1] [2,3] [0,1] [1,3] [1,2] [0,1] [0,2] [1,2] [1,1] [1,1] [1,2] [1,3] [0,1] Employees Each employee is assigned a setof shifts! ACP Advanced Summer School on Global Constraints - Samos, Greece.
Domain Representation • Enumerate all subsets • Pro: Accurate (any domain can be expressed) • Con: Exponential blowup D(X)= { {1,2,3}, {2,3}, {3} } ACP Advanced Summer School on Global Constraints - Samos, Greece.
Domain Representation Solution: Approximate domains D(X)= {5, 7, 9, 15, 23, 27, 39, 43} Can be approximated by an interval of the integers D(X)= [5, 43] ACP Advanced Summer School on Global Constraints - Samos, Greece.
Compact Set Representation • Collection of domain variables • x1,…,xn, D(xi) = Universe • AllDifferent(x1,…,xn) • Break symmetry: x1< … <xn • If cardinality is unknown, add a dummy value (and replace AllDifferent by NValue) • Pro: Compact (in terms of space requirements) • Con: Inaccurate, clumsy • Set variables are an abstraction of this representation ACP Advanced Summer School on Global Constraints - Samos, Greece.
Set Bounds [Puget’92, Gervet’97] The domain is specified by two sets: U (upper bound) Set inclusion lattice L (lower bound) ACP Advanced Summer School on Global Constraints - Samos, Greece.
Compact Domain Representation D(X)= { {1,2,3}, {2,3}, {3} } Becomes D(X) = [ {3}, {1,2,3} ] ACP Advanced Summer School on Global Constraints - Samos, Greece.
Compact Domain Representation D(X)= { {1,2,3}, {2,3}, {3} } Becomes D(X) = [ {3}, {1,2,3} ] Note: D(X) contains also {2,3} ! ACP Advanced Summer School on Global Constraints - Samos, Greece.
Partial vs. Total Order Note: L and U may not belong to the domain! • D(X)= { {1,2}, {1,3} } • Becomes • D(X) = [ {1}, {1,2,3} ] ACP Advanced Summer School on Global Constraints - Samos, Greece.
Filtering Bound consistency: Narrow the domain as much as possible without losing any solutions U (upper bound) L (lower bound) ACP Advanced Summer School on Global Constraints - Samos, Greece.
Filtering Bound consistency: Narrow the domain as much as possible without losing any solutions U (upper bound) L (lower bound) ACP Advanced Summer School on Global Constraints - Samos, Greece.
A Simple Example Subset(S,X)(S is a subset of X) Where D(S)=[LS,US], D(X)=[LX,UX] ACP Advanced Summer School on Global Constraints - Samos, Greece.
A Simple Example Subset(S,X)(S is a subset of X) Where D(S)=[LS,US], D(X)=[LX,UX] Running time:O(|Us|+|Ux|) ACP Advanced Summer School on Global Constraints - Samos, Greece.
Lattice Domain Representation • Pro • Compact (space and specification) • Filtering time depends on size of representation and not on cardinality of domain • Con • Not all domains can be expressed accurately • Partial filtering (only bounds) ACP Advanced Summer School on Global Constraints - Samos, Greece.
Symmetric Cardinality Constraint[Kocjan, Kreuger – CPAIOR 2004] [1,2] [1,1] [2,3] [0,1] Shifts Employees [1,1] [1,2] [0,1] [0,2] [1,3] ACP Advanced Summer School on Global Constraints - Samos, Greece.
Symmetric Cardinality Constraint[Kocjan, Kreuger – CPAIOR 2004] s [1,2] [0,1] [2,3] [1,1] [0,1] [4,7] [1,2] [0,2] [0,1] [1,3] [1,1] t ACP Advanced Summer School on Global Constraints - Samos, Greece.
Symmetric Cardinality Constraint[Kocjan, Kreuger – CPAIOR 2004] s [1,2] [0,1] [2,3] [1,1] [0,1] [4,7] [1,2] [0,2] [0,1] [1,3] [1,1] t ACP Advanced Summer School on Global Constraints - Samos, Greece.
Symmetric Cardinality Constraint[Kocjan, Kreuger – CPAIOR 2004] s Residual graph: [0,1] [0,1] [0,1] [0,1] [0,3] [0,1] [0,1] [0,1] [0,2] t ACP Advanced Summer School on Global Constraints - Samos, Greece.
Symmetric Cardinality Constraint[Kocjan, Kreuger – CPAIOR 2004] s Strongly Connected Components: [0,1] [0,1] [0,1] [0,1] [0,3] [0,1] [0,1] [0,1] [0,2] t ACP Advanced Summer School on Global Constraints - Samos, Greece.
Symmetric Cardinality Constraint[Kocjan, Kreuger – CPAIOR 2004] Non-flow edge between SCCs: Infeasible. s [0,1] [0,1] [0,1] [0,1] [0,3] [0,1] [0,1] [0,1] [0,2] t ACP Advanced Summer School on Global Constraints - Samos, Greece.
Symmetric Cardinality Constraint[Kocjan, Kreuger – CPAIOR 2004] Flow edge between SCCs: Mandatory. s [0,1] [0,1] [0,1] [0,1] [0,3] [0,1] [0,1] [0,1] [0,2] t ACP Advanced Summer School on Global Constraints - Samos, Greece.
Symetric Cardinality Constraint[Kocjan, Kreuger – CPAIOR 2004] Algorithm: • Connect each employee with possible shifts • by edge of capacity [1,1] if the shift is mandatory • by edge of capacity [0,1] otherwise ACP Advanced Summer School on Global Constraints - Samos, Greece.
Symetric Cardinality Constraint[Kocjan, Kreuger – CPAIOR 2004] Algorithm: • Connect employee with all possibleshifts • by edge of capacity [1,1] if the shift is mandatory • by edge of capacity [0,1] otherwise • Find a flow, construct the residual graph • Edges between SCCs are filtered • Non-flow edges are deleted • Inconsistency if one of them was mandatory • Flow edges become mandatory • If they were not already ACP Advanced Summer School on Global Constraints - Samos, Greece.
FixedCardinalityDisjoint(X1,…,Xn,C) • Set Variables X1,…,Xn • A constant C • Semantics: [Sadler and Gevret, Techreport’04 / Bessiere et al. CP’04 / Implemented in ILOG solver] ACP Advanced Summer School on Global Constraints - Samos, Greece.
FixedCardinalityDisjoint(X1,…,Xn,C) Special case of the symmetric cardinality constraint: [0,1] [0,1] [0,1] [0,1] values Set variables [C, C] [C,C] [C,C] [C,C] [C,C] ACP Advanced Summer School on Global Constraints - Samos, Greece.
FixedCardinalityDisjoint(X1,…,Xn,C) Actually, this is an upside-down GCC: [C,C] [C,C] [C,C] [C,C] [C,C] Set variables values Domain variables values [0,1] [0,1] [0,1] [0,1] ACP Advanced Summer School on Global Constraints - Samos, Greece.
Multiset Variables [Walsh CP’03] • Domain representations: • Domain Variables • Same problems as with sets • Bounds: Generalization of Gervet/Puget’s set intervals • D(X)=[L,U] where L and U are multisets • Occurrence representation • D(X)=(a,{0,1}), (b,{3,4}), (c,{2,5}) ACP Advanced Summer School on Global Constraints - Samos, Greece.
Multiset Variables [Walsh CP’03] Thm: Occurrence representation is more expressive than bound representation D(X) = { {a} , {a,a,a} } Bounds: D(X)=[{a},{a,a,a}] • Includes {a,a} Occurrence: D(X)=[(a,{1,3})] ACP Advanced Summer School on Global Constraints - Samos, Greece.
Multiset Variables [Walsh CP’03] Thm: Occurrence representation is more expressive than bound representation This does not hold if occurrences are described as intervals! (a,[1,3]) = [{a},{a,a,a}] ACP Advanced Summer School on Global Constraints - Samos, Greece.
Set vs. Multiset Variables It’s all the same, but with repetitions. right? ACP Advanced Summer School on Global Constraints - Samos, Greece.
FixedCardinalityDisjoint(X1,…,Xn,C) It’s all the same, but with repetitions. right? values [ 0, occi ] Multiset variables [C, C] [C,C] [C,C] [C,C] [C,C] ACP Advanced Summer School on Global Constraints - Samos, Greece.
FixedCardinalityDisjoint(X1,…,Xn,C) It’s all the same, but with repetitions. right? [ 0, max{occi} ] values [ 0, occi ] Multiset variables [C, C] [C,C] [C,C] [C,C] [C,C] ACP Advanced Summer School on Global Constraints - Samos, Greece.
FixedCardinalityDisjoint(X1,…,Xn,C) It’s all the same, but with repetitions. right? [ 0, max{occi} ] values [ 0, occi ] Multiset variables [C, C] [C,C] [C,C] [C,C] [C,C] But how do we enforce disjointness? ACP Advanced Summer School on Global Constraints - Samos, Greece.
FixedCardinalityDisjoint(X1,…,Xn,C) It’s all the same, but with repetitions. right? [ 0, max{occi} ] values { 0, occi } Multiset variables [C, C] [C,C] [C,C] [C,C] [C,C] But how do we enforce disjointness? ACP Advanced Summer School on Global Constraints - Samos, Greece.
FixedCardinalityDisjoint(X1,…,Xn,C) It’s all the same, but with repetitions. right? [ 0, max{occi} ] values Flow becomes NP-Hard { 0, occi } Multiset variables [C, C] [C,C] [C,C] [C,C] [C,C] But how do we enforce disjointness? ACP Advanced Summer School on Global Constraints - Samos, Greece.
FixedCardinalityDisjoint(X1,…,Xn,C) It’s all the same, but with repetitions. right? Apparently not! Thm [Bessiere et al. CP’04]: It is NP-hard to check feasibility for FCDisjoint on multiset variables. ACP Advanced Summer School on Global Constraints - Samos, Greece.
Value Set variable Reduction from 3-SAT x11 x13 x23 x24 !x12 !x21 p3 p1 p2 p4 n1 n2 n3 n4 ACP Advanced Summer School on Global Constraints - Samos, Greece.
Value Set variable Reduction from 3-SAT x11 x13 x23 x24 !x12 !x21 Value for each non-negated occurrence Value for each negated occurrence Variable for each clause Cardinality = 1 Clause variables ”take” one literal from each clause ACP Advanced Summer School on Global Constraints - Samos, Greece.
Value Set variable Reduction from 3-SAT x11 x13 x23 x24 !x12 !x21 ni if xi is false pi if xi is true p3 p1 p2 p4 n1 n2 n3 n4 Variable for each non-negated occurrence Cardinality = # occurrences Variable for each negated occurrence Cardinality = # occurrences ”True” and ”False” value for each variable ACP Advanced Summer School on Global Constraints - Samos, Greece.
Value Set variable Reduction from 3-SAT x11 x13 x23 x24 !x12 !x21 p4 p3 p1 p2 n1 n2 n3 n4 Consistency variables Cardinality = 1 ACP Advanced Summer School on Global Constraints - Samos, Greece.
Value Set variable Reduction from 3-SAT X2=x4 =FALSE X1=X3 =TRUE x11 x13 x23 x24 !x12 !x21 p4 p3 p1 p2 n1 n2 n3 n4 ”0 times” ACP Advanced Summer School on Global Constraints - Samos, Greece.