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
00041
00042 namespace Gecode { namespace Float { namespace Rel {
00043
00044
00045
00046
00047
00048
00049 template<class View>
00050 forceinline
00051 Lq<View>::Lq(Home home, View x0, View x1)
00052 : BinaryPropagator<View,PC_FLOAT_BND>(home,x0,x1) {}
00053
00054 template<class View>
00055 ExecStatus
00056 Lq<View>::post(Home home, View x0, View x1) {
00057 GECODE_ME_CHECK(x0.lq(home,x1.max()));
00058 GECODE_ME_CHECK(x1.gq(home,x0.min()));
00059 if (!same(x0,x1) && (x0.max() > x1.min()))
00060 (void) new (home) Lq<View>(home,x0,x1);
00061 return ES_OK;
00062 }
00063
00064 template<class View>
00065 forceinline
00066 Lq<View>::Lq(Space& home, bool share, Lq<View>& p)
00067 : BinaryPropagator<View,PC_FLOAT_BND>(home,share,p) {}
00068
00069 template<class View>
00070 Actor*
00071 Lq<View>::copy(Space& home, bool share) {
00072 return new (home) Lq<View>(home,share,*this);
00073 }
00074
00075 template<class View>
00076 ExecStatus
00077 Lq<View>::propagate(Space& home, const ModEventDelta&) {
00078 GECODE_ME_CHECK(x0.lq(home,x1.max()));
00079 GECODE_ME_CHECK(x1.gq(home,x0.min()));
00080 return (x0.assigned() || x1.assigned() || (x0.max() <= x1.min())) ? home.ES_SUBSUMED(*this) : ES_FIX;
00081 }
00082
00083
00084
00085
00086
00087
00088 template<class View>
00089 forceinline
00090 Le<View>::Le(Home home, View x0, View x1)
00091 : BinaryPropagator<View,PC_FLOAT_BND>(home,x0,x1) {}
00092
00093 template<class View>
00094 ExecStatus
00095 Le<View>::post(Home home, View x0, View x1) {
00096 GECODE_ME_CHECK(x0.lq(home,x1.max()));
00097 GECODE_ME_CHECK(x1.gq(home,x0.min()));
00098 if (x0.assigned() && x1.assigned()) {
00099 if (x0.max() >= x1.min())
00100 return ES_FAILED;
00101 } else if (same(x0,x1))
00102 return ES_FAILED;
00103 if (x0.max() >= x1.min())
00104 (void) new (home) Le<View>(home,x0,x1);
00105 return ES_OK;
00106 }
00107
00108 template<class View>
00109 forceinline
00110 Le<View>::Le(Space& home, bool share, Le<View>& p)
00111 : BinaryPropagator<View,PC_FLOAT_BND>(home,share,p) {}
00112
00113 template<class View>
00114 Actor*
00115 Le<View>::copy(Space& home, bool share) {
00116 return new (home) Le<View>(home,share,*this);
00117 }
00118
00119 template<class View>
00120 ExecStatus
00121 Le<View>::propagate(Space& home, const ModEventDelta&) {
00122 GECODE_ME_CHECK(x0.lq(home,x1.max()));
00123 GECODE_ME_CHECK(x1.gq(home,x0.min()));
00124 if (x0.assigned() && x1.assigned()) {
00125 return (x0.max() >= x1.min()) ? ES_FAILED : home.ES_SUBSUMED(*this);
00126 }
00127 return (x0.max() < x1.min()) ? home.ES_SUBSUMED(*this) : ES_FIX;
00128 }
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 template<class View, class CtrlView, ReifyMode rm>
00139 forceinline
00140 ReLq<View,CtrlView,rm>::ReLq(Home home, View x0, View x1, CtrlView b)
00141 : Int::ReBinaryPropagator<View,PC_FLOAT_BND,CtrlView>(home,x0,x1,b) {}
00142
00143 template<class View, class CtrlView, ReifyMode rm>
00144 ExecStatus
00145 ReLq<View,CtrlView,rm>::post(Home home, View x0, View x1, CtrlView b) {
00146 if (b.one()) {
00147 if (rm == RM_PMI)
00148 return ES_OK;
00149 return Lq<View>::post(home,x0,x1);
00150 }
00151 if (b.zero()) {
00152 if (rm == RM_IMP)
00153 return ES_OK;
00154 return Le<View>::post(home,x1,x0);
00155 }
00156 if (!same(x0,x1)) {
00157 switch (rtest_lq(x0,x1)) {
00158 case RT_TRUE:
00159 if (rm != RM_IMP)
00160 GECODE_ME_CHECK(b.one_none(home));
00161 break;
00162 case RT_FALSE:
00163 if (rm != RM_PMI)
00164 GECODE_ME_CHECK(b.zero_none(home));
00165 break;
00166 case RT_MAYBE:
00167 if (!x0.assigned() || !x1.assigned())
00168 (void) new (home) ReLq<View,CtrlView,rm>(home,x0,x1,b);
00169 else {
00170 if (rm != RM_IMP)
00171 GECODE_ME_CHECK(b.one_none(home));
00172 }
00173 break;
00174 default: GECODE_NEVER;
00175 }
00176 } else if (rm != RM_IMP) {
00177 GECODE_ME_CHECK(b.one_none(home));
00178 }
00179 return ES_OK;
00180 }
00181
00182 template<class View, class CtrlView, ReifyMode rm>
00183 forceinline
00184 ReLq<View,CtrlView,rm>::ReLq(Space& home, bool share, ReLq& p)
00185 : Int::ReBinaryPropagator<View,PC_FLOAT_BND,CtrlView>(home,share,p) {}
00186
00187 template<class View, class CtrlView, ReifyMode rm>
00188 Actor*
00189 ReLq<View,CtrlView,rm>::copy(Space& home, bool share) {
00190 return new (home) ReLq<View,CtrlView,rm>(home,share,*this);
00191 }
00192
00193 template<class View, class CtrlView, ReifyMode rm>
00194 ExecStatus
00195 ReLq<View,CtrlView,rm>::propagate(Space& home, const ModEventDelta&) {
00196 if (b.one()) {
00197 if (rm != RM_PMI)
00198 GECODE_REWRITE(*this,Lq<View>::post(home(*this),x0,x1));
00199 } else if (b.zero()) {
00200 if (rm != RM_IMP)
00201 GECODE_REWRITE(*this,Le<View>::post(home(*this),x1,x0));
00202 } else {
00203 switch (rtest_lq(x0,x1)) {
00204 case RT_TRUE:
00205 if (rm != RM_IMP)
00206 GECODE_ME_CHECK(b.one_none(home));
00207 break;
00208 case RT_FALSE:
00209 if (rm != RM_PMI)
00210 GECODE_ME_CHECK(b.zero_none(home));
00211 break;
00212 case RT_MAYBE:
00213 if (!x0.assigned() || !x1.assigned())
00214 return ES_FIX;
00215 else {
00216 if (rm != RM_IMP)
00217 GECODE_ME_CHECK(b.one_none(home));
00218 break;
00219 }
00220 default: GECODE_NEVER;
00221 }
00222 }
00223 return home.ES_SUBSUMED(*this);
00224 }
00225
00226
00227
00228
00229
00230
00231 template<class View, class CtrlView, ReifyMode rm>
00232 forceinline
00233 ReLqFloat<View,CtrlView,rm>::ReLqFloat(Home home, View x, FloatVal c0, CtrlView b)
00234 : Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView>(home,x,b), c(c0) {}
00235
00236 template<class View, class CtrlView, ReifyMode rm>
00237 ExecStatus
00238 ReLqFloat<View,CtrlView,rm>::post(Home home, View x, FloatVal c, CtrlView b) {
00239 if (b.one()) {
00240 if (rm != RM_PMI)
00241 GECODE_ME_CHECK(x.lq(home,c.max()));
00242 } if (b.zero()) {
00243 if (rm != RM_IMP) {
00244 GECODE_ME_CHECK(x.gq(home,c.min()));
00245 if (x.assigned() && (x.min() <= c.max()))
00246 return ES_FAILED;
00247 (void) new (home) ReLqFloat<View,CtrlView,rm>(home,x,c,b);
00248 }
00249 } else {
00250 switch (rtest_lq(x,c)) {
00251 case RT_TRUE:
00252 if (rm != RM_IMP)
00253 GECODE_ME_CHECK(b.one(home));
00254 break;
00255 case RT_FALSE:
00256 if (rm != RM_PMI)
00257 GECODE_ME_CHECK(b.zero(home));
00258 break;
00259 case RT_MAYBE:
00260 (void) new (home) ReLqFloat<View,CtrlView,rm>(home,x,c,b);
00261 break;
00262 default: GECODE_NEVER;
00263 }
00264 }
00265 return ES_OK;
00266 }
00267
00268
00269 template<class View, class CtrlView, ReifyMode rm>
00270 forceinline
00271 ReLqFloat<View,CtrlView,rm>::ReLqFloat(Space& home, bool share, ReLqFloat& p)
00272 : Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView>(home,share,p), c(p.c) {}
00273
00274 template<class View, class CtrlView, ReifyMode rm>
00275 Actor*
00276 ReLqFloat<View,CtrlView,rm>::copy(Space& home, bool share) {
00277 return new (home) ReLqFloat<View,CtrlView,rm>(home,share,*this);
00278 }
00279
00280 template<class View, class CtrlView, ReifyMode rm>
00281 ExecStatus
00282 ReLqFloat<View,CtrlView,rm>::propagate(Space& home, const ModEventDelta&) {
00283 if (b.one()) {
00284 if (rm != RM_PMI)
00285 GECODE_ME_CHECK(x0.lq(home,c.max()));
00286 } else if (b.zero()) {
00287 if (rm != RM_IMP)
00288 {
00289 GECODE_ME_CHECK(x0.gq(home,c.min()));
00290 if (x0.assigned()) {
00291 return (x0.min() <= c.max()) ? ES_FAILED : home.ES_SUBSUMED(*this);
00292 }
00293 }
00294 } else {
00295 switch (rtest_lq(x0,c)) {
00296 case RT_TRUE:
00297 if (rm != RM_IMP)
00298 GECODE_ME_CHECK(b.one(home));
00299 break;
00300 case RT_FALSE:
00301 if (rm != RM_PMI)
00302 GECODE_ME_CHECK(b.zero(home));
00303 break;
00304 case RT_MAYBE:
00305 return ES_FIX;
00306 default: GECODE_NEVER;
00307 }
00308 }
00309 return home.ES_SUBSUMED(*this);
00310 }
00311
00312
00313
00314
00315
00316
00317
00318 template<class View, class CtrlView, ReifyMode rm>
00319 forceinline
00320 ReLeFloat<View,CtrlView,rm>::ReLeFloat(Home home, View x, FloatVal c0, CtrlView b)
00321 : Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView>(home,x,b), c(c0) {}
00322
00323 template<class View, class CtrlView, ReifyMode rm>
00324 ExecStatus
00325 ReLeFloat<View,CtrlView,rm>::post(Home home, View x, FloatVal c, CtrlView b) {
00326 if (b.one()) {
00327 if (rm != RM_PMI)
00328 {
00329 GECODE_ME_CHECK(x.lq(home,c.max()));
00330 if (x.assigned() && (x.max() >= c.min()))
00331 return ES_FAILED;
00332 (void) new (home) ReLeFloat<View,CtrlView,rm>(home,x,c,b);
00333 }
00334 } else if (b.zero()) {
00335 if (rm != RM_IMP)
00336 GECODE_ME_CHECK(x.gq(home,c.min()));
00337 } else {
00338 switch (rtest_le(x,c)) {
00339 case RT_TRUE:
00340 if (rm != RM_IMP)
00341 GECODE_ME_CHECK(b.one(home));
00342 break;
00343 case RT_FALSE:
00344 if (rm != RM_PMI)
00345 GECODE_ME_CHECK(b.zero(home));
00346 break;
00347 case RT_MAYBE:
00348 (void) new (home) ReLeFloat<View,CtrlView,rm>(home,x,c,b);
00349 break;
00350 default: GECODE_NEVER;
00351 }
00352 }
00353 return ES_OK;
00354 }
00355
00356
00357 template<class View, class CtrlView, ReifyMode rm>
00358 forceinline
00359 ReLeFloat<View,CtrlView,rm>::ReLeFloat(Space& home, bool share, ReLeFloat& p)
00360 : Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView>(home,share,p), c(p.c) {}
00361
00362 template<class View, class CtrlView, ReifyMode rm>
00363 Actor*
00364 ReLeFloat<View,CtrlView,rm>::copy(Space& home, bool share) {
00365 return new (home) ReLeFloat<View,CtrlView,rm>(home,share,*this);
00366 }
00367
00368 template<class View, class CtrlView, ReifyMode rm>
00369 ExecStatus
00370 ReLeFloat<View,CtrlView,rm>::propagate(Space& home, const ModEventDelta&) {
00371 if (b.one()) {
00372 if (rm != RM_PMI)
00373 {
00374 GECODE_ME_CHECK(x0.lq(home,c.max()));
00375 if (x0.assigned()) {
00376 return (x0.max() >= c.min()) ? ES_FAILED : home.ES_SUBSUMED(*this);
00377 }
00378 }
00379 } else if (b.zero()) {
00380 if (rm != RM_IMP)
00381 GECODE_ME_CHECK(x0.gq(home,c.min()));
00382 } else {
00383 switch (rtest_le(x0,c)) {
00384 case RT_TRUE:
00385 if (rm != RM_IMP)
00386 GECODE_ME_CHECK(b.one(home));
00387 break;
00388 case RT_FALSE:
00389 if (rm != RM_PMI)
00390 GECODE_ME_CHECK(b.zero(home));
00391 break;
00392 case RT_MAYBE:
00393 return ES_FIX;
00394 default: GECODE_NEVER;
00395 }
00396 }
00397 return home.ES_SUBSUMED(*this);
00398 }
00399
00400 }}}
00401
00402
00403