Global Variables - PowerPoint PPT Presentation

global variables n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Global Variables PowerPoint Presentation
Download Presentation
Global Variables

play fullscreen
1 / 88
Global Variables
155 Views
Download Presentation
bart
Download Presentation

Global Variables

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Global Variables Irit Katriel BRICS, University of Aarhus ACP Advanced Summer School on Global Constraints - Samos, Greece.

  2. Roles of Global Constraints • Syntactic: Simplify models ACP Advanced Summer School on Global Constraints - Samos, Greece.

  3. Roles of Global Constraints • Speed up solving (by propagation) ACP Advanced Summer School on Global Constraints - Samos, Greece.

  4. 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.

  5. Bin Packing n items of different sizes: s1,…,sn Bin size: b ACP Advanced Summer School on Global Constraints - Samos, Greece.

  6. Bin Packing Pack items in as few bins as possible ACP Advanced Summer School on Global Constraints - Samos, Greece.

  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. 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.

  12. 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.

  13. 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.

  14. 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.

  15. 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.

  16. 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.

  17. 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.

  18. 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.

  19. 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.

  20. 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.

  21. 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.

  22. 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.

  23. 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.

  24. 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.

  25. 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.

  26. 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.

  27. 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.

  28. 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.

  29. 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.

  30. 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.

  31. 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.

  32. 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.

  33. 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.

  34. 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.

  35. 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.

  36. 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.

  37. 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.

  38. 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.

  39. Set vs. Multiset Variables It’s all the same, but with repetitions. right? ACP Advanced Summer School on Global Constraints - Samos, Greece.

  40. 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.

  41. 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.

  42. 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.

  43. 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.

  44. 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.

  45. 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.

  46. 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.

  47. 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.

  48. 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.

  49. 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.

  50. 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.