00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 namespace Gecode { namespace Set { namespace Rel {
00041
00042 template<class View0, class View1>
00043 forceinline
00044 ReSubset<View0,View1>::ReSubset(Home home, View0 y0,
00045 View1 y1, Gecode::Int::BoolView y2)
00046 : Propagator(home), x0(y0), x1(y1), b(y2) {
00047 b.subscribe(home,*this, Gecode::Int::PC_INT_VAL);
00048 x0.subscribe(home,*this, PC_SET_ANY);
00049 x1.subscribe(home,*this, PC_SET_ANY);
00050 }
00051
00052 template<class View0, class View1>
00053 forceinline
00054 ReSubset<View0,View1>::ReSubset(Space& home, bool share, ReSubset& p)
00055 : Propagator(home,share,p) {
00056 x0.update(home,share,p.x0);
00057 x1.update(home,share,p.x1);
00058 b.update(home,share,p.b);
00059 }
00060
00061 template<class View0, class View1>
00062 PropCost
00063 ReSubset<View0,View1>::cost(const Space&, const ModEventDelta&) const {
00064 return PropCost::ternary(PropCost::LO);
00065 }
00066
00067 template<class View0, class View1>
00068 forceinline size_t
00069 ReSubset<View0,View1>::dispose(Space& home) {
00070 b.cancel(home,*this, Gecode::Int::PC_INT_VAL);
00071 x0.cancel(home,*this, PC_SET_ANY);
00072 x1.cancel(home,*this, PC_SET_ANY);
00073 (void) Propagator::dispose(home);
00074 return sizeof(*this);
00075 }
00076
00077 template<class View0, class View1>
00078 ExecStatus
00079 ReSubset<View0,View1>::post(Home home, View0 x0, View1 x1,
00080 Gecode::Int::BoolView b) {
00081 (void) new (home) ReSubset<View0,View1>(home,x0,x1,b);
00082 return ES_OK;
00083 }
00084
00085 template<class View0, class View1>
00086 Actor*
00087 ReSubset<View0,View1>::copy(Space& home, bool share) {
00088 return new (home) ReSubset<View0,View1>(home,share,*this);
00089 }
00090
00091 template<class View0, class View1>
00092 ExecStatus
00093 ReSubset<View0,View1>::propagate(Space& home, const ModEventDelta&) {
00094 if (b.one())
00095 GECODE_REWRITE(*this,(Subset<View0,View1>::post(home(*this),x0,x1)));
00096 if (b.zero())
00097 GECODE_REWRITE(*this,(NoSubset<View0,View1>::post(home(*this),x0,x1)));
00098
00099
00100 if (x0.cardMin() > x1.cardMax()) {
00101 GECODE_ME_CHECK(b.zero_none(home));
00102 return home.ES_SUBSUMED(*this);
00103 }
00104
00105
00106 {
00107 LubRanges<View0> x0ub(x0);
00108 GlbRanges<View1> x1lb(x1);
00109 Iter::Ranges::Diff<LubRanges<View0>,GlbRanges<View1> > d(x0ub,x1lb);
00110 if (!d()) {
00111 GECODE_ME_CHECK(b.one_none(home));
00112 return home.ES_SUBSUMED(*this);
00113 }
00114 }
00115
00116
00117 {
00118 GlbRanges<View0> x0lb(x0);
00119 LubRanges<View1> x1ub(x1);
00120 Iter::Ranges::Diff<GlbRanges<View0>,LubRanges<View1> > d(x0lb,x1ub);
00121 if (d()) {
00122 GECODE_ME_CHECK(b.zero_none(home));
00123 return home.ES_SUBSUMED(*this);
00124 } else if (x0.assigned() && x1.assigned()) {
00125 GECODE_ME_CHECK(b.one_none(home));
00126 return home.ES_SUBSUMED(*this);
00127 }
00128 }
00129
00130 if (x0.cardMin() > 0) {
00131 LubRanges<View0> x0ub(x0);
00132 LubRanges<View1> x1ub(x1);
00133 Iter::Ranges::Inter<LubRanges<View0>,LubRanges<View1> >
00134 i(x0ub,x1ub);
00135 if (!i()) {
00136 GECODE_ME_CHECK(b.zero_none(home));
00137 return home.ES_SUBSUMED(*this);
00138 }
00139 }
00140
00141 return ES_FIX;
00142 }
00143
00144 }}}
00145
00146