lq.hpp
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
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 namespace Gecode { namespace Int { namespace Bool {
00039
00040
00041
00042
00043
00044
00045 template<class BV>
00046 forceinline
00047 Lq<BV>::Lq(Home home, BV b0, BV b1)
00048 : BoolBinary<BV,BV>(home,b0,b1) {}
00049
00050 template<class BV>
00051 forceinline
00052 Lq<BV>::Lq(Space& home, bool share, Lq<BV>& p)
00053 : BoolBinary<BV,BV>(home,share,p) {}
00054
00055 template<class BV>
00056 Actor*
00057 Lq<BV>::copy(Space& home, bool share) {
00058 return new (home) Lq<BV>(home,share,*this);
00059 }
00060
00061 template<class BV>
00062 inline ExecStatus
00063 Lq<BV>::post(Home home, BV b0, BV b1) {
00064 if (b0.zero()) {
00065 return ES_OK;
00066 } else if (b0.one()) {
00067 GECODE_ME_CHECK(b1.one(home));
00068 } else if (b1.zero()) {
00069 GECODE_ME_CHECK(b0.zero(home));
00070 } else if (b1.one()) {
00071 return ES_OK;
00072 } else {
00073 (void) new (home) Lq<BV>(home,b0,b1);
00074 }
00075 return ES_OK;
00076 }
00077
00078 template<class BV>
00079 ExecStatus
00080 Lq<BV>::propagate(Space& home, const ModEventDelta&) {
00081 #define GECODE_INT_STATUS(S0,S1) \
00082 ((BV::S0<<(1*BV::BITS))|(BV::S1<<(0*BV::BITS)))
00083 switch ((x0.status()<<(1*BV::BITS)) | (x1.status()<<(0*BV::BITS))) {
00084 case GECODE_INT_STATUS(NONE,NONE):
00085 GECODE_NEVER;
00086 case GECODE_INT_STATUS(NONE,ZERO):
00087 GECODE_ME_CHECK(x0.zero_none(home)); break;
00088 case GECODE_INT_STATUS(NONE,ONE):
00089 x0.cancel(home,*this,PC_BOOL_VAL); break;
00090 case GECODE_INT_STATUS(ZERO,NONE):
00091 x1.cancel(home,*this,PC_BOOL_VAL); break;
00092 case GECODE_INT_STATUS(ZERO,ZERO):
00093 break;
00094 case GECODE_INT_STATUS(ZERO,ONE):
00095 break;
00096 case GECODE_INT_STATUS(ONE,NONE):
00097 GECODE_ME_CHECK(x1.one_none(home)); break;
00098 case GECODE_INT_STATUS(ONE,ZERO):
00099 return ES_FAILED;
00100 case GECODE_INT_STATUS(ONE,ONE):
00101 break;
00102 default:
00103 GECODE_NEVER;
00104 }
00105 return ES_SUBSUMED(*this,sizeof(*this));
00106 #undef GECODE_INT_STATUS
00107 }
00108
00109
00110
00111
00112
00113
00114 template<class BV>
00115 forceinline ExecStatus
00116 Le<BV>::post(Home home, BV b0, BV b1) {
00117 GECODE_ME_CHECK(b0.zero(home));
00118 GECODE_ME_CHECK(b1.one(home));
00119 return ES_OK;
00120 }
00121
00122 }}}
00123
00124
00125