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 size_t
00069 ReSubset<View0,View1>::dispose(Space& home) {
00070 assert(!home.failed());
00071 b.cancel(home,*this, Gecode::Int::PC_INT_VAL);
00072 x0.cancel(home,*this, PC_SET_ANY);
00073 x1.cancel(home,*this, PC_SET_ANY);
00074 (void) Propagator::dispose(home);
00075 return sizeof(*this);
00076 }
00077
00078 template<class View0, class View1>
00079 ExecStatus
00080 ReSubset<View0,View1>::post(Home home, View0 x0, View1 x1,
00081 Gecode::Int::BoolView b) {
00082 (void) new (home) ReSubset<View0,View1>(home,x0,x1,b);
00083 return ES_OK;
00084 }
00085
00086 template<class View0, class View1>
00087 Actor*
00088 ReSubset<View0,View1>::copy(Space& home, bool share) {
00089 return new (home) ReSubset<View0,View1>(home,share,*this);
00090 }
00091
00092 template<class View0, class View1>
00093 ExecStatus
00094 ReSubset<View0,View1>::propagate(Space& home, const ModEventDelta&) {
00095 if (b.one())
00096 GECODE_REWRITE(*this,(Subset<View0,View1>::post(home(*this),x0,x1)));
00097 if (b.zero())
00098 GECODE_REWRITE(*this,(NoSubset<View0,View1>::post(home(*this),x0,x1)));
00099
00100
00101 if (x0.cardMin() > x1.cardMax()) {
00102 GECODE_ME_CHECK(b.zero_none(home));
00103 return ES_SUBSUMED(*this,home);
00104 }
00105
00106
00107 {
00108 LubRanges<View0> x0ub(x0);
00109 GlbRanges<View1> x1lb(x1);
00110 Iter::Ranges::Diff<LubRanges<View0>,GlbRanges<View1> > d(x0ub,x1lb);
00111 if (!d()) {
00112 GECODE_ME_CHECK(b.one_none(home));
00113 return ES_SUBSUMED(*this,home);
00114 }
00115 }
00116
00117
00118 {
00119 GlbRanges<View0> x0lb(x0);
00120 LubRanges<View1> x1ub(x1);
00121 Iter::Ranges::Diff<GlbRanges<View0>,LubRanges<View1> > d(x0lb,x1ub);
00122 if (d()) {
00123 GECODE_ME_CHECK(b.zero_none(home));
00124 return ES_SUBSUMED(*this,home);
00125 } else if (x0.assigned() && x1.assigned()) {
00126 GECODE_ME_CHECK(b.one_none(home));
00127 return ES_SUBSUMED(*this,home);
00128 }
00129 }
00130
00131 if (x0.cardMin() > 0) {
00132 LubRanges<View0> x0ub(x0);
00133 LubRanges<View1> x1ub(x1);
00134 Iter::Ranges::Inter<LubRanges<View0>,LubRanges<View1> >
00135 i(x0ub,x1ub);
00136 if (!i()) {
00137 GECODE_ME_CHECK(b.zero_none(home));
00138 return ES_SUBSUMED(*this,home);
00139 }
00140 }
00141
00142 return ES_FIX;
00143 }
00144
00145 }}}
00146
00147