range.icc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 namespace Gecode { namespace Int { namespace Dom {
00023
00024 template <class View>
00025 forceinline
00026 ReRange<View>::ReRange(Space* home, View x, int min0, int max0, BoolView b)
00027 : ReUnaryPropagator<View,PC_INT_BND,BoolView>(home,x,b),
00028 min(min0), max(max0) {}
00029
00030 template <class View>
00031 ExecStatus
00032 ReRange<View>::post(Space* home, View x, int min, int max, BoolView b) {
00033 if (min > max)
00034 return ES_FAILED;
00035 if ((max < x.min()) || (min > x.max())) {
00036 GECODE_ME_CHECK(b.t_zero(home));
00037 } else if ((min <= x.min()) && (x.max() <= max)) {
00038 GECODE_ME_CHECK(b.t_one(home));
00039 } else {
00040 (void) new (home) ReRange<View>(home,x,min,max,b);
00041 }
00042 return ES_OK;
00043 }
00044
00045
00046 template <class View>
00047 forceinline
00048 ReRange<View>::ReRange(Space* home, bool share, ReRange& p)
00049 : ReUnaryPropagator<View,PC_INT_BND,BoolView>(home,share,p),
00050 min(p.min), max(p.max) {}
00051
00052 template <class View>
00053 Actor*
00054 ReRange<View>::copy(Space* home, bool share) {
00055 return new (home) ReRange<View>(home,share,*this);
00056 }
00057
00058
00059 template <class View>
00060 ExecStatus
00061 ReRange<View>::propagate(Space* home) {
00062 if (b.one()) {
00063 GECODE_ME_CHECK(x0.gq(home,min));
00064 GECODE_ME_CHECK(x0.lq(home,max));
00065 return ES_SUBSUMED;
00066 }
00067 if (b.zero()) {
00068 Iter::Ranges::Singleton r(min,max);
00069 GECODE_ME_CHECK(x0.minus(home,r));
00070 return ES_SUBSUMED;
00071 }
00072 if ((x0.max() <= max) && (x0.min() >= min)) {
00073 b.t_one_none(home); return ES_SUBSUMED;
00074 }
00075 if ((x0.max() < min) || (x0.min() > max)) {
00076 b.t_zero_none(home); return ES_SUBSUMED;
00077 }
00078 return ES_FIX;
00079 }
00080
00081
00082 }}}
00083
00084
00085