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, ReifyMode rm>
00043 forceinline
00044 ReSubset<View0,View1,rm>::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, ReifyMode rm>
00053 forceinline
00054 ReSubset<View0,View1,rm>::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, ReifyMode rm>
00062 PropCost
00063 ReSubset<View0,View1,rm>::cost(const Space&, const ModEventDelta&) const {
00064 return PropCost::ternary(PropCost::LO);
00065 }
00066
00067 template<class View0, class View1, ReifyMode rm>
00068 forceinline size_t
00069 ReSubset<View0,View1,rm>::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, ReifyMode rm>
00078 ExecStatus
00079 ReSubset<View0,View1,rm>::post(Home home, View0 x0, View1 x1,
00080 Gecode::Int::BoolView b) {
00081 (void) new (home) ReSubset<View0,View1,rm>(home,x0,x1,b);
00082 return ES_OK;
00083 }
00084
00085 template<class View0, class View1, ReifyMode rm>
00086 Actor*
00087 ReSubset<View0,View1,rm>::copy(Space& home, bool share) {
00088 return new (home) ReSubset<View0,View1,rm>(home,share,*this);
00089 }
00090
00091 template<class View0, class View1, ReifyMode rm>
00092 ExecStatus
00093 ReSubset<View0,View1,rm>::propagate(Space& home, const ModEventDelta&) {
00094 if (b.one()) {
00095 if (rm == RM_PMI)
00096 return home.ES_SUBSUMED(*this);
00097 GECODE_REWRITE(*this,(Subset<View0,View1>::post(home(*this),x0,x1)));
00098 }
00099 if (b.zero()) {
00100 if (rm == RM_IMP)
00101 return home.ES_SUBSUMED(*this);
00102 GECODE_REWRITE(*this,(NoSubset<View0,View1>::post(home(*this),x0,x1)));
00103 }
00104
00105
00106 if (x0.cardMin() > x1.cardMax()) {
00107 if (rm != RM_PMI)
00108 GECODE_ME_CHECK(b.zero_none(home));
00109 return home.ES_SUBSUMED(*this);
00110 }
00111
00112
00113 {
00114 LubRanges<View0> x0ub(x0);
00115 GlbRanges<View1> x1lb(x1);
00116 Iter::Ranges::Diff<LubRanges<View0>,GlbRanges<View1> > d(x0ub,x1lb);
00117 if (!d()) {
00118 if (rm != RM_IMP)
00119 GECODE_ME_CHECK(b.one_none(home));
00120 return home.ES_SUBSUMED(*this);
00121 }
00122 }
00123
00124
00125 {
00126 GlbRanges<View0> x0lb(x0);
00127 LubRanges<View1> x1ub(x1);
00128 Iter::Ranges::Diff<GlbRanges<View0>,LubRanges<View1> > d(x0lb,x1ub);
00129 if (d()) {
00130 if (rm != RM_PMI)
00131 GECODE_ME_CHECK(b.zero_none(home));
00132 return home.ES_SUBSUMED(*this);
00133 } else if (x0.assigned() && x1.assigned()) {
00134 if (rm != RM_IMP)
00135 GECODE_ME_CHECK(b.one_none(home));
00136 return home.ES_SUBSUMED(*this);
00137 }
00138 }
00139
00140 if (x0.cardMin() > 0) {
00141 LubRanges<View0> x0ub(x0);
00142 LubRanges<View1> x1ub(x1);
00143 Iter::Ranges::Inter<LubRanges<View0>,LubRanges<View1> >
00144 i(x0ub,x1ub);
00145 if (!i()) {
00146 if (rm != RM_PMI)
00147 GECODE_ME_CHECK(b.zero_none(home));
00148 return home.ES_SUBSUMED(*this);
00149 }
00150 }
00151
00152 return ES_FIX;
00153 }
00154
00155 }}}
00156
00157