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
00041
00042 #ifndef __GECODE_INT_LINEAR_HH__
00043 #define __GECODE_INT_LINEAR_HH__
00044
00045 #include <gecode/int.hh>
00046
00052 namespace Gecode { namespace Int { namespace Linear {
00053
00054
00055
00056
00057
00058
00068 template <class Val, class A, class B, PropCond pc>
00069 class LinBin : public Propagator {
00070 protected:
00072 A x0;
00074 B x1;
00076 Val c;
00078 LinBin(Space& home, bool share, LinBin& p);
00080 LinBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
00082 LinBin(Space& home, A x0, B x1, Val c);
00083 public:
00085 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00087 virtual size_t dispose(Space& home);
00088 };
00089
00099 template <class Val, class A, class B, PropCond pc, class Ctrl>
00100 class ReLinBin : public Propagator {
00101 protected:
00103 A x0;
00105 B x1;
00107 Val c;
00109 Ctrl b;
00111 ReLinBin(Space& home, bool share, ReLinBin& p);
00113 ReLinBin(Space& home, A x0, B x1, Val c, Ctrl b);
00114 public:
00116 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00118 virtual size_t dispose(Space& home);
00119 };
00120
00133 template <class Val, class A, class B>
00134 class EqBin : public LinBin<Val,A,B,PC_INT_BND> {
00135 protected:
00136 using LinBin<Val,A,B,PC_INT_BND>::x0;
00137 using LinBin<Val,A,B,PC_INT_BND>::x1;
00138 using LinBin<Val,A,B,PC_INT_BND>::c;
00139
00141 EqBin(Space& home, bool share, EqBin& p);
00143 EqBin(Space& home, A x0, B x1, Val c);
00144 public:
00146 EqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
00148 virtual Actor* copy(Space& home, bool share);
00150 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00152 static ExecStatus post(Space& home, A x0, B x1, Val c);
00153 };
00154
00167 template <class Val, class A, class B, class Ctrl>
00168 class ReEqBin : public ReLinBin<Val,A,B,PC_INT_BND,Ctrl> {
00169 protected:
00170 using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::x0;
00171 using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::x1;
00172 using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::c;
00173 using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::b;
00174
00176 ReEqBin(Space& home, bool share, ReEqBin& p);
00178 ReEqBin(Space& home,A,B,Val,Ctrl);
00179 public:
00181 virtual Actor* copy(Space& home, bool share);
00183 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00185 static ExecStatus post(Space& home, A x0, B x1, Val c, Ctrl b);
00186 };
00187
00200 template <class Val, class A, class B>
00201 class NqBin : public LinBin<Val,A,B,PC_INT_VAL> {
00202 protected:
00203 using LinBin<Val,A,B,PC_INT_VAL>::x0;
00204 using LinBin<Val,A,B,PC_INT_VAL>::x1;
00205 using LinBin<Val,A,B,PC_INT_VAL>::c;
00206
00208 NqBin(Space& home, bool share, NqBin& p);
00210 NqBin(Space& home, A x0, B x1, Val c);
00211 public:
00213 NqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
00215 virtual Actor* copy(Space& home, bool share);
00217 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00219 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00221 static ExecStatus post(Space& home, A x0, B x1, Val c);
00222 };
00223
00236 template <class Val, class A, class B>
00237 class LqBin : public LinBin<Val,A,B,PC_INT_BND> {
00238 protected:
00239 using LinBin<Val,A,B,PC_INT_BND>::x0;
00240 using LinBin<Val,A,B,PC_INT_BND>::x1;
00241 using LinBin<Val,A,B,PC_INT_BND>::c;
00242
00244 LqBin(Space& home, bool share, LqBin& p);
00246 LqBin(Space& home, A x0, B x1, Val c);
00247 public:
00249 LqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
00251 virtual Actor* copy(Space& home, bool share);
00253 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00255 static ExecStatus post(Space& home, A x0, B x1, Val c);
00256 };
00257
00270 template <class Val, class A, class B>
00271 class GqBin : public LinBin<Val,A,B,PC_INT_BND> {
00272 protected:
00273 using LinBin<Val,A,B,PC_INT_BND>::x0;
00274 using LinBin<Val,A,B,PC_INT_BND>::x1;
00275 using LinBin<Val,A,B,PC_INT_BND>::c;
00276
00278 GqBin(Space& home, bool share, GqBin& p);
00280 GqBin(Space& home, A x0, B x1, Val c);
00281 public:
00283 GqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
00285 virtual Actor* copy(Space& home, bool share);
00287 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00289 static ExecStatus post(Space& home, A x0, B x1, Val c);
00290 };
00291
00304 template <class Val, class A, class B>
00305 class ReLqBin : public ReLinBin<Val,A,B,PC_INT_BND,BoolView> {
00306 protected:
00307 using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::x0;
00308 using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::x1;
00309 using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::c;
00310 using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::b;
00311
00313 ReLqBin(Space& home, bool share, ReLqBin& p);
00315 ReLqBin(Space& home, A x0, B x1, Val c, BoolView b);
00316 public:
00318 virtual Actor* copy(Space& home, bool share);
00320 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00322 static ExecStatus post(Space& home, A x0, B x1, Val c, BoolView b);
00323 };
00324
00325 }}}
00326
00327 #include <gecode/int/linear/int-bin.hpp>
00328
00329 namespace Gecode { namespace Int { namespace Linear {
00330
00331
00332
00333
00334
00335
00345 template <class Val, class A, class B, class C, PropCond pc>
00346 class LinTer : public Propagator {
00347 protected:
00349 A x0;
00351 B x1;
00353 C x2;
00355 Val c;
00357 LinTer(Space& home, bool share, LinTer& p);
00359 LinTer(Space& home, A x0, B x1, C x2, Val c);
00361 LinTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
00362 public:
00364 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00366 virtual size_t dispose(Space& home);
00367 };
00368
00381 template <class Val, class A, class B, class C>
00382 class EqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
00383 protected:
00384 using LinTer<Val,A,B,C,PC_INT_BND>::x0;
00385 using LinTer<Val,A,B,C,PC_INT_BND>::x1;
00386 using LinTer<Val,A,B,C,PC_INT_BND>::x2;
00387 using LinTer<Val,A,B,C,PC_INT_BND>::c;
00388
00390 EqTer(Space& home, bool share, EqTer& p);
00392 EqTer(Space& home, A x0, B x1, C x2, Val c);
00393 public:
00395 EqTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
00397 virtual Actor* copy(Space& home, bool share);
00399 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00401 static ExecStatus post(Space& home, A x0, B x1, C x2, Val c);
00402 };
00403
00416 template <class Val, class A, class B, class C>
00417 class NqTer : public LinTer<Val,A,B,C,PC_INT_VAL> {
00418 protected:
00419 using LinTer<Val,A,B,C,PC_INT_VAL>::x0;
00420 using LinTer<Val,A,B,C,PC_INT_VAL>::x1;
00421 using LinTer<Val,A,B,C,PC_INT_VAL>::x2;
00422 using LinTer<Val,A,B,C,PC_INT_VAL>::c;
00423
00425 NqTer(Space& home, bool share, NqTer& p);
00427 NqTer(Space& home, A x0, B x1, C x2, Val c);
00428 public:
00430 NqTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
00432 virtual Actor* copy(Space& home, bool share);
00434 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00436 static ExecStatus post(Space& home, A x0, B x1, C x2, Val c);
00437 };
00438
00451 template <class Val, class A, class B, class C>
00452 class LqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
00453 protected:
00454 using LinTer<Val,A,B,C,PC_INT_BND>::x0;
00455 using LinTer<Val,A,B,C,PC_INT_BND>::x1;
00456 using LinTer<Val,A,B,C,PC_INT_BND>::x2;
00457 using LinTer<Val,A,B,C,PC_INT_BND>::c;
00458
00460 LqTer(Space& home, bool share, LqTer& p);
00462 LqTer(Space& home, A x0, B x1, C x2, Val c);
00463 public:
00465 LqTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
00467 virtual Actor* copy(Space& home, bool share);
00469 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00471 static ExecStatus post(Space& home, A x0, B x1, C x2, Val c);
00472 };
00473
00474 }}}
00475
00476 #include <gecode/int/linear/int-ter.hpp>
00477
00478 namespace Gecode { namespace Int { namespace Linear {
00479
00480
00481
00482
00483
00484
00494 template <class Val, class P, class N, PropCond pc>
00495 class Lin : public Propagator {
00496 protected:
00498 ViewArray<P> x;
00500 ViewArray<N> y;
00502 Val c;
00503
00505 Lin(Space& home, bool share, Lin& p);
00507 Lin(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00508 public:
00510 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00512 virtual size_t dispose(Space& home);
00513 };
00514
00524 template <class Val, class P, class N, PropCond pc, class Ctrl>
00525 class ReLin : public Lin<Val,P,N,pc> {
00526 protected:
00528 Ctrl b;
00530 ReLin(Space& home, bool share, ReLin& p);
00532 ReLin(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
00533 public:
00535 virtual size_t dispose(Space& home);
00536 };
00537
00543 template <class Val, class View>
00544 void bounds_p(ModEventDelta med, ViewArray<View>& x,
00545 Val& c, Val& sl, Val& su);
00546
00552 template <class Val, class View>
00553 void bounds_n(ModEventDelta med, ViewArray<View>& y,
00554 Val& c, Val& sl, Val& su);
00555
00568 template <class Val, class P, class N>
00569 class Eq : public Lin<Val,P,N,PC_INT_BND> {
00570 protected:
00571 using Lin<Val,P,N,PC_INT_BND>::x;
00572 using Lin<Val,P,N,PC_INT_BND>::y;
00573 using Lin<Val,P,N,PC_INT_BND>::c;
00574
00576 Eq(Space& home, bool share, Eq& p);
00577 public:
00579 Eq(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00581 virtual Actor* copy(Space& home, bool share);
00583 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00585 static ExecStatus
00586 post(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00587 };
00588
00599 template <class Val, class View>
00600 class DomEq
00601 : public Lin<Val,View,View,PC_INT_DOM> {
00602 protected:
00603 using Lin<Val,View,View,PC_INT_DOM>::x;
00604 using Lin<Val,View,View,PC_INT_DOM>::y;
00605 using Lin<Val,View,View,PC_INT_DOM>::c;
00606
00608 DomEq(Space& home, bool share, DomEq& p);
00609 public:
00611 DomEq(Space& home, ViewArray<View>& x, ViewArray<View>& y, Val c);
00613 virtual Actor* copy(Space& home, bool share);
00620 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00622 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00624 static ExecStatus
00625 post(Space& home, ViewArray<View>& x, ViewArray<View>& y, Val c);
00626 };
00627
00640 template <class Val, class P, class N, class Ctrl>
00641 class ReEq : public ReLin<Val,P,N,PC_INT_BND,Ctrl> {
00642 protected:
00643 using ReLin<Val,P,N,PC_INT_BND,Ctrl>::x;
00644 using ReLin<Val,P,N,PC_INT_BND,Ctrl>::y;
00645 using ReLin<Val,P,N,PC_INT_BND,Ctrl>::c;
00646 using ReLin<Val,P,N,PC_INT_BND,Ctrl>::b;
00647
00649 ReEq(Space& home, bool share, ReEq& p);
00650 public:
00652 ReEq(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
00654 virtual Actor* copy(Space& home, bool share);
00656 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00658 static ExecStatus
00659 post(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
00660 };
00661
00674 template <class Val, class P, class N>
00675 class Nq : public Lin<Val,P,N,PC_INT_VAL> {
00676 protected:
00677 using Lin<Val,P,N,PC_INT_VAL>::x;
00678 using Lin<Val,P,N,PC_INT_VAL>::y;
00679 using Lin<Val,P,N,PC_INT_VAL>::c;
00680
00682 Nq(Space& home, bool share, Nq& p);
00683 public:
00685 Nq(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00687 virtual Actor* copy(Space& home, bool share);
00689 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00691 static ExecStatus
00692 post(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00693 };
00694
00707 template <class Val, class P, class N>
00708 class Lq : public Lin<Val,P,N,PC_INT_BND> {
00709 protected:
00710 using Lin<Val,P,N,PC_INT_BND>::x;
00711 using Lin<Val,P,N,PC_INT_BND>::y;
00712 using Lin<Val,P,N,PC_INT_BND>::c;
00713
00715 Lq(Space& home, bool share, Lq& p);
00716 public:
00718 Lq(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00720 virtual Actor* copy(Space& home, bool share);
00722 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00724 static ExecStatus
00725 post(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00726 };
00727
00740 template <class Val, class P, class N>
00741 class ReLq : public ReLin<Val,P,N,PC_INT_BND,BoolView> {
00742 protected:
00743 using ReLin<Val,P,N,PC_INT_BND,BoolView>::x;
00744 using ReLin<Val,P,N,PC_INT_BND,BoolView>::y;
00745 using ReLin<Val,P,N,PC_INT_BND,BoolView>::c;
00746 using ReLin<Val,P,N,PC_INT_BND,BoolView>::b;
00747
00749 ReLq(Space& home, bool share, ReLq& p);
00750 public:
00752 ReLq(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
00754 virtual Actor* copy(Space& home, bool share);
00756 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00758 static ExecStatus
00759 post(Space& home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
00760 };
00761
00762 }}}
00763
00764 #include <gecode/int/linear/int-nary.hpp>
00765 #include <gecode/int/linear/int-dom.hpp>
00766
00767 namespace Gecode { namespace Int { namespace Linear {
00768
00769
00770
00771
00772
00773
00778 template <class VX>
00779 class MemoryLinBoolInt : public Propagator {
00780 protected:
00782 ViewArray<VX> x;
00784 int n_s;
00786 int c;
00788 MemoryLinBoolInt(Space& home, bool share, MemoryLinBoolInt& p);
00790 MemoryLinBoolInt(Space& home, ViewArray<VX>& x, int n_s, int c);
00791 public:
00793 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00795 virtual size_t dispose(Space& home);
00796 };
00797
00802 template <class VX>
00803 class SpeedLinBoolInt : public Propagator {
00804 protected:
00806 ViewArray<VX> x;
00808 int n_s;
00810 int c;
00812 Council<ViewAdvisor<VX> > co;
00814 SpeedLinBoolInt(Space& home, bool share, SpeedLinBoolInt& p);
00816 SpeedLinBoolInt(Space& home, ViewArray<VX>& x, int n_s, int c);
00817 public:
00819 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00821 virtual size_t dispose(Space& home);
00822 };
00823
00830 template <class VX>
00831 class EqBoolInt {
00832 public:
00834 static const int threshold = 32;
00836 class Memory : public MemoryLinBoolInt<VX> {
00837 protected:
00838 using MemoryLinBoolInt<VX>::x;
00839 using MemoryLinBoolInt<VX>::n_s;
00840 using MemoryLinBoolInt<VX>::c;
00841 public:
00843 Memory(Space& home, bool share, Memory& p);
00845 Memory(Space& home, ViewArray<VX>& x, int c);
00847 virtual Actor* copy(Space& home, bool share);
00849 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00851 static ExecStatus post(Space& home, ViewArray<VX>& x, int c);
00852 };
00854 class Speed : public SpeedLinBoolInt<VX> {
00855 protected:
00856 using SpeedLinBoolInt<VX>::x;
00857 using SpeedLinBoolInt<VX>::n_s;
00858 using SpeedLinBoolInt<VX>::c;
00859 using SpeedLinBoolInt<VX>::co;
00860 public:
00862 Speed(Space& home, bool share, Speed& p);
00864 Speed(Space& home, ViewArray<VX>& x, int c);
00866 virtual Actor* copy(Space& home, bool share);
00868 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00870 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00871 };
00873 static ExecStatus post(Space& home, ViewArray<VX>& x, int c);
00874 };
00875
00882 template <class VX>
00883 class GqBoolInt {
00884 public:
00886 static const int threshold = 32;
00888 class Memory : public MemoryLinBoolInt<VX> {
00889 protected:
00890 using MemoryLinBoolInt<VX>::x;
00891 using MemoryLinBoolInt<VX>::n_s;
00892 using MemoryLinBoolInt<VX>::c;
00893 public:
00895 Memory(Space& home, bool share, Memory& p);
00897 Memory(Space& home, ViewArray<VX>& x, int c);
00899 virtual Actor* copy(Space& home, bool share);
00901 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00902 };
00904 class Speed : public SpeedLinBoolInt<VX> {
00905 protected:
00906 using SpeedLinBoolInt<VX>::x;
00907 using SpeedLinBoolInt<VX>::n_s;
00908 using SpeedLinBoolInt<VX>::c;
00909 using SpeedLinBoolInt<VX>::co;
00910 public:
00912 Speed(Space& home, bool share, Speed& p);
00914 Speed(Space& home, ViewArray<VX>& x, int c);
00916 virtual Actor* copy(Space& home, bool share);
00918 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00920 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00921 };
00922 public:
00924 static ExecStatus post(Space& home, ViewArray<VX>& x, int c);
00925 };
00926
00933 template<class VX>
00934 class NqBoolInt : public BinaryPropagator<VX,PC_INT_VAL> {
00935 protected:
00936 using BinaryPropagator<VX,PC_INT_VAL>::x0;
00937 using BinaryPropagator<VX,PC_INT_VAL>::x1;
00939 ViewArray<VX> x;
00941 int c;
00943 bool resubscribe(Space& home, VX& y);
00945 NqBoolInt(Space& home, ViewArray<VX>& b, int c);
00947 NqBoolInt(Space& home, bool share, NqBoolInt<VX>& p);
00948 public:
00950 virtual Actor* copy(Space& home, bool share);
00952 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00954 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00956 static ExecStatus post(Space& home, ViewArray<VX>& b, int c);
00957 };
00958
00959
00960
00961
00962
00963
00964
00969 template <class VX, class VB>
00970 class MemoryReLinBoolInt : public MemoryLinBoolInt<VX> {
00971 protected:
00972 using MemoryLinBoolInt<VX>::x;
00973 using MemoryLinBoolInt<VX>::n_s;
00974 using MemoryLinBoolInt<VX>::c;
00976 VB b;
00978 MemoryReLinBoolInt(Space& home, bool share, MemoryReLinBoolInt& p);
00980 MemoryReLinBoolInt(Space& home, ViewArray<VX>& x, int n_s, int c, VB b);
00981 public:
00983 virtual size_t dispose(Space& home);
00984 };
00985
00990 template <class VX, class VB>
00991 class SpeedReLinBoolInt : public SpeedLinBoolInt<VX> {
00992 protected:
00993 using SpeedLinBoolInt<VX>::x;
00994 using SpeedLinBoolInt<VX>::n_s;
00995 using SpeedLinBoolInt<VX>::c;
00996 using SpeedLinBoolInt<VX>::co;
00998 VB b;
01000 SpeedReLinBoolInt(Space& home, bool share, SpeedReLinBoolInt& p);
01002 SpeedReLinBoolInt(Space& home, ViewArray<VX>& x, int n_s, int c, VB b);
01003 public:
01005 virtual size_t dispose(Space& home);
01006 };
01007
01008
01009
01010
01017 template <class VX, class VB>
01018 class ReGqBoolInt {
01019 public:
01021 static const int threshold = 32;
01023 class Memory : public MemoryReLinBoolInt<VX,VB> {
01024 protected:
01025 using MemoryReLinBoolInt<VX,VB>::x;
01026 using MemoryReLinBoolInt<VX,VB>::n_s;
01027 using MemoryReLinBoolInt<VX,VB>::c;
01028 using MemoryReLinBoolInt<VX,VB>::b;
01029 public:
01031 Memory(Space& home, bool share, Memory& p);
01033 Memory(Space& home, ViewArray<VX>& x, int c, VB b);
01035 virtual Actor* copy(Space& home, bool share);
01037 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01039 ExecStatus rewrite_inverse(Space& home, ViewArray<BoolView>& x, int c);
01041 ExecStatus rewrite_inverse(Space& home, ViewArray<NegBoolView>& x, int c);
01042 };
01044 class Speed : public SpeedReLinBoolInt<VX,VB> {
01045 protected:
01046 using SpeedReLinBoolInt<VX,VB>::x;
01047 using SpeedReLinBoolInt<VX,VB>::n_s;
01048 using SpeedReLinBoolInt<VX,VB>::c;
01049 using SpeedReLinBoolInt<VX,VB>::co;
01050 using SpeedReLinBoolInt<VX,VB>::b;
01051 public:
01053 Speed(Space& home, bool share, Speed& p);
01055 Speed(Space& home, ViewArray<VX>& x, int c, VB b);
01057 virtual Actor* copy(Space& home, bool share);
01059 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
01061 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01063 ExecStatus rewrite_inverse(Space& home, ViewArray<BoolView>& x, int c);
01065 ExecStatus rewrite_inverse(Space& home, ViewArray<NegBoolView>& x, int c);
01066 };
01067 public:
01069 static ExecStatus post(Space& home, ViewArray<VX>& x, int c, VB b);
01070 };
01071
01078 template <class VX, class VB>
01079 class ReEqBoolInt {
01080 public:
01082 static const int threshold = 32;
01084 class Memory : public MemoryReLinBoolInt<VX,VB> {
01085 protected:
01086 using MemoryReLinBoolInt<VX,VB>::x;
01087 using MemoryReLinBoolInt<VX,VB>::n_s;
01088 using MemoryReLinBoolInt<VX,VB>::c;
01089 using MemoryReLinBoolInt<VX,VB>::b;
01090 public:
01092 Memory(Space& home, bool share, Memory& p);
01094 Memory(Space& home, ViewArray<VX>& x, int c, VB b);
01096 virtual Actor* copy(Space& home, bool share);
01098 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01099 };
01101 class Speed : public SpeedReLinBoolInt<VX,VB> {
01102 protected:
01103 using SpeedReLinBoolInt<VX,VB>::x;
01104 using SpeedReLinBoolInt<VX,VB>::n_s;
01105 using SpeedReLinBoolInt<VX,VB>::c;
01106 using SpeedReLinBoolInt<VX,VB>::co;
01107 using SpeedReLinBoolInt<VX,VB>::b;
01108 public:
01110 Speed(Space& home, bool share, Speed& p);
01112 Speed(Space& home, ViewArray<VX>& x, int c, VB b);
01114 virtual Actor* copy(Space& home, bool share);
01116 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
01118 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01119 };
01121 static ExecStatus post(Space& home, ViewArray<VX>& x, int c, VB b);
01122 };
01123
01124 }}}
01125
01126 #include <gecode/int/linear/bool-int.hpp>
01127
01128 namespace Gecode { namespace Int { namespace Linear {
01129
01134 template <class XV, class YV>
01135 class LinBoolView : public Propagator {
01136 protected:
01138 ViewArray<XV> x;
01140 YV y;
01142 int c;
01144 LinBoolView(Space& home, bool share, LinBoolView& p);
01146 LinBoolView(Space& home, ViewArray<XV>& x, YV y, int c);
01147 public:
01149 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
01151 virtual size_t dispose(Space& home);
01152 };
01153
01154
01159 template <class XV, class YV, class BV>
01160 class ReLinBoolView : public LinBoolView<XV,YV> {
01161 protected:
01162 using LinBoolView<XV,YV>::x;
01163 using LinBoolView<XV,YV>::y;
01164 using LinBoolView<XV,YV>::c;
01166 BV b;
01168 ReLinBoolView(Space& home, bool share, ReLinBoolView& p);
01170 ReLinBoolView(Space& home, ViewArray<XV>& x, YV y, int c, BV b);
01171 public:
01173 virtual size_t dispose(Space& home);
01174 };
01175
01176
01183 template <class XV, class YV>
01184 class EqBoolView : public LinBoolView<XV,YV> {
01185 protected:
01186 using LinBoolView<XV,YV>::x;
01187 using LinBoolView<XV,YV>::y;
01188 using LinBoolView<XV,YV>::c;
01189
01191 EqBoolView(Space& home, bool share, EqBoolView& p);
01193 EqBoolView(Space& home, ViewArray<XV>& x, YV y, int c);
01194 public:
01196 virtual Actor* copy(Space& home, bool share);
01198 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01200 static ExecStatus post(Space& home, ViewArray<XV>& x, YV y, int c);
01201 };
01202
01209 template <class XV, class YV>
01210 class NqBoolView : public LinBoolView<XV,YV> {
01211 protected:
01212 using LinBoolView<XV,YV>::x;
01213 using LinBoolView<XV,YV>::y;
01214 using LinBoolView<XV,YV>::c;
01215
01217 NqBoolView(Space& home, bool share, NqBoolView& p);
01219 NqBoolView(Space& home, ViewArray<XV>& x, YV y, int c);
01220 public:
01222 virtual Actor* copy(Space& home, bool share);
01224 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01226 static ExecStatus post(Space& home, ViewArray<XV>& x, YV y, int c);
01227 };
01228
01235 template <class XV, class YV>
01236 class GqBoolView : public LinBoolView<XV,YV> {
01237 protected:
01238 using LinBoolView<XV,YV>::x;
01239 using LinBoolView<XV,YV>::y;
01240 using LinBoolView<XV,YV>::c;
01241
01243 GqBoolView(Space& home, bool share, GqBoolView& p);
01245 GqBoolView(Space& home, ViewArray<XV>& x, YV y, int c);
01246 public:
01248 virtual Actor* copy(Space& home, bool share);
01250 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01252 static ExecStatus post(Space& home, ViewArray<XV>& x, YV y, int c);
01253 };
01254
01261 template <class XV, class YV, class BV>
01262 class ReEqBoolView : public ReLinBoolView<XV,YV,BV> {
01263 protected:
01264 using ReLinBoolView<XV,YV,BV>::x;
01265 using ReLinBoolView<XV,YV,BV>::y;
01266 using ReLinBoolView<XV,YV,BV>::c;
01267 using ReLinBoolView<XV,YV,BV>::b;
01268
01270 ReEqBoolView(Space& home, bool share, ReEqBoolView& p);
01272 ReEqBoolView(Space& home, ViewArray<XV>& x, YV y, int c, BV b);
01273 public:
01275 virtual Actor* copy(Space& home, bool share);
01277 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01279 static ExecStatus post(Space& home, ViewArray<XV>& x, YV y, int c, BV b);
01280 };
01281
01288 template <class XV, class YV, class BV>
01289 class ReGqBoolView : public ReLinBoolView<XV,YV,BV> {
01290 protected:
01291 using ReLinBoolView<XV,YV,BV>::x;
01292 using ReLinBoolView<XV,YV,BV>::y;
01293 using ReLinBoolView<XV,YV,BV>::c;
01294 using ReLinBoolView<XV,YV,BV>::b;
01295
01297 ReGqBoolView(Space& home, bool share, ReGqBoolView& p);
01299 ReGqBoolView(Space& home, ViewArray<XV>& x, YV y, int c, BV b);
01300 public:
01302 virtual Actor* copy(Space& home, bool share);
01304 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01306 static ExecStatus post(Space& home, ViewArray<XV>& x, YV y, int c, BV b);
01307 };
01308
01309 }}}
01310
01311 #include <gecode/int/linear/bool-view.hpp>
01312
01313 namespace Gecode { namespace Int { namespace Linear {
01314
01316 class ScaleBool {
01317 public:
01319 int a;
01321 BoolView x;
01322 };
01323
01325 class ScaleBoolArray {
01326 private:
01328 ScaleBool* _fst;
01330 ScaleBool* _lst;
01331 public:
01333 ScaleBoolArray(void);
01335 ScaleBoolArray(Space& home, int n);
01337 void subscribe(Space& home, Propagator& p);
01339 void cancel(Space& home, Propagator& p);
01341 void update(Space& home, bool share, ScaleBoolArray& sba);
01343 ScaleBool* fst(void) const;
01345 ScaleBool* lst(void) const;
01347 void fst(ScaleBool* f);
01349 void lst(ScaleBool* l);
01351 bool empty(void) const;
01353 int size(void) const;
01354 private:
01356 class ScaleDec {
01357 public:
01358 bool
01359 operator ()(const ScaleBool& x, const ScaleBool& y);
01360 };
01361 public:
01363 void sort(void);
01364 };
01365
01366
01368 class EmptyScaleBoolArray {
01369 public:
01371 EmptyScaleBoolArray(void);
01373 EmptyScaleBoolArray(Space& home, int n);
01375 void subscribe(Space& home, Propagator& p);
01377 void cancel(Space& home, Propagator& p);
01379 void update(Space& home, bool share, EmptyScaleBoolArray& esba);
01381 ScaleBool* fst(void) const;
01383 ScaleBool* lst(void) const;
01385 void fst(ScaleBool* f);
01387 void lst(ScaleBool* l);
01389 bool empty(void) const;
01391 int size(void) const;
01393 void sort(void);
01394 };
01395
01396
01401 template <class SBAP, class SBAN, class VX, PropCond pcx>
01402 class LinBoolScale : public Propagator {
01403 protected:
01405 SBAP p;
01407 SBAN n;
01409 VX x;
01411 int c;
01412 public:
01414 LinBoolScale(Space& home, SBAP& p, SBAN& n, VX x, int c);
01416 LinBoolScale(Space& home, bool share, Propagator& pr,
01417 SBAP& p, SBAN& n, VX x, int c);
01419 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
01421 virtual size_t dispose(Space& home);
01422 };
01423
01430 template <class SBAP, class SBAN, class VX>
01431 class EqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
01432 protected:
01433 using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::p;
01434 using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::n;
01435 using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::x;
01436 using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::c;
01437 public:
01439 EqBoolScale(Space& home, SBAP& p, SBAN& n, VX x, int c);
01441 EqBoolScale(Space& home, bool share, Propagator& pr,
01442 SBAP& p, SBAN& n, VX x, int c);
01444 virtual Actor* copy(Space& home, bool share);
01446 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01448 static ExecStatus post(Space& home, SBAP& p, SBAN& n, VX x, int c);
01449 };
01450
01457 template <class SBAP, class SBAN, class VX>
01458 class LqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
01459 protected:
01460 using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::p;
01461 using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::n;
01462 using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::x;
01463 using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::c;
01464 public:
01466 LqBoolScale(Space& home, SBAP& p, SBAN& n, VX x, int c);
01468 LqBoolScale(Space& home, bool share, Propagator& pr,
01469 SBAP& p, SBAN& n, VX x, int c);
01471 virtual Actor* copy(Space& home, bool share);
01473 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01475 static ExecStatus post(Space& home, SBAP& p, SBAN& n, VX x, int c);
01476 };
01477
01484 template <class SBAP, class SBAN, class VX>
01485 class NqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL> {
01486 protected:
01487 using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::p;
01488 using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::n;
01489 using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::x;
01490 using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::c;
01491 public:
01493 NqBoolScale(Space& home, SBAP& p, SBAN& n, VX x, int c);
01495 NqBoolScale(Space& home, bool share, Propagator& pr,
01496 SBAP& p, SBAN& n, VX x, int c);
01498 virtual Actor* copy(Space& home, bool share);
01500 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01502 static ExecStatus post(Space& home, SBAP& p, SBAN& n, VX x, int c);
01503 };
01504
01505 }}}
01506
01507 #include <gecode/int/linear/bool-scale.hpp>
01508
01509 namespace Gecode { namespace Int { namespace Linear {
01510
01515 template<class View>
01516 class Term {
01517 public:
01519 int a;
01521 View x;
01522 };
01523
01538 template<class View>
01539 void estimate(Term<View>* t, int n, int c,
01540 int& l, int& u);
01541
01563 template<class View>
01564 bool normalize(Term<View>* t, int &n,
01565 Term<View>* &t_p, int &n_p,
01566 Term<View>* &t_n, int &n_n);
01567
01568
01595 GECODE_INT_EXPORT void
01596 post(Space& home, Term<IntView>* t, int n, IntRelType r, int c,
01597 IntConLevel=ICL_DEF);
01598
01627 GECODE_INT_EXPORT void
01628 post(Space& home, Term<IntView>* t, int n, IntRelType r, int c, BoolView b,
01629 IntConLevel=ICL_DEF);
01630
01657 GECODE_INT_EXPORT void
01658 post(Space& home, Term<BoolView>* t, int n, IntRelType r, int c,
01659 IntConLevel=ICL_DEF);
01660
01688 GECODE_INT_EXPORT void
01689 post(Space& home, Term<BoolView>* t, int n, IntRelType r, int c, BoolView b,
01690 IntConLevel=ICL_DEF);
01691
01719 GECODE_INT_EXPORT void
01720 post(Space& home, Term<BoolView>* t, int n, IntRelType r, IntView y, int c=0,
01721 IntConLevel=ICL_DEF);
01722
01750 GECODE_INT_EXPORT void
01751 post(Space& home, Term<BoolView>* t, int n, IntRelType r, IntView y,
01752 BoolView b, IntConLevel=ICL_DEF);
01753
01754 }}}
01755
01756 #include <gecode/int/linear/post.hpp>
01757
01758 #endif
01759
01760