outline
play

Outline 1. Reification Reification 2. Global Constraints Global - PowerPoint PPT Presentation

Topic 16: Propagators 1 (Version of 13th November 2020) Pierre Flener Optimisation Group Department of Information Technology Uppsala University Sweden Course 1DL441: Combinatorial Optimisation and Constraint Programming, whose part 1 is


  1. Topic 16: Propagators 1 (Version of 13th November 2020) Pierre Flener Optimisation Group Department of Information Technology Uppsala University Sweden Course 1DL441: Combinatorial Optimisation and Constraint Programming, whose part 1 is Course 1DL451: Modelling for Combinatorial Optimisation 1 Based partly on material by N. Beldiceanu and Ch. Schulte

  2. Outline 1. Reification Reification 2. Global Constraints Global Constraints 3. linear linear channel 4. channel element extensional 5. element distinct Na¨ ıve DC 6. extensional Propagator Efficient DC Propagator Efficient BC 7. distinct Propagator Na¨ ıve DC Propagator Efficient DC Propagator Efficient BC Propagator COCP/M4CO 16 - 2 -

  3. Outline 1. Reification Reification 2. Global Constraints Global Constraints 3. linear linear channel 4. channel element extensional 5. element distinct Na¨ ıve DC 6. extensional Propagator Efficient DC Propagator Efficient BC 7. distinct Propagator Na¨ ıve DC Propagator Efficient DC Propagator Efficient BC Propagator COCP/M4CO 16 - 3 -

  4. Reification Implementation of b ⇔ γ ( · · · ) : Reification When there are search guesses or other constraints on the Global reifying 0 / 1-variable b : Constraints linear If the variable b becomes fixed to 1, channel then the constraint γ ( · · · ) is propagated. element extensional If the variable b becomes fixed to 0, distinct Na¨ ıve DC then the constraint ¬ γ ( · · · ) is propagated. Propagator Efficient DC Propagator If the constraint γ ( · · · ) is subsumed, Efficient BC Propagator then the variable b is fixed to 1. If the constraint ¬ γ ( · · · ) is subsumed, then the variable b is fixed to 0. COCP/M4CO 16 - 4 -

  5. Constraint combination with reification: With reification, constraints can be arbitrarily combined with logical connectives: negation ( ¬ ), disjunction ( ∨ ), conjunction ( & ), implication ( ⇒ ), and equivalence ( ⇔ ). However, propagation may be very poor! Reification Global Example Constraints linear The composite constraint ( γ 1 & γ 2 ) ∨ γ 3 is modelled as channel element ( b 1 ⇔ γ 1 ) & ( b 2 ⇔ γ 2 ) & ( b 3 ⇔ γ 3 ) extensional & ( b 1 · b 2 = b ) & ( b + b 3 ≥ 1 ) distinct Na¨ ıve DC Propagator Hence even the constraints γ 1 and γ 2 must be reified. Efficient DC Propagator If γ 1 is x = y + 1 and γ 2 is y = x + 1, then γ 1 & γ 2 is unsat; Efficient BC Propagator however, b is then not fixed to value 0 by propagation, as each propagator works individually and there is no communication through the shared variables x and y ; hence b 3 = 1 is not propagated and γ 3 is not forced to hold. COCP/M4CO 16 - 5 -

  6. Remember the warning in Topic 2: Basic Modelling that the disjunction and negation of constraints (with \/ , xor , not , <- , -> , <-> , exists , xorall , if θ then φ else ψ endif ) in MiniZinc often makes the solving slow? Reification Global Example Constraints linear The MiniZinc disjunctive constraint channel constraint x = 0 \/ x = 9; element extensional is flattened for Gecode as follows, with reification: distinct Na¨ ıve DC Propagator ( b 0 ⇔ x = 0 ) & ( b 9 ⇔ x = 9 ) & ( b 0 + b 9 ≥ 1 ) Efficient DC Propagator Efficient BC Propagator But it is logically equivalent to the variable declaration var {0,9}: x; where no reification is involved, and even no propagation. COCP/M4CO 16 - 6 -

  7. Remember the strong warning in Topic 2: Basic Modelling about a conditional if θ then φ 1 else φ 2 endif or a comprehension, say [i | i in ρ where θ ] , in MiniZinc having a test θ that depends on variables? Reification Example Global Constraints Consider var 1..9: x and var 1..9: y for linear channel forall(i in 1..9 where i > x)(i > y) element Recall that this is syntactic sugar for extensional distinct forall([i > y | i in 1..9 where i > x]) Na¨ ıve DC Propagator Efficient DC This is flattened for Gecode into the equivalent of Propagator Efficient BC Propagator forall(i in 1..9)(i > x -> i > y) that is with a logical implication ( -> ), hence with a hidden logical disjunction ( \/ ): for each i , both sub-constraints are reified as both have variables. COCP/M4CO 16 - 7 -

  8. Outline 1. Reification Reification 2. Global Constraints Global Constraints 3. linear linear channel 4. channel element extensional 5. element distinct Na¨ ıve DC 6. extensional Propagator Efficient DC Propagator Efficient BC 7. distinct Propagator Na¨ ıve DC Propagator Efficient DC Propagator Efficient BC Propagator COCP/M4CO 16 - 8 -

  9. Definition A primitive constraint is not decomposable. A global constraint is definable by a logical formula (usually a conjunction) involving primitive constraints, Reification but not always in a trivial way. Global Constraints For domain consistency, all solutions to a constraint need to linear be considered: a na¨ ıve propagator, first computing all the channel element solutions and then projecting them onto the domains of the extensional variables, often takes too much time and space: distinct Na¨ ıve DC Propagator Example (already seen in Topic 13: Consistency) Efficient DC Propagator The store { x �→ { 2 , . . . , 7 } , y �→ { 0 , 1 , 2 } , z �→ {− 1 , . . . , 2 }} Efficient BC Propagator has the solutions � 3 , 1 , 0 � , � 5 , 0 , 1 � , and � 6 , 2 , 0 � to the linear equality constraint x = 3 · y + 5 · z . Hence the store { x �→ { 3 , 5 , 6 } , y �→ { 0 , 1 , 2 } , z �→ { 0 , 1 }} is domain-consistent. (Continued on slide 18.) COCP/M4CO 16 - 9 -

  10. Globality from a Semantic Point of View Some constraints cannot be defined by a conjunction of primitive constraints without introducing more variables: Reification Global Example ( count ([ x 1 , . . . , x n ] , v , ≥ , ℓ ) ) Constraints linear At least ℓ variables of [ x 1 , . . . , x n ] take the constant value v : channel n element � ( ∀ i ∈ 1 .. n : b i ⇔ x i = v ) & b i ≥ ℓ extensional distinct i = 1 Na¨ ıve DC Propagator Some constraints can be defined by a conjunction of Efficient DC Propagator Efficient BC primitive constraints without introducing more variables: Propagator Example ( distinct ([ x 1 , . . . , x n ]) ) ∀ i , j ∈ 1 .. n where i < j : x i � = x j COCP/M4CO 16 - 10 -

  11. Globality from a Propagation Point of View Reification Some constraints can be defined by a conjunction of Global Constraints primitive constraints, but it leads to weak propagation: linear Example channel element Consider the store { x 1 , x 2 , x 3 �→ { 4 , 5 }} : extensional Upon distinct ([ x 1 , x 2 , x 3 ]) : distinct Na¨ ıve DC Propagation fails under domain or bounds consistency. Propagator Efficient DC Propagator Upon x 1 � = x 2 & x 1 � = x 3 & x 2 � = x 3 : Efficient BC Propagator Propagation succeeds, and it is only search that fails. COCP/M4CO 16 - 11 -

  12. Globality from a Propagation Point of View Some constraints can be defined by a conjunction of Reification primitive constraints, with strong propagation, but it leads Global Constraints to propagation with poor time or memory performance: linear Example channel element Upon strictly_increasing([a,b,c,d,a]) , extensional which is rel([a,b,c,d,a],IRT LE) ) in Gecode: distinct Propagation fails. Na¨ ıve DC Propagator Efficient DC Upon a < b & b < c & c < d & d < a : Propagator Efficient BC Propagation also fails, but the runtime complexity Propagator depends on the sizes of the domains, rather than on the number of variables. COCP/M4CO 16 - 12 -

  13. Outline 1. Reification Reification 2. Global Constraints Global Constraints 3. linear linear channel 4. channel element extensional 5. element distinct Na¨ ıve DC 6. extensional Propagator Efficient DC Propagator Efficient BC 7. distinct Propagator Na¨ ıve DC Propagator Efficient DC Propagator Efficient BC Propagator COCP/M4CO 16 - 13 -

  14. The linear Predicate Definition Reification A linear ([ a 1 , . . . , a n ] , [ x 1 , . . . , x n ] , R , d ) constraint, with Global Constraints [ a 1 , . . . , a n ] a sequence of non-zero integer constants, linear [ x 1 , . . . , x n ] a sequence of integer variables, channel R in { <, ≤ , = , � = , ≥ , > } , and element extensional d an integer constant, � n � distinct Na¨ ıve DC � Propagator holds iff the linear relation a i · x i R d holds. Efficient DC Propagator i = 1 Efficient BC Propagator We now show how to enforce bounds consistency cheaply on linear equality. For simplicity of notation, we pick n = 2, giving a 1 · x 1 + a 2 · x 2 = d , and rename into a · x + b · y = d . COCP/M4CO 16 - 14 -

  15. BC propagator for a binary linear equality: Rewrite for x (the handling of y is analogous and omitted): a · x + b · y = d ⇔ x = ( d − b · y ) / a Reification Upper bound on x , starting from store s : Global   Constraints     linear x ≤  max { ( d − b · n ) / a | n ∈ s ( y ) }  channel � �� � M element extensional and (analogously, hence further details are omitted): distinct Na¨ ıve DC Propagator x ≥ ⌈ min { ( d − b · n ) / a | n ∈ s ( y ) }⌉ Efficient DC Propagator Efficient BC Propagator Computing M : � max { ( d − b · n ) | n ∈ s ( y ) } / a if a > 0 M = min { ( d − b · n ) | n ∈ s ( y ) } / a if a < 0 COCP/M4CO 16 - 15 -

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend