00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 namespace Gecode { namespace Int { namespace Rel {
00025
00026
00027
00028
00029
00030
00031 template <class View>
00032 forceinline
00033 Lq<View>::Lq(Space* home, View x0, View x1)
00034 : BinaryPropagator<View,PC_INT_BND>(home,x0,x1) {}
00035
00036 template <class View>
00037 ExecStatus
00038 Lq<View>::post(Space* home, View x0, View x1) {
00039 GECODE_ME_CHECK(x0.lq(home,x1.max()));
00040 GECODE_ME_CHECK(x1.gq(home,x0.min()));
00041 if (!same(x0,x1) && (x0.max() > x1.min()))
00042 (void) new (home) Lq<View>(home,x0,x1);
00043 return ES_OK;
00044 }
00045
00046 template <class View>
00047 forceinline
00048 Lq<View>::Lq(Space* home, bool share, Lq<View>& p)
00049 : BinaryPropagator<View,PC_INT_BND>(home,share,p) {}
00050
00051 template <class View>
00052 Actor*
00053 Lq<View>::copy(Space* home, bool share) {
00054 return new (home) Lq<View>(home,share,*this);
00055 }
00056
00057 template <class View>
00058 ExecStatus
00059 Lq<View>::propagate(Space* home) {
00060 GECODE_ME_CHECK(x0.lq(home,x1.max()));
00061 GECODE_ME_CHECK(x1.gq(home,x0.min()));
00062 return (x0.max() <= x1.min()) ? ES_SUBSUMED : ES_FIX;
00063 }
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 template <class View>
00074 forceinline
00075 Le<View>::Le(Space* home, View x0, View x1)
00076 : BinaryPropagator<View,PC_INT_BND>(home,x0,x1) {}
00077
00078 template <class View>
00079 ExecStatus
00080 Le<View>::post(Space* home, View x0, View x1) {
00081 if (same(x0,x1))
00082 return ES_FAILED;
00083 GECODE_ME_CHECK(x0.le(home,x1.max()));
00084 GECODE_ME_CHECK(x1.gr(home,x0.min()));
00085 if (x0.max() >= x1.min())
00086 (void) new (home) Le<View>(home,x0,x1);
00087 return ES_OK;
00088 }
00089
00090 template <class View>
00091 forceinline
00092 Le<View>::Le(Space* home, bool share, Le<View>& p)
00093 : BinaryPropagator<View,PC_INT_BND>(home,share,p) {}
00094
00095 template <class View>
00096 Actor*
00097 Le<View>::copy(Space* home, bool share) {
00098 return new (home) Le<View>(home,share,*this);
00099 }
00100
00101 template <class View>
00102 ExecStatus
00103 Le<View>::propagate(Space* home) {
00104 GECODE_ME_CHECK(x0.le(home,x1.max()));
00105 GECODE_ME_CHECK(x1.gr(home,x0.min()));
00106 return (x0.max() < x1.min()) ? ES_SUBSUMED : ES_FIX;
00107 }
00108
00109
00110
00111
00112
00113
00114
00115 template <class View, class CtrlView>
00116 forceinline
00117 ReLq<View,CtrlView>::ReLq(Space* home, View x0, View x1, CtrlView b)
00118 : ReBinaryPropagator<View,PC_INT_BND,CtrlView>(home,x0,x1,b) {}
00119
00120 template <class View, class CtrlView>
00121 ExecStatus
00122 ReLq<View,CtrlView>::post(Space* home, View x0, View x1, CtrlView b) {
00123 if (b.one())
00124 return Lq<View>::post(home,x0,x1);
00125 if (b.zero())
00126 return Le<View>::post(home,x1,x0);
00127 if (!same(x0,x1)) {
00128 switch (rtest_lq(x0,x1)) {
00129 case RT_TRUE: b.t_one_none(home); break;
00130 case RT_FALSE: b.t_zero_none(home); break;
00131 case RT_MAYBE:
00132 (void) new (home) ReLq<View,CtrlView>(home,x0,x1,b);
00133 }
00134 } else {
00135 b.t_one_none(home);
00136 }
00137 return ES_OK;
00138 }
00139
00140 template <class View, class CtrlView>
00141 forceinline
00142 ReLq<View,CtrlView>::ReLq(Space* home, bool share, ReLq& p)
00143 : ReBinaryPropagator<View,PC_INT_BND,CtrlView>(home,share,p) {}
00144
00145 template <class View, class CtrlView>
00146 Actor*
00147 ReLq<View,CtrlView>::copy(Space* home, bool share) {
00148 return new (home) ReLq<View,CtrlView>(home,share,*this);
00149 }
00150
00151 template <class View, class CtrlView>
00152 ExecStatus
00153 ReLq<View,CtrlView>::propagate(Space* home) {
00154 if (b.one()) {
00155 if (Lq<View>::post(home,x0,x1) == ES_FAILED)
00156 return ES_FAILED;
00157 return ES_SUBSUMED;
00158 }
00159 if (b.zero()) {
00160 if (Le<View>::post(home,x1,x0) == ES_FAILED)
00161 return ES_FAILED;
00162 return ES_SUBSUMED;
00163 }
00164 switch (rtest_lq(x0,x1)) {
00165 case RT_TRUE:
00166 b.t_one_none(home); return ES_SUBSUMED;
00167 case RT_FALSE:
00168 b.t_zero_none(home); return ES_SUBSUMED;
00169 case RT_MAYBE:
00170 ;
00171 }
00172 return ES_FIX;
00173 }
00174
00175
00176
00177
00178
00179
00180 template <class View, class CtrlView>
00181 forceinline
00182 ReLqInt<View,CtrlView>::ReLqInt(Space* home, View x, int c0, CtrlView b)
00183 : ReUnaryPropagator<View,PC_INT_BND,CtrlView>(home,x,b), c(c0) {}
00184
00185 template <class View, class CtrlView>
00186 ExecStatus
00187 ReLqInt<View,CtrlView>::post(Space* home, View x, int c, CtrlView b) {
00188 if (b.one()) {
00189 GECODE_ME_CHECK(x.lq(home,c));
00190 } else if (b.zero()) {
00191 GECODE_ME_CHECK(x.gr(home,c));
00192 } else {
00193 switch (rtest_lq(x,c)) {
00194 case RT_TRUE: b.t_one_none(home); break;
00195 case RT_FALSE: b.t_zero_none(home); break;
00196 case RT_MAYBE:
00197 (void) new (home) ReLqInt<View,CtrlView>(home,x,c,b);
00198 }
00199 }
00200 return ES_OK;
00201 }
00202
00203
00204 template <class View, class CtrlView>
00205 forceinline
00206 ReLqInt<View,CtrlView>::ReLqInt(Space* home, bool share, ReLqInt& p)
00207 : ReUnaryPropagator<View,PC_INT_BND,CtrlView>(home,share,p), c(p.c) {}
00208
00209 template <class View, class CtrlView>
00210 Actor*
00211 ReLqInt<View,CtrlView>::copy(Space* home, bool share) {
00212 return new (home) ReLqInt<View,CtrlView>(home,share,*this);
00213 }
00214
00215 template <class View, class CtrlView>
00216 ExecStatus
00217 ReLqInt<View,CtrlView>::propagate(Space* home) {
00218 if (b.one()) {
00219 GECODE_ME_CHECK(x0.lq(home,c)); return ES_SUBSUMED;
00220 }
00221 if (b.zero()) {
00222 GECODE_ME_CHECK(x0.gr(home,c)); return ES_SUBSUMED;
00223 }
00224 switch (rtest_lq(x0,c)) {
00225 case RT_TRUE:
00226 b.t_one_none(home); return ES_SUBSUMED;
00227 case RT_FALSE:
00228 b.t_zero_none(home); return ES_SUBSUMED;
00229 case RT_MAYBE:
00230 ;
00231 }
00232 return ES_FIX;
00233 }
00234
00235 }}}
00236
00237
00238