| 39 | |
| 40 | template<class View, template<class View0,class View1> class Eq> |
| 41 | ExecStatus |
| 42 | prop_abs_bnd(Space& home, Propagator& p, View x0, View x1) { |
| 43 | if (x0.assigned()) { |
| 44 | GECODE_ME_CHECK(x1.eq(home,(x0.val() < 0) ? -x0.val() : x0.val())); |
| 45 | return home.ES_SUBSUMED(p); |
| 46 | } |
| 47 | |
| 48 | if (x1.assigned()) { |
| 49 | if (x0.min() >= 0) { |
| 50 | GECODE_ME_CHECK(x0.eq(home,x1.val())); |
| 51 | return home.ES_SUBSUMED(p); |
| 52 | } else if (x0.max() <= 0) { |
| 53 | GECODE_ME_CHECK(x0.eq(home,-x1.val())); |
| 54 | return home.ES_SUBSUMED(p); |
| 55 | } else if (x1.val() == 0) { |
| 56 | GECODE_ME_CHECK(x0.eq(home,0)); |
| 57 | return home.ES_SUBSUMED(p); |
| 58 | } else { |
| 59 | int mp[2] = {-x1.val(),x1.val()}; |
| 60 | Iter::Values::Array i(mp,2); |
| 61 | GECODE_ME_CHECK(x0.inter_v(home,i,false)); |
| 62 | return home.ES_SUBSUMED(p); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | if (x0.min() >= 0) |
| 67 | GECODE_REWRITE(p,(Eq<View,View>::post(home(p),x0,x1))); |
| 68 | |
| 69 | if (x0.max() <= 0) |
| 70 | GECODE_REWRITE(p,(Eq<MinusView,View>::post(home(p),MinusView(x0),x1))); |
| 71 | |
| 72 | |
| 73 | GECODE_ME_CHECK(x1.lq(home,std::max(x0.max(),-x0.min()))); |
| 74 | GECODE_ME_CHECK(x0.gq(home,-x1.max())); |
| 75 | GECODE_ME_CHECK(x0.lq(home,x1.max())); |
| 76 | if (x1.min() > 0) { |
| 77 | if (-x1.min() < x0.min()) { |
| 78 | GECODE_ME_CHECK(x0.gq(home,x1.min())); |
| 79 | } else if (x0.max() < x1.min()) { |
| 80 | GECODE_ME_CHECK(x0.lq(home,-x1.min())); |
| 81 | } |
| 82 | } |
| 83 | return ES_NOFIX; |
| 84 | } |
| 85 | |
| 86 | template<class View> |
| 87 | forceinline |