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 #ifndef __GECODE_INT_BOOL_HH__
00041 #define __GECODE_INT_BOOL_HH__
00042
00043 #include <gecode/int.hh>
00044
00050 namespace Gecode { namespace Int { namespace Bool {
00051
00052
00053
00054
00055
00056
00058 template<class BVA, class BVB>
00059 class BoolBinary : public Propagator {
00060 protected:
00061 BVA x0;
00062 BVB x1;
00063
00064 BoolBinary(Home home, BVA b0, BVB b1);
00066 BoolBinary(Space& home, bool share, BoolBinary& p);
00068 BoolBinary(Space& home, bool share, Propagator& p,
00069 BVA b0, BVB b1);
00070 public:
00072 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00074 virtual size_t dispose(Space& home);
00075 };
00076
00078 template<class BVA, class BVB, class BVC>
00079 class BoolTernary : public Propagator {
00080 protected:
00081 BVA x0;
00082 BVB x1;
00083 BVC x2;
00084
00085 BoolTernary(Home home, BVA b0, BVB b1, BVC b2);
00087 BoolTernary(Space& home, bool share, BoolTernary& p);
00088 public:
00090 BoolTernary(Space& home, bool share, Propagator& p,
00091 BVA b0, BVB b1, BVC b2);
00093 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00095 virtual size_t dispose(Space& home);
00096 };
00097
00104 template<class BVA, class BVB>
00105 class Eq : public BoolBinary<BVA,BVB> {
00106 protected:
00107 using BoolBinary<BVA,BVB>::x0;
00108 using BoolBinary<BVA,BVB>::x1;
00110 Eq(Home home, BVA b0, BVB b1);
00112 Eq(Space& home, bool share, Eq& p);
00113 public:
00115 Eq(Space& home, bool share, Propagator& p,
00116 BVA b0, BVB b1);
00118 virtual Actor* copy(Space& home, bool share);
00120 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00122 static ExecStatus post(Home home, BVA x0, BVB x1);
00123 };
00124
00125
00132 template<class BV>
00133 class NaryEq : public NaryPropagator<BV,PC_BOOL_VAL> {
00134 protected:
00135 using NaryPropagator<BV,PC_BOOL_VAL>::x;
00137 NaryEq(Home home, ViewArray<BV>& x);
00139 NaryEq(Space& home, bool share, NaryEq& p);
00140 public:
00142 virtual Actor* copy(Space& home, bool share);
00144 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00146 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00148 static ExecStatus post(Home home, ViewArray<BV>& x);
00149 };
00150
00151
00158 template<class BV>
00159 class Lq : public BoolBinary<BV,BV> {
00160 protected:
00161 using BoolBinary<BV,BV>::x0;
00162 using BoolBinary<BV,BV>::x1;
00164 Lq(Home home, BV b0, BV b1);
00166 Lq(Space& home, bool share, Lq& p);
00167 public:
00169 virtual Actor* copy(Space& home, bool share);
00171 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00173 static ExecStatus post(Home home, BV b0, BV b1);
00174 };
00175
00182 template<class VX>
00183 class NaryLq : public NaryPropagator<VX,PC_BOOL_NONE> {
00184 protected:
00185 using NaryPropagator<VX,PC_BOOL_NONE>::x;
00187 bool run;
00189 int n_zero;
00191 int n_one;
00193 Council<Advisor> c;
00195 NaryLq(Home home, ViewArray<VX>& x);
00197 NaryLq(Space& home, bool share, NaryLq<VX>& p);
00198 public:
00200 virtual Actor* copy(Space& home, bool share);
00202 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00204 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00206 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00208 static ExecStatus post(Home home, ViewArray<VX>& x);
00210 virtual size_t dispose(Space& home);
00211 };
00212
00213
00214
00215
00222 template<class BV>
00223 class Le {
00224 public:
00226 static ExecStatus post(Home home, BV b0, BV b1);
00227 };
00228
00229
00236 template<class BVA, class BVB>
00237 class BinOrTrue : public BoolBinary<BVA,BVB> {
00238 protected:
00239 using BoolBinary<BVA,BVB>::x0;
00240 using BoolBinary<BVA,BVB>::x1;
00242 BinOrTrue(Home home, BVA b0, BVB b1);
00244 BinOrTrue(Space& home, bool share, BinOrTrue& p);
00245 public:
00247 BinOrTrue(Space& home, bool share, Propagator& p,
00248 BVA b0, BVB b1);
00250 virtual Actor* copy(Space& home, bool share);
00252 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00254 static ExecStatus post(Home home, BVA b0, BVB b1);
00255 };
00256
00263 template<class BV>
00264 class TerOrTrue : public BoolBinary<BV,BV> {
00265 protected:
00266 using BoolBinary<BV,BV>::x0;
00267 using BoolBinary<BV,BV>::x1;
00269 BV x2;
00271 TerOrTrue(Home home, BV b0, BV b1, BV b2);
00273 TerOrTrue(Space& home, bool share, TerOrTrue& p);
00274 public:
00276 TerOrTrue(Space& home, bool share, Propagator& p,
00277 BV b0, BV b1, BV b2);
00279 virtual Actor* copy(Space& home, bool share);
00281 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00283 static ExecStatus post(Home home, BV b0, BV b1, BV b2);
00285 virtual size_t dispose(Space& home);
00286 };
00287
00294 template<class BV>
00295 class QuadOrTrue : public BoolBinary<BV,BV> {
00296 protected:
00297 using BoolBinary<BV,BV>::x0;
00298 using BoolBinary<BV,BV>::x1;
00300 BV x2;
00302 BV x3;
00304 QuadOrTrue(Home home, BV b0, BV b1, BV b2, BV b3);
00306 QuadOrTrue(Space& home, bool share, QuadOrTrue& p);
00307 public:
00309 QuadOrTrue(Space& home, bool share, Propagator& p,
00310 BV b0, BV b1, BV b2, BV b3);
00312 virtual Actor* copy(Space& home, bool share);
00314 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00316 static ExecStatus post(Home home, BV b0, BV b1, BV b2, BV b3);
00318 virtual size_t dispose(Space& home);
00319 };
00320
00327 template<class BVA, class BVB, class BVC>
00328 class Or : public BoolTernary<BVA,BVB,BVC> {
00329 protected:
00330 using BoolTernary<BVA,BVB,BVC>::x0;
00331 using BoolTernary<BVA,BVB,BVC>::x1;
00332 using BoolTernary<BVA,BVB,BVC>::x2;
00334 Or(Home home, BVA b0, BVB b1, BVC b2);
00336 Or(Space& home, bool share, Or& p);
00337 public:
00339 Or(Space& home, bool share, Propagator& p, BVA b0, BVB b1, BVC b2);
00341 virtual Actor* copy(Space& home, bool share);
00343 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00345 static ExecStatus post(Home home, BVA b0, BVB b1, BVC b2);
00346 };
00347
00354 template<class VX,class VY>
00355 class NaryOr
00356 : public MixNaryOnePropagator<VX,PC_BOOL_NONE,VY,PC_BOOL_VAL> {
00357 protected:
00358 using MixNaryOnePropagator<VX,PC_BOOL_NONE,VY,PC_BOOL_VAL>::x;
00359 using MixNaryOnePropagator<VX,PC_BOOL_NONE,VY,PC_BOOL_VAL>::y;
00361 int n_zero;
00363 Council<Advisor> c;
00365 NaryOr(Home home, ViewArray<VX>& x, VY y);
00367 NaryOr(Space& home, bool share, NaryOr<VX,VY>& p);
00368 public:
00370 virtual Actor* copy(Space& home, bool share);
00372 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00374 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00376 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00378 static ExecStatus post(Home home, ViewArray<VX>& x, VY y);
00380 virtual size_t dispose(Space& home);
00381 };
00382
00383
00390 template<class BV>
00391 class NaryOrTrue : public BinaryPropagator<BV,PC_BOOL_VAL> {
00392 protected:
00393 using BinaryPropagator<BV,PC_BOOL_VAL>::x0;
00394 using BinaryPropagator<BV,PC_BOOL_VAL>::x1;
00396 ViewArray<BV> x;
00398 ExecStatus resubscribe(Space& home, BV& x0, BV x1);
00400 NaryOrTrue(Home home, ViewArray<BV>& x);
00402 NaryOrTrue(Space& home, bool share, NaryOrTrue<BV>& p);
00403 public:
00405 virtual Actor* copy(Space& home, bool share);
00407 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00409 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00411 static ExecStatus post(Home home, ViewArray<BV>& b);
00413 virtual size_t dispose(Space& home);
00414 };
00415
00416
00423 template<class BVA, class BVB, class BVC>
00424 class Eqv : public BoolTernary<BVA,BVB,BVC> {
00425 protected:
00426 using BoolTernary<BVA,BVB,BVC>::x0;
00427 using BoolTernary<BVA,BVB,BVC>::x1;
00428 using BoolTernary<BVA,BVB,BVC>::x2;
00430 Eqv(Space& home, bool share, Eqv& p);
00432 Eqv(Home home, BVA b0 ,BVB b1, BVC b2);
00433 public:
00435 virtual Actor* copy(Space& home, bool share);
00437 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00439 static ExecStatus post(Home home, BVA b0, BVB b1, BVC b2);
00440 };
00441
00442
00451 class NaryEqv : public BinaryPropagator<BoolView,PC_BOOL_VAL> {
00452 protected:
00453 using BinaryPropagator<BoolView,PC_BOOL_VAL>::x0;
00454 using BinaryPropagator<BoolView,PC_BOOL_VAL>::x1;
00456 ViewArray<BoolView> x;
00458 int pm2;
00460 void resubscribe(Space& home, BoolView& x0);
00462 NaryEqv(Home home, ViewArray<BoolView>& x, int pm2);
00464 NaryEqv(Space& home, bool share, NaryEqv& p);
00465 public:
00467 GECODE_INT_EXPORT
00468 virtual Actor* copy(Space& home, bool share);
00470 GECODE_INT_EXPORT
00471 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00473 GECODE_INT_EXPORT
00474 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00476 GECODE_INT_EXPORT
00477 static ExecStatus post(Home home, ViewArray<BoolView>& x, int pm2);
00479 virtual size_t dispose(Space& home);
00480 };
00481
00482
00489 template<class VX, class VY>
00490 class Clause : public Propagator {
00491 protected:
00493 ViewArray<VX> x;
00495 ViewArray<VY> y;
00497 VX z;
00499 int n_zero;
00501 class Tagged : public Advisor {
00502 public:
00504 const bool x;
00506 Tagged(Space& home, Propagator& p, Council<Tagged>& c, bool x);
00508 Tagged(Space& home, bool share, Tagged& a);
00509 };
00511 Council<Tagged> c;
00513 void cancel(Space& home);
00515 Clause(Home home, ViewArray<VX>& x, ViewArray<VY>& y, VX z);
00517 Clause(Space& home, bool share, Clause<VX,VY>& p);
00518 public:
00520 virtual Actor* copy(Space& home, bool share);
00522 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00524 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00526 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00528 static ExecStatus post(Home home, ViewArray<VX>& x, ViewArray<VY>& y,
00529 VX z);
00531 virtual size_t dispose(Space& home);
00532 };
00533
00534
00541 template<class VX, class VY>
00542 class ClauseTrue
00543 : public MixBinaryPropagator<VX,PC_BOOL_VAL,VY,PC_BOOL_VAL> {
00544 protected:
00545 using MixBinaryPropagator<VX,PC_BOOL_VAL,VY,PC_BOOL_VAL>::x0;
00546 using MixBinaryPropagator<VX,PC_BOOL_VAL,VY,PC_BOOL_VAL>::x1;
00548 ViewArray<VX> x;
00550 ViewArray<VY> y;
00552 ClauseTrue(Home home, ViewArray<VX>& x, ViewArray<VY>& y);
00554 ClauseTrue(Space& home, bool share, ClauseTrue<VX,VY>& p);
00555 public:
00557 virtual Actor* copy(Space& home, bool share);
00559 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00561 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00563 static ExecStatus post(Home home, ViewArray<VX>& x, ViewArray<VY>& y);
00565 virtual size_t dispose(Space& home);
00566 };
00567
00568
00569 }}}
00570
00571 #include <gecode/int/bool/base.hpp>
00572 #include <gecode/int/bool/eq.hpp>
00573 #include <gecode/int/bool/lq.hpp>
00574 #include <gecode/int/bool/or.hpp>
00575 #include <gecode/int/bool/eqv.hpp>
00576 #include <gecode/int/bool/clause.hpp>
00577
00578 #endif
00579
00580
00581