half reification and flattening
play

Half Reification and Flattening Thibaut Feydy Peter Stuckey Zoltan - PowerPoint PPT Presentation

Half Reification and Flattening Thibaut Feydy Peter Stuckey Zoltan Somogyi NICTA Members NICTA Partners www.nicta.com.au From imagination to impact Flattening 1 Implementing half reification 2 Results 3 Conclusions 4 2/25 Motivation


  1. Half Reification and Flattening Thibaut Feydy Peter Stuckey Zoltan Somogyi NICTA Members NICTA Partners www.nicta.com.au From imagination to impact

  2. Flattening 1 Implementing half reification 2 Results 3 Conclusions 4 2/25

  3. Motivation Complex integer and Booleans expressions arise in CP models, CP Solvers handle primitive relations (propagators) Reification and Flattening are the techniques used in CP solvers to handle complex expressions But reification is often overkill ! Reification is not available for many constraints 3/25

  4. Flattening 1 Implementing half reification 2 Results 3 Conclusions 4 4/25

  5. Flattening of complex expressions Models : complex expressions, (partial) functions, nesting. Solvers : primitive constraints implementation (propagators) ⇒ flat relations. ⇒ Complex models are flattened in conjunction of primitives constraints. � x ∗ y = xy x ∗ y + 2 z = 0 ≡ xy + 2 z = 0 5/25

  6. Reification A reified constraint b ↔ c associates a thruth value b with a constraint c .  b 1 ↔ x + 2 < y  x + 2 < y ∨ y + 4 < x ≡ b 2 ↔ y + 4 < x b 1 ∨ b 2   bool 2 int ( b , i )  bool 2 int ( x = y ) < z ≡ i < z b ↔ x = y  Reified constraints available for common primitives. Missing for most globals. 6/25

  7. Flattening and partial functions x = a [ i ] ≡ element ( i , a , x ) array access is a partial function: a = [ 5 , 7 , 2 ] , i ∈ [ − 3 , 7 ] partial functions need to be made safe in reified context:  b ∨ b 1   b 1 ↔ ( b 2 ∧ b 3 )     b 2 ↔ i = i 1  b ∨ x = a [ i ] ≡ b 2 ↔ i ∈ 1 .. 3   b 3 ↔ x = x 1      element ( i 1 , a , x 1 ) 7/25

  8. Half Reification The half reification of a constraint c is the constraint b → c . Convention: always use → direction: b ← c ≡ ¬ b → ¬ c In many case, flattening can be modified to generate half reified constraints. b is the Boolean context of c : positive : b → c negative : b ← c ≡ ¬ b → ¬ c reified 8/25

  9. Flattening with half reified constraints  b 1 ↔ x + 2 < y  x + 2 < y ∨ y + 4 < x ≡ b 2 ↔ y + 4 < x b 1 ∨ b 2  Half reification:  b 1 → x + 2 < y  x + 2 < y ∨ y + 4 < x ≡ b 2 → y + 4 < x b 1 ∨ b 2  9/25

  10. Flattening with half reified constraints  bool 2 int ( b , i )  bool 2 int ( x = y ) < z ≡ i < z b ↔ x = y  Half reification:  bool 2 int ( b , i )  bool 2 int ( x = y ) < z ≡ i < z ¬ b → x � = y  10/25

  11. The relational semantic for free  b ∨ b 1   b 1 ↔ ( b 2 ∧ b 3 )     b 2 ↔ i = i 1  b ∨ x = a [ i ] ≡ b 2 ↔ i ∈ 1 .. 3   b 3 ↔ x = x 1     element ( i 1 , a , x 1 )  Half reification: � b ∨ b 1 b ∨ x = a [ i ] ≡ b 1 → element ( i , a , x ) 11/25

  12. Full reification as decomposition � b → c b ↔ c ≡ ¬ b → ¬ c No Loss of Propagation! Informally : If b unfixed, both propagates when c or ¬ c is infered. If b fixed, both propagates c or ¬ c . 12/25

  13. Flattening 1 Implementing half reification 2 Results 3 Conclusions 4 13/25

  14. Propagators implementation A propagator prop c for a constraint c is defined by: solved c : DOM → { true , false } . unsat c : DOM → { true , false } . prune c : DOM → DOM ′ ⊆ DOM . events c : a set of events which wakes up the propagator. if solved c ( DOM ) : kill prop c . if unsat c ( DOM ) : fails. prune c ( DOM ) . 14/25

  15. Generic reification implementation prop b ↔ c ( DOM ) : if b = true : prop ( c , DOM ) if b = false : prop ¬ c ( DOM ) if b = undecided : if unsat c ( DOM ) : b := false , kill prop b ↔ c . if unsat ¬ c ( DOM ) : b := true , kill prop b ↔ c events b ↔ c = events c ∪ events ¬ c ∪ fix ( b ) ⇒ works if primitive is negatable (negated primitive exists) ⇒ most global constraints cannot be negated 15/25

  16. Generic half reification implementation prop b → c ( DOM ) : if b = true : prop c ( DOM ) if b = false : kill prop b → c if b = unknown : if unsat c ( DOM ) : b := false , kill prop b → c if solved c ( DOM ) : kill prop b → c . events b → c = events c ∪ fix ( b ) 16/25

  17. Reified vs Half Reified constraints: Example Linear disequality : � a i x i � = c Wakes up on � fix ( x i ) . At most 1 wake-up per variable down a branch. Reified equality : � ¬ b ↔ a i x i = c Wakes up on fix ( b ) ∪ � bnd ( x i ) . Half reified disequality : � b → a i x i � = c Wakes up on { fix ( b ) } ∪ � fix ( x i ) . At most 1 wake-up per variable down a branch. 17/25

  18. Reified vs Half Reified constraints: Example Linear disequality : � a i x i � = c Linear cost down a branch Reified equality : � ¬ b ↔ a i x i = c Linear cost per propagation Half reified disequality : � b → a i x i � = c Linear cost down a branch. 17/25

  19. All functionalities required are part of a non-reified propagator, Same events that the non reified propagator (plus the context Boolean), If b = true , same as non-reified propagator. No overhead if templates/partial evaluation Works for global constraints ! 18/25

  20. Revised Flattening Observation : the propagator for l → c can be killed as soon as l is false. ⇒ Add additional constraints to fix introduced Booleans earlier.  b ∨ b 1 ∨ b 2   b 1 → c 1    b ∨ c 1 ∨ c 2 ≡ b 2 → c 2 ¬ b ∨ ¬ b 1     ¬ b ∨ ¬ b 2  � b 1 → c 1 c 1 ∨ c 2 ≡ ¬ b 1 → c 2 19/25

  21. Flattening 1 Implementing half reification 2 Results 3 Conclusions 4 20/25

  22. Results QCP Max Quasi Group Completion with soft all-different half and full use decomposition, half-g uses global alldifferent FD, FD + Explanations : same solver with/without lazy clause generation FD FD + Explanations Inst. full half half-g full half half-g qm10 20 14 20 14 20 14 0 15 0 15 0 15 qm15 205 6 180 7 174 7 2 15 1 15 1 15 qm20 300 0 289 1 286 1 116 11 127 10 114 10 Table: Avg. times in seconds / Solved instances, 300s timeouts 21/25

  23. Results Prize collecting paths Collect prizes along a path, maximizing total profit, Each node visited at most once, partial element constraints, ext uses a modified model to avoid partiality : extended arrays. FD FD + Explanations full half ext full half ext 18 2 10 1 10 1 10 1 10 0 10 0 10 20 5 10 4 10 4 10 1 10 1 10 1 10 24 46 10 34 10 40 10 7 10 5 10 6 10 25 66 10 51 10 57 10 10 10 7 10 8 10 28 255 5 214 8 241 6 38 10 23 10 35 10 30 286 1 281 2 284 1 100 10 61 10 92 10 32 300 0 297 1 300 0 230 5 164 10 215 8 Table: Avg. times in seconds / Solved instances, 300s timeouts 22/25

  24. Results Resource Constrained Project Scheduling Problem (RCPSP) cumulative constraint time decomposition linear inequality over Boolean expressions half reified difference logic � i ∈ tasks bool 2 int ( start i < = t ∧ t < start i + d i ) ∗ r i < = rc FD FD + Explanations Instances full half full half BL x40 277.2 5 269.3 5 17.1 39 15.4 39 J30 x480 116.1 300 114.3 304 16.9 463 12.9 468 Table: Avg. times in seconds / Solved instances, 300s timeouts 23/25

  25. Flattening 1 Implementing half reification 2 Results 3 Conclusions 4 24/25

  26. Conclusions Simple ! Given a constraint implementation, half reification for free, Implements relational semantic, ⇒ easier flattening, faster propagation Less expensive to propagate that full reification, Allows using global constraints in positive context ⇒ soft global constraints Fully reified propagators mostly unnecessary. ⇒ less code to write and maintain 25/25

  27. Conclusions Simple ! Given a constraint implementation, half reification for free, Implements relational semantic, ⇒ easier flattening, faster propagation Less expensive to propagate that full reification, Allows using global constraints in positive context ⇒ soft global constraints Fully reified propagators mostly unnecessary. ⇒ less code to write and maintain Thank you. 25/25

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