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 namespace Gecode { namespace Int { namespace Dom {
00035
00036 template<class View, ReifyMode rm>
00037 forceinline
00038 ReIntSet<View,rm>::ReIntSet
00039 (Home home, View x, const IntSet& s, BoolView b)
00040 : ReUnaryPropagator<View,PC_INT_DOM,BoolView>(home,x,b), is(s) {
00041 home.notice(*this,AP_DISPOSE);
00042 }
00043
00044 template<class View, ReifyMode rm>
00045 forceinline size_t
00046 ReIntSet<View,rm>::dispose(Space& home) {
00047 home.ignore(*this,AP_DISPOSE);
00048 is.~IntSet();
00049 (void) ReUnaryPropagator<View,PC_INT_DOM,BoolView>::dispose(home);
00050 return sizeof(*this);
00051 }
00052
00053 template<class View, ReifyMode rm>
00054 ExecStatus
00055 ReIntSet<View,rm>::post(Home home, View x, const IntSet& s, BoolView b) {
00056 if (s.ranges() == 0) {
00057 if (rm == RM_PMI)
00058 return ES_OK;
00059 GECODE_ME_CHECK(b.zero(home));
00060 } else if (s.ranges() == 1) {
00061 return ReRange<View,rm>::post(home,x,s.min(),s.max(),b);
00062 } else if (b.one()) {
00063 if (rm == RM_PMI)
00064 return ES_OK;
00065 IntSetRanges i_is(s);
00066 GECODE_ME_CHECK(x.inter_r(home,i_is,false));
00067 } else if (b.zero()) {
00068 if (rm == RM_IMP)
00069 return ES_OK;
00070 IntSetRanges i_is(s);
00071 GECODE_ME_CHECK(x.minus_r(home,i_is,false));
00072 } else {
00073 (void) new (home) ReIntSet<View,rm>(home,x,s,b);
00074 }
00075 return ES_OK;
00076 }
00077
00078
00079 template<class View, ReifyMode rm>
00080 forceinline
00081 ReIntSet<View,rm>::ReIntSet(Space& home, ReIntSet& p)
00082 : ReUnaryPropagator<View,PC_INT_DOM,BoolView>(home,p), is(p.is) {
00083 }
00084
00085 template<class View, ReifyMode rm>
00086 Actor*
00087 ReIntSet<View,rm>::copy(Space& home) {
00088 return new (home) ReIntSet(home,*this);
00089 }
00090
00091 template<class View, ReifyMode rm>
00092 ExecStatus
00093 ReIntSet<View,rm>::propagate(Space& home, const ModEventDelta&) {
00094 IntSetRanges i_is(is);
00095 if (b.one()) {
00096 if (rm != RM_PMI)
00097 GECODE_ME_CHECK(x0.inter_r(home,i_is,false));
00098 return home.ES_SUBSUMED(*this);
00099 }
00100 if (b.zero()) {
00101 if (rm != RM_IMP)
00102 GECODE_ME_CHECK(x0.minus_r(home,i_is,false));
00103 return home.ES_SUBSUMED(*this);
00104 }
00105
00106 {
00107 ViewRanges<View> i_x(x0);
00108
00109 switch (Iter::Ranges::compare(i_x,i_is)) {
00110 case Iter::Ranges::CS_SUBSET:
00111 if (rm != RM_IMP)
00112 GECODE_ME_CHECK(b.one_none(home));
00113 return home.ES_SUBSUMED(*this);
00114 case Iter::Ranges::CS_DISJOINT:
00115 if (rm != RM_PMI)
00116 GECODE_ME_CHECK(b.zero_none(home));
00117 return home.ES_SUBSUMED(*this);
00118 case Iter::Ranges::CS_NONE:
00119 break;
00120 default: GECODE_NEVER;
00121 }
00122 }
00123 return ES_FIX;
00124 }
00125
00126 }}}
00127
00128
00129