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:
00130 b.t_one_none(home); break;
00131 case RT_FALSE:
00132 b.t_zero_none(home); break;
00133 case RT_MAYBE:
00134 (void) new (home) ReLq<View,CtrlView>(home,x0,x1,b); break;
00135 default: GECODE_NEVER;
00136 }
00137 } else {
00138 b.t_one_none(home);
00139 }
00140 return ES_OK;
00141 }
00142
00143 template <class View, class CtrlView>
00144 forceinline
00145 ReLq<View,CtrlView>::ReLq(Space* home, bool share, ReLq& p)
00146 : ReBinaryPropagator<View,PC_INT_BND,CtrlView>(home,share,p) {}
00147
00148 template <class View, class CtrlView>
00149 Actor*
00150 ReLq<View,CtrlView>::copy(Space* home, bool share) {
00151 return new (home) ReLq<View,CtrlView>(home,share,*this);
00152 }
00153
00154 template <class View, class CtrlView>
00155 ExecStatus
00156 ReLq<View,CtrlView>::propagate(Space* home) {
00157 if (b.one()) {
00158 if (Lq<View>::post(home,x0,x1) == ES_FAILED)
00159 return ES_FAILED;
00160 return ES_SUBSUMED;
00161 }
00162 if (b.zero()) {
00163 if (Le<View>::post(home,x1,x0) == ES_FAILED)
00164 return ES_FAILED;
00165 return ES_SUBSUMED;
00166 }
00167 switch (rtest_lq(x0,x1)) {
00168 case RT_TRUE:
00169 b.t_one_none(home); return ES_SUBSUMED;
00170 case RT_FALSE:
00171 b.t_zero_none(home); return ES_SUBSUMED;
00172 case RT_MAYBE:
00173 break;
00174 default: GECODE_NEVER;
00175 }
00176 return ES_FIX;
00177 }
00178
00179
00180
00181
00182
00183
00184 template <class View, class CtrlView>
00185 forceinline
00186 ReLqInt<View,CtrlView>::ReLqInt(Space* home, View x, int c0, CtrlView b)
00187 : ReUnaryPropagator<View,PC_INT_BND,CtrlView>(home,x,b), c(c0) {}
00188
00189 template <class View, class CtrlView>
00190 ExecStatus
00191 ReLqInt<View,CtrlView>::post(Space* home, View x, int c, CtrlView b) {
00192 if (b.one()) {
00193 GECODE_ME_CHECK(x.lq(home,c));
00194 } else if (b.zero()) {
00195 GECODE_ME_CHECK(x.gr(home,c));
00196 } else {
00197 switch (rtest_lq(x,c)) {
00198 case RT_TRUE:
00199 b.t_one_none(home); break;
00200 case RT_FALSE:
00201 b.t_zero_none(home); break;
00202 case RT_MAYBE:
00203 (void) new (home) ReLqInt<View,CtrlView>(home,x,c,b); break;
00204 default: GECODE_NEVER;
00205 }
00206 }
00207 return ES_OK;
00208 }
00209
00210
00211 template <class View, class CtrlView>
00212 forceinline
00213 ReLqInt<View,CtrlView>::ReLqInt(Space* home, bool share, ReLqInt& p)
00214 : ReUnaryPropagator<View,PC_INT_BND,CtrlView>(home,share,p), c(p.c) {}
00215
00216 template <class View, class CtrlView>
00217 Actor*
00218 ReLqInt<View,CtrlView>::copy(Space* home, bool share) {
00219 return new (home) ReLqInt<View,CtrlView>(home,share,*this);
00220 }
00221
00222 template <class View, class CtrlView>
00223 ExecStatus
00224 ReLqInt<View,CtrlView>::propagate(Space* home) {
00225 if (b.one()) {
00226 GECODE_ME_CHECK(x0.lq(home,c)); return ES_SUBSUMED;
00227 }
00228 if (b.zero()) {
00229 GECODE_ME_CHECK(x0.gr(home,c)); return ES_SUBSUMED;
00230 }
00231 switch (rtest_lq(x0,c)) {
00232 case RT_TRUE:
00233 b.t_one_none(home); return ES_SUBSUMED;
00234 case RT_FALSE:
00235 b.t_zero_none(home); return ES_SUBSUMED;
00236 case RT_MAYBE:
00237 break;
00238 default: GECODE_NEVER;
00239 }
00240 return ES_FIX;
00241 }
00242
00243 }}}
00244
00245
00246