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
00176
00183 template<class BV>
00184 class Le {
00185 public:
00187 static ExecStatus post(Home home, BV b0, BV b1);
00188 };
00189
00190
00197 template<class BVA, class BVB>
00198 class BinOrTrue : public BoolBinary<BVA,BVB> {
00199 protected:
00200 using BoolBinary<BVA,BVB>::x0;
00201 using BoolBinary<BVA,BVB>::x1;
00203 BinOrTrue(Home home, BVA b0, BVB b1);
00205 BinOrTrue(Space& home, bool share, BinOrTrue& p);
00206 public:
00208 BinOrTrue(Space& home, bool share, Propagator& p,
00209 BVA b0, BVB b1);
00211 virtual Actor* copy(Space& home, bool share);
00213 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00215 static ExecStatus post(Home home, BVA b0, BVB b1);
00216 };
00217
00224 template<class BV>
00225 class TerOrTrue : public BoolBinary<BV,BV> {
00226 protected:
00227 using BoolBinary<BV,BV>::x0;
00228 using BoolBinary<BV,BV>::x1;
00230 BV x2;
00232 TerOrTrue(Home home, BV b0, BV b1, BV b2);
00234 TerOrTrue(Space& home, bool share, TerOrTrue& p);
00235 public:
00237 TerOrTrue(Space& home, bool share, Propagator& p,
00238 BV b0, BV b1, BV b2);
00240 virtual Actor* copy(Space& home, bool share);
00242 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00244 static ExecStatus post(Home home, BV b0, BV b1, BV b2);
00246 virtual size_t dispose(Space& home);
00247 };
00248
00255 template<class BV>
00256 class QuadOrTrue : public BoolBinary<BV,BV> {
00257 protected:
00258 using BoolBinary<BV,BV>::x0;
00259 using BoolBinary<BV,BV>::x1;
00261 BV x2;
00263 BV x3;
00265 QuadOrTrue(Home home, BV b0, BV b1, BV b2, BV b3);
00267 QuadOrTrue(Space& home, bool share, QuadOrTrue& p);
00268 public:
00270 QuadOrTrue(Space& home, bool share, Propagator& p,
00271 BV b0, BV b1, BV b2, BV b3);
00273 virtual Actor* copy(Space& home, bool share);
00275 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00277 static ExecStatus post(Home home, BV b0, BV b1, BV b2, BV b3);
00279 virtual size_t dispose(Space& home);
00280 };
00281
00288 template<class BVA, class BVB, class BVC>
00289 class Or : public BoolTernary<BVA,BVB,BVC> {
00290 protected:
00291 using BoolTernary<BVA,BVB,BVC>::x0;
00292 using BoolTernary<BVA,BVB,BVC>::x1;
00293 using BoolTernary<BVA,BVB,BVC>::x2;
00295 Or(Home home, BVA b0, BVB b1, BVC b2);
00297 Or(Space& home, bool share, Or& p);
00298 public:
00300 Or(Space& home, bool share, Propagator& p, BVA b0, BVB b1, BVC b2);
00302 virtual Actor* copy(Space& home, bool share);
00304 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00306 static ExecStatus post(Home home, BVA b0, BVB b1, BVC b2);
00307 };
00308
00315 template<class VX,class VY>
00316 class NaryOr
00317 : public MixNaryOnePropagator<VX,PC_BOOL_NONE,VY,PC_BOOL_VAL> {
00318 protected:
00319 using MixNaryOnePropagator<VX,PC_BOOL_NONE,VY,PC_BOOL_VAL>::x;
00320 using MixNaryOnePropagator<VX,PC_BOOL_NONE,VY,PC_BOOL_VAL>::y;
00322 int n_zero;
00324 Council<Advisor> c;
00326 NaryOr(Home home, ViewArray<VX>& x, VY y);
00328 NaryOr(Space& home, bool share, NaryOr<VX,VY>& p);
00329 public:
00331 virtual Actor* copy(Space& home, bool share);
00333 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00335 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00337 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00339 static ExecStatus post(Home home, ViewArray<VX>& x, VY y);
00341 virtual size_t dispose(Space& home);
00342 };
00343
00344
00351 template<class BV>
00352 class NaryOrTrue : public BinaryPropagator<BV,PC_BOOL_VAL> {
00353 protected:
00354 using BinaryPropagator<BV,PC_BOOL_VAL>::x0;
00355 using BinaryPropagator<BV,PC_BOOL_VAL>::x1;
00357 ViewArray<BV> x;
00359 ExecStatus resubscribe(Space& home, BV& x0, BV x1);
00361 NaryOrTrue(Home home, ViewArray<BV>& x);
00363 NaryOrTrue(Space& home, bool share, NaryOrTrue<BV>& p);
00364 public:
00366 virtual Actor* copy(Space& home, bool share);
00368 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00370 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00372 static ExecStatus post(Home home, ViewArray<BV>& b);
00374 virtual size_t dispose(Space& home);
00375 };
00376
00377
00384 template<class BVA, class BVB, class BVC>
00385 class Eqv : public BoolTernary<BVA,BVB,BVC> {
00386 protected:
00387 using BoolTernary<BVA,BVB,BVC>::x0;
00388 using BoolTernary<BVA,BVB,BVC>::x1;
00389 using BoolTernary<BVA,BVB,BVC>::x2;
00391 Eqv(Space& home, bool share, Eqv& p);
00393 Eqv(Home home, BVA b0 ,BVB b1, BVC b2);
00394 public:
00396 virtual Actor* copy(Space& home, bool share);
00398 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00400 static ExecStatus post(Home home, BVA b0, BVB b1, BVC b2);
00401 };
00402
00403
00410 template<class VX, class VY>
00411 class Clause : public Propagator {
00412 protected:
00414 ViewArray<VX> x;
00416 ViewArray<VY> y;
00418 VX z;
00420 int n_zero;
00422 class Tagged : public Advisor {
00423 public:
00425 const bool x;
00427 Tagged(Space& home, Propagator& p, Council<Tagged>& c, bool x);
00429 Tagged(Space& home, bool share, Tagged& a);
00430 };
00432 Council<Tagged> c;
00434 void cancel(Space& home);
00436 Clause(Home home, ViewArray<VX>& x, ViewArray<VY>& y, VX z);
00438 Clause(Space& home, bool share, Clause<VX,VY>& p);
00439 public:
00441 virtual Actor* copy(Space& home, bool share);
00443 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00445 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00447 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00449 static ExecStatus post(Home home, ViewArray<VX>& x, ViewArray<VY>& y,
00450 VX z);
00452 virtual size_t dispose(Space& home);
00453 };
00454
00455
00462 template<class VX, class VY>
00463 class ClauseTrue
00464 : public MixBinaryPropagator<VX,PC_BOOL_VAL,VY,PC_BOOL_VAL> {
00465 protected:
00466 using MixBinaryPropagator<VX,PC_BOOL_VAL,VY,PC_BOOL_VAL>::x0;
00467 using MixBinaryPropagator<VX,PC_BOOL_VAL,VY,PC_BOOL_VAL>::x1;
00469 ViewArray<VX> x;
00471 ViewArray<VY> y;
00473 ClauseTrue(Home home, ViewArray<VX>& x, ViewArray<VY>& y);
00475 ClauseTrue(Space& home, bool share, ClauseTrue<VX,VY>& p);
00476 public:
00478 virtual Actor* copy(Space& home, bool share);
00480 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00482 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00484 static ExecStatus post(Home home, ViewArray<VX>& x, ViewArray<VY>& y);
00486 virtual size_t dispose(Space& home);
00487 };
00488
00489
00490 }}}
00491
00492 #include <gecode/int/bool/base.hpp>
00493 #include <gecode/int/bool/eq.hpp>
00494 #include <gecode/int/bool/lq.hpp>
00495 #include <gecode/int/bool/or.hpp>
00496 #include <gecode/int/bool/eqv.hpp>
00497 #include <gecode/int/bool/clause.hpp>
00498
00499 #endif
00500
00501
00502