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 void reschedule(Space& home);
00076 virtual size_t dispose(Space& home);
00077 };
00078
00080 template<class BVA, class BVB, class BVC>
00081 class BoolTernary : public Propagator {
00082 protected:
00083 BVA x0;
00084 BVB x1;
00085 BVC x2;
00086
00087 BoolTernary(Home home, BVA b0, BVB b1, BVC b2);
00089 BoolTernary(Space& home, bool share, BoolTernary& p);
00090 public:
00092 BoolTernary(Space& home, bool share, Propagator& p,
00093 BVA b0, BVB b1, BVC b2);
00095 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00097 virtual void reschedule(Space& home);
00099 virtual size_t dispose(Space& home);
00100 };
00101
00108 template<class BVA, class BVB>
00109 class Eq : public BoolBinary<BVA,BVB> {
00110 protected:
00111 using BoolBinary<BVA,BVB>::x0;
00112 using BoolBinary<BVA,BVB>::x1;
00114 Eq(Home home, BVA b0, BVB b1);
00116 Eq(Space& home, bool share, Eq& p);
00117 public:
00119 Eq(Space& home, bool share, Propagator& p,
00120 BVA b0, BVB b1);
00122 virtual Actor* copy(Space& home, bool share);
00124 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00126 static ExecStatus post(Home home, BVA x0, BVB x1);
00127 };
00128
00129
00136 template<class BV>
00137 class NaryEq : public NaryPropagator<BV,PC_BOOL_VAL> {
00138 protected:
00139 using NaryPropagator<BV,PC_BOOL_VAL>::x;
00141 NaryEq(Home home, ViewArray<BV>& x);
00143 NaryEq(Space& home, bool share, NaryEq& p);
00144 public:
00146 virtual Actor* copy(Space& home, bool share);
00148 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00150 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00152 static ExecStatus post(Home home, ViewArray<BV>& x);
00153 };
00154
00155
00162 template<class BV>
00163 class Lq : public BoolBinary<BV,BV> {
00164 protected:
00165 using BoolBinary<BV,BV>::x0;
00166 using BoolBinary<BV,BV>::x1;
00168 Lq(Home home, BV b0, BV b1);
00170 Lq(Space& home, bool share, Lq& p);
00171 public:
00173 virtual Actor* copy(Space& home, bool share);
00175 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00177 static ExecStatus post(Home home, BV b0, BV b1);
00178 };
00179
00186 template<class VX>
00187 class NaryLq : public NaryPropagator<VX,PC_BOOL_NONE> {
00188 protected:
00189 using NaryPropagator<VX,PC_BOOL_NONE>::x;
00191 bool run;
00193 int n_zero;
00195 int n_one;
00197 Council<Advisor> c;
00199 NaryLq(Home home, ViewArray<VX>& x);
00201 NaryLq(Space& home, bool share, NaryLq<VX>& p);
00202 public:
00204 virtual Actor* copy(Space& home, bool share);
00206 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00208 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00210 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00212 static ExecStatus post(Home home, ViewArray<VX>& x);
00214 virtual size_t dispose(Space& home);
00215 };
00216
00217
00218
00219
00226 template<class BV>
00227 class Le {
00228 public:
00230 static ExecStatus post(Home home, BV b0, BV b1);
00231 };
00232
00233
00240 template<class BVA, class BVB>
00241 class BinOrTrue : public BoolBinary<BVA,BVB> {
00242 protected:
00243 using BoolBinary<BVA,BVB>::x0;
00244 using BoolBinary<BVA,BVB>::x1;
00246 BinOrTrue(Home home, BVA b0, BVB b1);
00248 BinOrTrue(Space& home, bool share, BinOrTrue& p);
00249 public:
00251 BinOrTrue(Space& home, bool share, Propagator& p,
00252 BVA b0, BVB b1);
00254 virtual Actor* copy(Space& home, bool share);
00256 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00258 static ExecStatus post(Home home, BVA b0, BVB b1);
00259 };
00260
00267 template<class BV>
00268 class TerOrTrue : public BoolBinary<BV,BV> {
00269 protected:
00270 using BoolBinary<BV,BV>::x0;
00271 using BoolBinary<BV,BV>::x1;
00273 BV x2;
00275 TerOrTrue(Home home, BV b0, BV b1, BV b2);
00277 TerOrTrue(Space& home, bool share, TerOrTrue& p);
00278 public:
00280 TerOrTrue(Space& home, bool share, Propagator& p,
00281 BV b0, BV b1, BV b2);
00283 virtual Actor* copy(Space& home, bool share);
00285 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00287 static ExecStatus post(Home home, BV b0, BV b1, BV b2);
00289 virtual size_t dispose(Space& home);
00290 };
00291
00298 template<class BV>
00299 class QuadOrTrue : public BoolBinary<BV,BV> {
00300 protected:
00301 using BoolBinary<BV,BV>::x0;
00302 using BoolBinary<BV,BV>::x1;
00304 BV x2;
00306 BV x3;
00308 QuadOrTrue(Home home, BV b0, BV b1, BV b2, BV b3);
00310 QuadOrTrue(Space& home, bool share, QuadOrTrue& p);
00311 public:
00313 QuadOrTrue(Space& home, bool share, Propagator& p,
00314 BV b0, BV b1, BV b2, BV b3);
00316 virtual Actor* copy(Space& home, bool share);
00318 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00320 static ExecStatus post(Home home, BV b0, BV b1, BV b2, BV b3);
00322 virtual size_t dispose(Space& home);
00323 };
00324
00331 template<class BVA, class BVB, class BVC>
00332 class Or : public BoolTernary<BVA,BVB,BVC> {
00333 protected:
00334 using BoolTernary<BVA,BVB,BVC>::x0;
00335 using BoolTernary<BVA,BVB,BVC>::x1;
00336 using BoolTernary<BVA,BVB,BVC>::x2;
00338 Or(Home home, BVA b0, BVB b1, BVC b2);
00340 Or(Space& home, bool share, Or& p);
00341 public:
00343 Or(Space& home, bool share, Propagator& p, BVA b0, BVB b1, BVC b2);
00345 virtual Actor* copy(Space& home, bool share);
00347 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00349 static ExecStatus post(Home home, BVA b0, BVB b1, BVC b2);
00350 };
00351
00358 template<class VX,class VY>
00359 class NaryOr
00360 : public MixNaryOnePropagator<VX,PC_BOOL_NONE,VY,PC_BOOL_VAL> {
00361 protected:
00362 using MixNaryOnePropagator<VX,PC_BOOL_NONE,VY,PC_BOOL_VAL>::x;
00363 using MixNaryOnePropagator<VX,PC_BOOL_NONE,VY,PC_BOOL_VAL>::y;
00365 int n_zero;
00367 Council<Advisor> c;
00369 NaryOr(Home home, ViewArray<VX>& x, VY y);
00371 NaryOr(Space& home, bool share, NaryOr<VX,VY>& p);
00372 public:
00374 virtual Actor* copy(Space& home, bool share);
00376 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00378 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00380 virtual void reschedule(Space& home);
00382 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00384 static ExecStatus post(Home home, ViewArray<VX>& x, VY y);
00386 virtual size_t dispose(Space& home);
00387 };
00388
00389
00396 template<class BV>
00397 class NaryOrTrue : public BinaryPropagator<BV,PC_BOOL_VAL> {
00398 protected:
00399 using BinaryPropagator<BV,PC_BOOL_VAL>::x0;
00400 using BinaryPropagator<BV,PC_BOOL_VAL>::x1;
00402 ViewArray<BV> x;
00404 ExecStatus resubscribe(Space& home, BV& x0, BV x1);
00406 NaryOrTrue(Home home, ViewArray<BV>& x);
00408 NaryOrTrue(Space& home, bool share, NaryOrTrue<BV>& p);
00409 public:
00411 virtual Actor* copy(Space& home, bool share);
00413 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00415 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00417 static ExecStatus post(Home home, ViewArray<BV>& b);
00419 virtual size_t dispose(Space& home);
00420 };
00421
00422
00429 template<class BVA, class BVB, class BVC>
00430 class Eqv : public BoolTernary<BVA,BVB,BVC> {
00431 protected:
00432 using BoolTernary<BVA,BVB,BVC>::x0;
00433 using BoolTernary<BVA,BVB,BVC>::x1;
00434 using BoolTernary<BVA,BVB,BVC>::x2;
00436 Eqv(Space& home, bool share, Eqv& p);
00438 Eqv(Home home, BVA b0 ,BVB b1, BVC b2);
00439 public:
00441 virtual Actor* copy(Space& home, bool share);
00443 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00445 static ExecStatus post(Home home, BVA b0, BVB b1, BVC b2);
00446 };
00447
00448
00457 class NaryEqv : public BinaryPropagator<BoolView,PC_BOOL_VAL> {
00458 protected:
00459 using BinaryPropagator<BoolView,PC_BOOL_VAL>::x0;
00460 using BinaryPropagator<BoolView,PC_BOOL_VAL>::x1;
00462 ViewArray<BoolView> x;
00464 int pm2;
00466 void resubscribe(Space& home, BoolView& x0);
00468 NaryEqv(Home home, ViewArray<BoolView>& x, int pm2);
00470 NaryEqv(Space& home, bool share, NaryEqv& p);
00471 public:
00473 GECODE_INT_EXPORT
00474 virtual Actor* copy(Space& home, bool share);
00476 GECODE_INT_EXPORT
00477 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00479 GECODE_INT_EXPORT
00480 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00482 GECODE_INT_EXPORT
00483 static ExecStatus post(Home home, ViewArray<BoolView>& x, int pm2);
00485 virtual size_t dispose(Space& home);
00486 };
00487
00488
00495 template<class VX, class VY>
00496 class Clause : public Propagator {
00497 protected:
00499 ViewArray<VX> x;
00501 ViewArray<VY> y;
00503 VX z;
00505 int n_zero;
00507 class Tagged : public Advisor {
00508 public:
00510 const bool x;
00512 Tagged(Space& home, Propagator& p, Council<Tagged>& c, bool x);
00514 Tagged(Space& home, bool share, Tagged& a);
00515 };
00517 Council<Tagged> c;
00519 void cancel(Space& home);
00521 Clause(Home home, ViewArray<VX>& x, ViewArray<VY>& y, VX z);
00523 Clause(Space& home, bool share, Clause<VX,VY>& p);
00524 public:
00526 virtual Actor* copy(Space& home, bool share);
00528 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00530 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00532 virtual void reschedule(Space& home);
00534 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00536 static ExecStatus post(Home home, ViewArray<VX>& x, ViewArray<VY>& y,
00537 VX z);
00539 virtual size_t dispose(Space& home);
00540 };
00541
00542
00549 template<class VX, class VY>
00550 class ClauseTrue
00551 : public MixBinaryPropagator<VX,PC_BOOL_VAL,VY,PC_BOOL_VAL> {
00552 protected:
00553 using MixBinaryPropagator<VX,PC_BOOL_VAL,VY,PC_BOOL_VAL>::x0;
00554 using MixBinaryPropagator<VX,PC_BOOL_VAL,VY,PC_BOOL_VAL>::x1;
00556 ViewArray<VX> x;
00558 ViewArray<VY> y;
00560 ClauseTrue(Home home, ViewArray<VX>& x, ViewArray<VY>& y);
00562 ClauseTrue(Space& home, bool share, ClauseTrue<VX,VY>& p);
00563 public:
00565 virtual Actor* copy(Space& home, bool share);
00567 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00569 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00571 static ExecStatus post(Home home, ViewArray<VX>& x, ViewArray<VY>& y);
00573 virtual size_t dispose(Space& home);
00574 };
00575
00576
00583 template<class V0, class V1, class V2, PropCond pc>
00584 class IteBase : public Propagator {
00585 protected:
00587 BoolView b;
00589 V0 x0; V1 x1; V2 x2;
00591 IteBase(Space& home, bool share, IteBase& p);
00593 IteBase(Home home, BoolView b, V0 x0, V1 x1, V2 x2);
00594 public:
00596 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00598 virtual void reschedule(Space& home);
00600 virtual size_t dispose(Space& home);
00601 };
00602
00609 template<class V0, class V1, class V2>
00610 class IteBnd : public IteBase<V0,V1,V2,PC_INT_BND> {
00611 protected:
00612 using IteBase<V0,V1,V2,PC_INT_BND>::b;
00613 using IteBase<V0,V1,V2,PC_INT_BND>::x0;
00614 using IteBase<V0,V1,V2,PC_INT_BND>::x1;
00615 using IteBase<V0,V1,V2,PC_INT_BND>::x2;
00617 IteBnd(Space& home, bool share, IteBnd& p);
00619 IteBnd(Home home, BoolView b, V0 x0, V1 x1, V2 x2);
00620 public:
00622 virtual Actor* copy(Space& home, bool share);
00624 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00626 static ExecStatus post(Home home, BoolView b, V0 x0, V1 x1, V2 x2);
00627 };
00628
00635 template<class V0, class V1, class V2>
00636 class IteDom : public IteBase<V0,V1,V2,PC_INT_DOM> {
00637 protected:
00638 using IteBase<V0,V1,V2,PC_INT_DOM>::b;
00639 using IteBase<V0,V1,V2,PC_INT_DOM>::x0;
00640 using IteBase<V0,V1,V2,PC_INT_DOM>::x1;
00641 using IteBase<V0,V1,V2,PC_INT_DOM>::x2;
00643 IteDom(Space& home, bool share, IteDom& p);
00645 IteDom(Home home, BoolView b, V0 x0, V1 x1, V2 x2);
00646 public:
00648 virtual Actor* copy(Space& home, bool share);
00650 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00652 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00654 static ExecStatus post(Home home, BoolView b, V0 x0, V1 x1, V2 x2);
00655 };
00656
00657 }}}
00658
00659 #include <gecode/int/bool/base.hpp>
00660 #include <gecode/int/bool/eq.hpp>
00661 #include <gecode/int/bool/lq.hpp>
00662 #include <gecode/int/bool/or.hpp>
00663 #include <gecode/int/bool/eqv.hpp>
00664 #include <gecode/int/bool/clause.hpp>
00665 #include <gecode/int/bool/ite.hpp>
00666
00667 #endif
00668
00669
00670