Generated on Mon Nov 30 23:53:27 2009 for Gecode by doxygen 1.6.1

linear.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Guido Tack <tack@gecode.org>
00006  *     Tias Guns <tias.guns@cs.kuleuven.be>
00007  *
00008  *  Copyright:
00009  *     Christian Schulte, 2002
00010  *     Guido Tack, 2004
00011  *     Tias Guns, 2009
00012  *
00013  *  Last modified:
00014  *     $Date: 2009-10-20 11:15:31 +0200 (Tue, 20 Oct 2009) $ by $Author: schulte $
00015  *     $Revision: 9973 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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    * Binary propagators
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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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    * Ternary propagators
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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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    * n-ary propagators
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<Val,P,N,pc>& p);
00507     Lin(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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(Home 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    * Boolean linear propagators
00771    *
00772    */
00773 
00778   template<class VX>
00779   class LinBoolInt : public Propagator {
00780   protected:
00782     Council<Advisor> co;
00784     ViewArray<VX> x;
00786     int n_as;
00788     int n_hs;
00790     int c;
00792     void normalize(void);
00794     LinBoolInt(Space& home, bool share, LinBoolInt& p);
00796     LinBoolInt(Home home, ViewArray<VX>& x, int n_s, int c);
00797   public:
00799     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00801     virtual size_t dispose(Space& home);
00802   };
00803 
00810   template<class VX>
00811   class EqBoolInt : public LinBoolInt<VX> {
00812   protected:
00813     using LinBoolInt<VX>::co;
00814     using LinBoolInt<VX>::x;
00815     using LinBoolInt<VX>::n_as;
00816     using LinBoolInt<VX>::n_hs;
00817     using LinBoolInt<VX>::c;
00819     EqBoolInt(Space& home, bool share, EqBoolInt& p);
00821     EqBoolInt(Home home, ViewArray<VX>& x, int c);
00822   public:
00824     virtual Actor* copy(Space& home, bool share);
00826     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00828     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00830     static ExecStatus post(Home home, ViewArray<VX>& x, int c);
00831   };
00832 
00839   template<class VX>
00840   class GqBoolInt : public LinBoolInt<VX> {
00841   protected:
00842     using LinBoolInt<VX>::co;
00843     using LinBoolInt<VX>::x;
00844     using LinBoolInt<VX>::n_as;
00845     using LinBoolInt<VX>::n_hs;
00846     using LinBoolInt<VX>::c;
00848     GqBoolInt(Space& home, bool share, GqBoolInt& p);
00850     GqBoolInt(Home home, ViewArray<VX>& x, int c);
00851   public:
00853     virtual Actor* copy(Space& home, bool share);
00855     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00857     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00859     static ExecStatus post(Home home, ViewArray<VX>& x, int c);
00860   };
00861 
00868   template<class VX>
00869   class NqBoolInt : public BinaryPropagator<VX,PC_INT_VAL> {
00870   protected:
00871     using BinaryPropagator<VX,PC_INT_VAL>::x0;
00872     using BinaryPropagator<VX,PC_INT_VAL>::x1;
00874     ViewArray<VX> x;
00876     int c;
00878     bool resubscribe(Space& home, VX& y);
00880     NqBoolInt(Home home,  ViewArray<VX>& b, int c);
00882     NqBoolInt(Space& home, bool share, NqBoolInt<VX>& p);
00883   public:
00885     virtual Actor* copy(Space& home, bool share);
00887     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00889     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00891     static  ExecStatus post(Home home, ViewArray<VX>& b, int c);
00893     virtual size_t dispose(Space& home);
00894   };
00895 
00896 
00901   template<class VX, class VB>
00902   class ReLinBoolInt : public Propagator {
00903   protected:
00905     Council<Advisor> co;
00907     ViewArray<VX> x;
00909     int n_s;
00911     int c;
00913     VB b;
00915     void normalize(void);
00917     ReLinBoolInt(Space& home, bool share, ReLinBoolInt& p);
00919     ReLinBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
00920   public:
00922     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00924     virtual size_t dispose(Space& home);
00925   };
00926 
00927 
00931   template<class BV>
00932   class BoolNegTraits {};
00933 
00940   template<class VX, class VB>
00941   class ReGqBoolInt : public ReLinBoolInt<VX,VB> {
00942   protected:
00943     using ReLinBoolInt<VX,VB>::co;
00944     using ReLinBoolInt<VX,VB>::x;
00945     using ReLinBoolInt<VX,VB>::c;
00946     using ReLinBoolInt<VX,VB>::b;
00947     using ReLinBoolInt<VX,VB>::n_s;
00948     using ReLinBoolInt<VX,VB>::normalize;
00950     ReGqBoolInt(Space& home, bool share, ReGqBoolInt& p);
00952     ReGqBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
00953   public:
00955     virtual Actor* copy(Space& home, bool share);
00957     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00959     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00961     static ExecStatus post(Home home, ViewArray<VX>& x, int c, VB b);
00962   };
00963 
00970   template<class VX, class VB>
00971   class ReEqBoolInt : public ReLinBoolInt<VX,VB> {
00972   protected:
00973     using ReLinBoolInt<VX,VB>::co;
00974     using ReLinBoolInt<VX,VB>::x;
00975     using ReLinBoolInt<VX,VB>::c;
00976     using ReLinBoolInt<VX,VB>::b;
00977     using ReLinBoolInt<VX,VB>::n_s;
00978     using ReLinBoolInt<VX,VB>::normalize;
00980     ReEqBoolInt(Space& home, bool share, ReEqBoolInt& p);
00982     ReEqBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
00983   public:
00985     virtual Actor* copy(Space& home, bool share);
00987     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00989     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00991     static ExecStatus post(Home home, ViewArray<VX>& x, int c, VB b);
00992   };
00993 
00994 }}}
00995 
00996 #include <gecode/int/linear/bool-int.hpp>
00997 
00998 namespace Gecode { namespace Int { namespace Linear {
00999 
01004   template<class XV, class YV>
01005   class LinBoolView : public Propagator {
01006   protected:
01008     ViewArray<XV> x;
01010     YV y;
01012     int c;
01014     LinBoolView(Space& home, bool share, LinBoolView& p);
01016     LinBoolView(Home home, ViewArray<XV>& x, YV y, int c);
01017   public:
01019     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
01021     virtual size_t dispose(Space& home);
01022   };
01023 
01024 
01029   template<class XV, class YV, class BV>
01030   class ReLinBoolView : public LinBoolView<XV,YV> {
01031   protected:
01032     using LinBoolView<XV,YV>::x;
01033     using LinBoolView<XV,YV>::y;
01034     using LinBoolView<XV,YV>::c;
01036     BV b;
01038     ReLinBoolView(Space& home, bool share, ReLinBoolView& p);
01040     ReLinBoolView(Home home, ViewArray<XV>& x, YV y, int c, BV b);
01041   public:
01043     virtual size_t dispose(Space& home);
01044   };
01045 
01046 
01053   template<class XV, class YV>
01054   class EqBoolView : public LinBoolView<XV,YV> {
01055   protected:
01056     using LinBoolView<XV,YV>::x;
01057     using LinBoolView<XV,YV>::y;
01058     using LinBoolView<XV,YV>::c;
01059 
01061     EqBoolView(Space& home, bool share, EqBoolView& p);
01063     EqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
01064   public:
01066     virtual Actor* copy(Space& home, bool share);
01068     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01070     static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
01071   };
01072 
01079   template<class XV, class YV>
01080   class NqBoolView : public LinBoolView<XV,YV> {
01081   protected:
01082     using LinBoolView<XV,YV>::x;
01083     using LinBoolView<XV,YV>::y;
01084     using LinBoolView<XV,YV>::c;
01085 
01087     NqBoolView(Space& home, bool share, NqBoolView& p);
01089     NqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
01090   public:
01092     virtual Actor* copy(Space& home, bool share);
01094     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01096     static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
01097   };
01098 
01105   template<class XV, class YV>
01106   class GqBoolView : public LinBoolView<XV,YV> {
01107   protected:
01108     using LinBoolView<XV,YV>::x;
01109     using LinBoolView<XV,YV>::y;
01110     using LinBoolView<XV,YV>::c;
01111 
01113     GqBoolView(Space& home, bool share, GqBoolView& p);
01115     GqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
01116   public:
01118     virtual Actor* copy(Space& home, bool share);
01120     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01122     static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
01123   };
01124 
01131   template<class XV, class YV, class BV>
01132   class ReEqBoolView : public ReLinBoolView<XV,YV,BV> {
01133   protected:
01134     using ReLinBoolView<XV,YV,BV>::x;
01135     using ReLinBoolView<XV,YV,BV>::y;
01136     using ReLinBoolView<XV,YV,BV>::c;
01137     using ReLinBoolView<XV,YV,BV>::b;
01138 
01140     ReEqBoolView(Space& home, bool share, ReEqBoolView& p);
01142     ReEqBoolView(Home home, ViewArray<XV>& x, YV y, int c, BV b);
01143   public:
01145     virtual Actor* copy(Space& home, bool share);
01147     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01149     static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c, BV b);
01150   };
01151 
01158   template<class XV, class YV, class BV>
01159   class ReGqBoolView : public ReLinBoolView<XV,YV,BV> {
01160   protected:
01161     using ReLinBoolView<XV,YV,BV>::x;
01162     using ReLinBoolView<XV,YV,BV>::y;
01163     using ReLinBoolView<XV,YV,BV>::c;
01164     using ReLinBoolView<XV,YV,BV>::b;
01165 
01167     ReGqBoolView(Space& home, bool share, ReGqBoolView& p);
01169     ReGqBoolView(Home home, ViewArray<XV>& x, YV y, int c, BV b);
01170   public:
01172     virtual Actor* copy(Space& home, bool share);
01174     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01176     static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c, BV b);
01177   };
01178 
01179 }}}
01180 
01181 #include <gecode/int/linear/bool-view.hpp>
01182 
01183 namespace Gecode { namespace Int { namespace Linear {
01184 
01186   class ScaleBool {
01187   public:
01189     int      a;
01191     BoolView x;
01192   };
01193 
01195   class ScaleBoolArray {
01196   private:
01198     ScaleBool* _fst;
01200     ScaleBool* _lst;
01201   public:
01203     ScaleBoolArray(void);
01205     ScaleBoolArray(Space& home, int n);
01207     void subscribe(Space& home, Propagator& p);
01209     void cancel(Space& home, Propagator& p);
01211     void update(Space& home, bool share, ScaleBoolArray& sba);
01213     ScaleBool* fst(void) const;
01215     ScaleBool* lst(void) const;
01217     void fst(ScaleBool* f);
01219     void lst(ScaleBool* l);
01221     bool empty(void) const;
01223     int size(void) const;
01224   private:
01226     class ScaleDec {
01227     public:
01228       bool
01229       operator ()(const ScaleBool& x, const ScaleBool& y);
01230     };
01231   public:
01233     void sort(void);
01234   };
01235 
01236 
01238   class EmptyScaleBoolArray {
01239   public:
01241     EmptyScaleBoolArray(void);
01243     EmptyScaleBoolArray(Space& home, int n);
01245     void subscribe(Space& home, Propagator& p);
01247     void cancel(Space& home, Propagator& p);
01249     void update(Space& home, bool share, EmptyScaleBoolArray& esba);
01251     ScaleBool* fst(void) const;
01253     ScaleBool* lst(void) const;
01255     void fst(ScaleBool* f);
01257     void lst(ScaleBool* l);
01259     bool empty(void) const;
01261     int size(void) const;
01263     void sort(void);
01264   };
01265 
01266 
01271   template<class SBAP, class SBAN, class VX, PropCond pcx>
01272   class LinBoolScale : public Propagator {
01273   protected:
01275     SBAP p;
01277     SBAN n;
01279     VX   x;
01281     int  c;
01282   public:
01284     LinBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
01286     LinBoolScale(Space& home, bool share, Propagator& pr,
01287                  SBAP& p, SBAN& n, VX x, int c);
01289     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
01291     virtual size_t dispose(Space& home);
01292   };
01293 
01300   template<class SBAP, class SBAN, class VX>
01301   class EqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
01302   protected:
01303     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::p;
01304     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::n;
01305     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::x;
01306     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::c;
01307   public:
01309     EqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
01311     EqBoolScale(Space& home, bool share, Propagator& pr,
01312                 SBAP& p, SBAN& n, VX x, int c);
01314     virtual Actor* copy(Space& home, bool share);
01316     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01318     static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
01319   };
01320 
01327   template<class SBAP, class SBAN, class VX>
01328   class LqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
01329   protected:
01330     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::p;
01331     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::n;
01332     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::x;
01333     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::c;
01334   public:
01336     LqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
01338     LqBoolScale(Space& home, bool share, Propagator& pr,
01339                 SBAP& p, SBAN& n, VX x, int c);
01341     virtual Actor* copy(Space& home, bool share);
01343     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01345     static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
01346   };
01347 
01354   template<class SBAP, class SBAN, class VX>
01355   class NqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL> {
01356   protected:
01357     using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::p;
01358     using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::n;
01359     using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::x;
01360     using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::c;
01361   public:
01363     NqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
01365     NqBoolScale(Space& home, bool share, Propagator& pr,
01366                 SBAP& p, SBAN& n, VX x, int c);
01368     virtual Actor* copy(Space& home, bool share);
01370     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01372     static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
01373   };
01374 
01375 }}}
01376 
01377 #include <gecode/int/linear/bool-scale.hpp>
01378 
01379 namespace Gecode { namespace Int { namespace Linear {
01380 
01385   template<class View>
01386   class Term {
01387   public:
01389     int a;
01391     View x;
01392   };
01393 
01408   template<class View>
01409   void estimate(Term<View>* t, int n, int c,
01410                 int& l, int& u);
01411 
01433   template<class View>
01434   bool normalize(Term<View>* t, int &n,
01435                  Term<View>* &t_p, int &n_p,
01436                  Term<View>* &t_n, int &n_n);
01437 
01438 
01466   GECODE_INT_EXPORT void
01467   post(Home home, Term<IntView>* t, int n, IntRelType r, int c,
01468        IntConLevel=ICL_DEF);
01469 
01499   GECODE_INT_EXPORT void
01500   post(Home home, Term<IntView>* t, int n, IntRelType r, int c, BoolView b,
01501        IntConLevel=ICL_DEF);
01502 
01530   GECODE_INT_EXPORT void
01531   post(Home home, Term<BoolView>* t, int n, IntRelType r, int c,
01532        IntConLevel=ICL_DEF);
01533 
01562   GECODE_INT_EXPORT void
01563   post(Home home, Term<BoolView>* t, int n, IntRelType r, int c, BoolView b,
01564        IntConLevel=ICL_DEF);
01565 
01594   GECODE_INT_EXPORT void
01595   post(Home home, Term<BoolView>* t, int n, IntRelType r, IntView y, int c=0,
01596        IntConLevel=ICL_DEF);
01597 
01626   GECODE_INT_EXPORT void
01627   post(Home home, Term<BoolView>* t, int n, IntRelType r, IntView y,
01628        BoolView b, IntConLevel=ICL_DEF);
01629 
01630 }}}
01631 
01632 #include <gecode/int/linear/post.hpp>
01633 
01634 #endif
01635 
01636 // STATISTICS: int-prop