Generated on Fri Oct 19 11:24:55 2018 for Gecode by doxygen 1.6.3

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  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #ifndef __GECODE_INT_LINEAR_HH__
00039 #define __GECODE_INT_LINEAR_HH__
00040 
00041 #include <gecode/int.hh>
00042 
00048 namespace Gecode { namespace Int { namespace Linear {
00049 
00050   /*
00051    * Binary propagators
00052    *
00053    */
00054 
00064   template<class Val, class A, class B, PropCond pc>
00065   class LinBin : public Propagator {
00066   protected:
00068     A x0;
00070     B x1;
00072     Val c;
00074     LinBin(Space& home, LinBin& p);
00076     LinBin(Space& home, Propagator& p, A x0, B x1, Val c);
00078     LinBin(Home home, A x0, B x1, Val c);
00079   public:
00081     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00083     virtual void reschedule(Space& home);
00085     virtual size_t dispose(Space& home);
00086   };
00087 
00097   template<class Val, class A, class B, PropCond pc, class Ctrl>
00098   class ReLinBin : public Propagator {
00099   protected:
00101     A x0;
00103     B x1;
00105     Val c;
00107     Ctrl b;
00109     ReLinBin(Space& home, ReLinBin& p);
00111     ReLinBin(Home home, A x0, B x1, Val c, Ctrl b);
00112   public:
00114     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00116     virtual void reschedule(Space& home);
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, EqBin& p);
00143     EqBin(Home home, A x0, B x1, Val c);
00144   public:
00146     EqBin(Space& home, Propagator& p, A x0, B x1, Val c);
00148     virtual Actor* copy(Space& home);
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, ReifyMode rm>
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, ReEqBin& p);
00178     ReEqBin(Home home,A,B,Val,Ctrl);
00179   public:
00181     virtual Actor* copy(Space& home);
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, NqBin& p);
00210     NqBin(Home home, A x0, B x1, Val c);
00211   public:
00213     NqBin(Space& home, Propagator& p, A x0, B x1, Val c);
00215     virtual Actor* copy(Space& home);
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, LqBin& p);
00246     LqBin(Home home, A x0, B x1, Val c);
00247   public:
00249     LqBin(Space& home, Propagator& p, A x0, B x1, Val c);
00251     virtual Actor* copy(Space& home);
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, GqBin& p);
00280     GqBin(Home home, A x0, B x1, Val c);
00281   public:
00283     GqBin(Space& home, Propagator& p, A x0, B x1, Val c);
00285     virtual Actor* copy(Space& home);
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, ReifyMode rm>
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, ReLqBin& p);
00315     ReLqBin(Home home, A x0, B x1, Val c, BoolView b);
00316   public:
00318     virtual Actor* copy(Space& home);
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, LinTer& p);
00359     LinTer(Home home, A x0, B x1, C x2, Val c);
00361     LinTer(Space& home, 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 void reschedule(Space& home);
00368     virtual size_t dispose(Space& home);
00369   };
00370 
00383   template<class Val, class A, class B, class C>
00384   class EqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
00385   protected:
00386     using LinTer<Val,A,B,C,PC_INT_BND>::x0;
00387     using LinTer<Val,A,B,C,PC_INT_BND>::x1;
00388     using LinTer<Val,A,B,C,PC_INT_BND>::x2;
00389     using LinTer<Val,A,B,C,PC_INT_BND>::c;
00390 
00392     EqTer(Space& home, EqTer& p);
00394     EqTer(Home home, A x0, B x1, C x2, Val c);
00395   public:
00397     EqTer(Space& home, Propagator& p, A x0, B x1, C x2, Val c);
00399     virtual Actor* copy(Space& home);
00401     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00403     static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
00404   };
00405 
00418   template<class Val, class A, class B, class C>
00419   class NqTer : public LinTer<Val,A,B,C,PC_INT_VAL> {
00420   protected:
00421     using LinTer<Val,A,B,C,PC_INT_VAL>::x0;
00422     using LinTer<Val,A,B,C,PC_INT_VAL>::x1;
00423     using LinTer<Val,A,B,C,PC_INT_VAL>::x2;
00424     using LinTer<Val,A,B,C,PC_INT_VAL>::c;
00425 
00427     NqTer(Space& home, NqTer& p);
00429     NqTer(Home home, A x0, B x1, C x2, Val c);
00430   public:
00432     NqTer(Space& home, Propagator& p, A x0, B x1, C x2, Val c);
00434     virtual Actor* copy(Space& home);
00436     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00438     static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
00439   };
00440 
00453   template<class Val, class A, class B, class C>
00454   class LqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
00455   protected:
00456     using LinTer<Val,A,B,C,PC_INT_BND>::x0;
00457     using LinTer<Val,A,B,C,PC_INT_BND>::x1;
00458     using LinTer<Val,A,B,C,PC_INT_BND>::x2;
00459     using LinTer<Val,A,B,C,PC_INT_BND>::c;
00460 
00462     LqTer(Space& home, LqTer& p);
00464     LqTer(Home home, A x0, B x1, C x2, Val c);
00465   public:
00467     LqTer(Space& home, Propagator& p, A x0, B x1, C x2, Val c);
00469     virtual Actor* copy(Space& home);
00471     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00473     static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
00474   };
00475 
00476 }}}
00477 
00478 #include <gecode/int/linear/int-ter.hpp>
00479 
00480 namespace Gecode { namespace Int { namespace Linear {
00481 
00482   /*
00483    * n-ary propagators
00484    *
00485    */
00486 
00496   template<class Val, class P, class N, PropCond pc>
00497   class Lin : public Propagator {
00498   protected:
00500     ViewArray<P> x;
00502     ViewArray<N> y;
00504     Val c;
00505 
00507     Lin(Space& home, Lin<Val,P,N,pc>& p);
00509     Lin(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00510   public:
00512     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00514     virtual void reschedule(Space& home);
00516     virtual size_t dispose(Space& home);
00517   };
00518 
00528   template<class Val, class P, class N, PropCond pc, class Ctrl>
00529   class ReLin : public Lin<Val,P,N,pc> {
00530   protected:
00531     using Lin<Val,P,N,pc>::x;
00532     using Lin<Val,P,N,pc>::y;
00534     Ctrl b;
00536     ReLin(Space& home, ReLin& p);
00538     ReLin(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
00539   public:
00541     virtual void reschedule(Space& home);
00543     virtual size_t dispose(Space& home);
00544   };
00545 
00551   template<class Val, class View>
00552   void bounds_p(ModEventDelta med, ViewArray<View>& x,
00553                 Val& c, Val& sl, Val& su);
00554 
00560   template<class Val, class View>
00561   void bounds_n(ModEventDelta med, ViewArray<View>& y,
00562                 Val& c, Val& sl, Val& su);
00563 
00576   template<class Val, class P, class N>
00577   class Eq : public Lin<Val,P,N,PC_INT_BND> {
00578   protected:
00579     using Lin<Val,P,N,PC_INT_BND>::x;
00580     using Lin<Val,P,N,PC_INT_BND>::y;
00581     using Lin<Val,P,N,PC_INT_BND>::c;
00582 
00584     Eq(Space& home, Eq& p);
00585   public:
00587     Eq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00589     virtual Actor* copy(Space& home);
00591     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00593     static ExecStatus
00594     post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00595   };
00596 
00607   template<class Val, class View>
00608   class DomEq
00609     : public Lin<Val,View,View,PC_INT_DOM> {
00610   protected:
00611     using Lin<Val,View,View,PC_INT_DOM>::x;
00612     using Lin<Val,View,View,PC_INT_DOM>::y;
00613     using Lin<Val,View,View,PC_INT_DOM>::c;
00614 
00616     DomEq(Space& home, DomEq& p);
00617   public:
00619     DomEq(Home home, ViewArray<View>& x, ViewArray<View>& y, Val c);
00621     virtual Actor* copy(Space& home);
00628     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00630     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00632     static ExecStatus
00633     post(Home home, ViewArray<View>& x, ViewArray<View>& y, Val c);
00634   };
00635 
00648   template<class Val, class P, class N, class Ctrl, ReifyMode rm>
00649   class ReEq : public ReLin<Val,P,N,PC_INT_BND,Ctrl> {
00650   protected:
00651     using ReLin<Val,P,N,PC_INT_BND,Ctrl>::x;
00652     using ReLin<Val,P,N,PC_INT_BND,Ctrl>::y;
00653     using ReLin<Val,P,N,PC_INT_BND,Ctrl>::c;
00654     using ReLin<Val,P,N,PC_INT_BND,Ctrl>::b;
00655 
00657     ReEq(Space& home, ReEq& p);
00658   public:
00660     ReEq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
00662     virtual Actor* copy(Space& home);
00664     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00666     static ExecStatus
00667     post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
00668   };
00669 
00682   template<class Val, class P, class N>
00683   class Nq : public Lin<Val,P,N,PC_INT_VAL> {
00684   protected:
00685     using Lin<Val,P,N,PC_INT_VAL>::x;
00686     using Lin<Val,P,N,PC_INT_VAL>::y;
00687     using Lin<Val,P,N,PC_INT_VAL>::c;
00688 
00690     Nq(Space& home, Nq& p);
00691   public:
00693     Nq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00695     virtual Actor* copy(Space& home);
00697     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00699     static ExecStatus
00700     post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00701   };
00702 
00715   template<class Val, class P, class N>
00716   class Lq : public Lin<Val,P,N,PC_INT_BND> {
00717   protected:
00718     using Lin<Val,P,N,PC_INT_BND>::x;
00719     using Lin<Val,P,N,PC_INT_BND>::y;
00720     using Lin<Val,P,N,PC_INT_BND>::c;
00721 
00723     Lq(Space& home, Lq& p);
00724   public:
00726     Lq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00728     virtual Actor* copy(Space& home);
00730     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00732     static ExecStatus
00733     post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
00734   };
00735 
00748   template<class Val, class P, class N, ReifyMode rm>
00749   class ReLq : public ReLin<Val,P,N,PC_INT_BND,BoolView> {
00750   protected:
00751     using ReLin<Val,P,N,PC_INT_BND,BoolView>::x;
00752     using ReLin<Val,P,N,PC_INT_BND,BoolView>::y;
00753     using ReLin<Val,P,N,PC_INT_BND,BoolView>::c;
00754     using ReLin<Val,P,N,PC_INT_BND,BoolView>::b;
00755 
00757     ReLq(Space& home, ReLq& p);
00758   public:
00760     ReLq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
00762     virtual Actor* copy(Space& home);
00764     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00766     static ExecStatus
00767     post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
00768   };
00769 
00770 }}}
00771 
00772 #include <gecode/int/linear/int-nary.hpp>
00773 #include <gecode/int/linear/int-dom.hpp>
00774 
00775 namespace Gecode { namespace Int { namespace Linear {
00776 
00777   /*
00778    * Boolean linear propagators
00779    *
00780    */
00781 
00786   template<class VX>
00787   class LinBoolInt : public Propagator {
00788   protected:
00790     Council<Advisor> co;
00792     ViewArray<VX> x;
00794     int n_as;
00796     int n_hs;
00798     int c;
00800     void normalize(void);
00802     LinBoolInt(Space& home, LinBoolInt& p);
00804     LinBoolInt(Home home, ViewArray<VX>& x, int n_s, int c);
00805   public:
00807     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00809     virtual size_t dispose(Space& home);
00810   };
00811 
00818   template<class VX>
00819   class EqBoolInt : public LinBoolInt<VX> {
00820   protected:
00821     using LinBoolInt<VX>::co;
00822     using LinBoolInt<VX>::x;
00823     using LinBoolInt<VX>::n_as;
00824     using LinBoolInt<VX>::n_hs;
00825     using LinBoolInt<VX>::c;
00826     using LinBoolInt<VX>::disabled;
00828     EqBoolInt(Space& home, EqBoolInt& p);
00830     EqBoolInt(Home home, ViewArray<VX>& x, int c);
00831   public:
00833     virtual Actor* copy(Space& home);
00835     virtual void reschedule(Space& home);
00837     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00839     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00841     static ExecStatus post(Home home, ViewArray<VX>& x, int c);
00842   };
00843 
00850   template<class VX>
00851   class GqBoolInt : public LinBoolInt<VX> {
00852   protected:
00853     using LinBoolInt<VX>::co;
00854     using LinBoolInt<VX>::x;
00855     using LinBoolInt<VX>::n_as;
00856     using LinBoolInt<VX>::n_hs;
00857     using LinBoolInt<VX>::c;
00858     using LinBoolInt<VX>::disabled;
00860     GqBoolInt(Space& home, GqBoolInt& p);
00862     GqBoolInt(Home home, ViewArray<VX>& x, int c);
00863   public:
00865     virtual Actor* copy(Space& home);
00867     virtual void reschedule(Space& home);
00869     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00871     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00873     static ExecStatus post(Home home, ViewArray<VX>& x, int c);
00874   };
00875 
00882   template<class VX>
00883   class NqBoolInt : public BinaryPropagator<VX,PC_INT_VAL> {
00884   protected:
00885     using BinaryPropagator<VX,PC_INT_VAL>::x0;
00886     using BinaryPropagator<VX,PC_INT_VAL>::x1;
00888     ViewArray<VX> x;
00890     int c;
00892     bool resubscribe(Space& home, VX& y);
00894     NqBoolInt(Home home,  ViewArray<VX>& b, int c);
00896     NqBoolInt(Space& home, NqBoolInt<VX>& p);
00897   public:
00899     virtual Actor* copy(Space& home);
00901     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00903     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00905     static  ExecStatus post(Home home, ViewArray<VX>& b, int c);
00907     virtual size_t dispose(Space& home);
00908   };
00909 
00910 
00915   template<class VX, class VB>
00916   class ReLinBoolInt : public Propagator {
00917   protected:
00919     Council<Advisor> co;
00921     ViewArray<VX> x;
00923     int n_s;
00925     int c;
00927     VB b;
00929     void normalize(void);
00931     ReLinBoolInt(Space& home, ReLinBoolInt& p);
00933     ReLinBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
00934   public:
00936     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00938     virtual size_t dispose(Space& home);
00939   };
00940 
00941 
00945   template<class BV>
00946   class BoolNegTraits {};
00947 
00954   template<class VX, class VB, ReifyMode rm>
00955   class ReGqBoolInt : public ReLinBoolInt<VX,VB> {
00956   protected:
00957     using ReLinBoolInt<VX,VB>::co;
00958     using ReLinBoolInt<VX,VB>::x;
00959     using ReLinBoolInt<VX,VB>::c;
00960     using ReLinBoolInt<VX,VB>::b;
00961     using ReLinBoolInt<VX,VB>::n_s;
00962     using ReLinBoolInt<VX,VB>::normalize;
00964     ReGqBoolInt(Space& home, ReGqBoolInt& p);
00966     ReGqBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
00967   public:
00969     virtual Actor* copy(Space& home);
00971     virtual void reschedule(Space& home);
00973     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00975     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00977     static ExecStatus post(Home home, ViewArray<VX>& x, int c, VB b);
00978   };
00979 
00986   template<class VX, class VB, ReifyMode rm>
00987   class ReEqBoolInt : public ReLinBoolInt<VX,VB> {
00988   protected:
00989     using ReLinBoolInt<VX,VB>::co;
00990     using ReLinBoolInt<VX,VB>::x;
00991     using ReLinBoolInt<VX,VB>::c;
00992     using ReLinBoolInt<VX,VB>::b;
00993     using ReLinBoolInt<VX,VB>::n_s;
00994     using ReLinBoolInt<VX,VB>::normalize;
00996     ReEqBoolInt(Space& home, ReEqBoolInt& p);
00998     ReEqBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
00999   public:
01001     virtual Actor* copy(Space& home);
01003     virtual void reschedule(Space& home);
01005     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
01007     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01009     static ExecStatus post(Home home, ViewArray<VX>& x, int c, VB b);
01010   };
01011 
01012 }}}
01013 
01014 #include <gecode/int/linear/bool-int.hpp>
01015 
01016 namespace Gecode { namespace Int { namespace Linear {
01017 
01022   template<class XV, class YV>
01023   class LinBoolView : public Propagator {
01024   protected:
01026     ViewArray<XV> x;
01028     YV y;
01030     int c;
01032     LinBoolView(Space& home, LinBoolView& p);
01034     LinBoolView(Home home, ViewArray<XV>& x, YV y, int c);
01035   public:
01037     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
01039     virtual void reschedule(Space& home);
01041     virtual size_t dispose(Space& home);
01042   };
01043 
01044 
01051   template<class XV, class YV>
01052   class EqBoolView : public LinBoolView<XV,YV> {
01053   protected:
01054     using LinBoolView<XV,YV>::x;
01055     using LinBoolView<XV,YV>::y;
01056     using LinBoolView<XV,YV>::c;
01057 
01059     EqBoolView(Space& home, EqBoolView& p);
01061     EqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
01062   public:
01064     virtual Actor* copy(Space& home);
01066     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01068     static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
01069   };
01070 
01077   template<class XV, class YV>
01078   class NqBoolView : public LinBoolView<XV,YV> {
01079   protected:
01080     using LinBoolView<XV,YV>::x;
01081     using LinBoolView<XV,YV>::y;
01082     using LinBoolView<XV,YV>::c;
01083 
01085     NqBoolView(Space& home, NqBoolView& p);
01087     NqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
01088   public:
01090     virtual Actor* copy(Space& home);
01092     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01094     static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
01095   };
01096 
01103   template<class XV, class YV>
01104   class GqBoolView : public LinBoolView<XV,YV> {
01105   protected:
01106     using LinBoolView<XV,YV>::x;
01107     using LinBoolView<XV,YV>::y;
01108     using LinBoolView<XV,YV>::c;
01109 
01111     GqBoolView(Space& home, GqBoolView& p);
01113     GqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
01114   public:
01116     virtual Actor* copy(Space& home);
01118     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01120     static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
01121   };
01122 
01123 }}}
01124 
01125 #include <gecode/int/linear/bool-view.hpp>
01126 
01127 namespace Gecode { namespace Int { namespace Linear {
01128 
01130   class ScaleBool {
01131   public:
01133     int      a;
01135     BoolView x;
01136   };
01137 
01139   class ScaleBoolArray {
01140   private:
01142     ScaleBool* _fst;
01144     ScaleBool* _lst;
01145   public:
01147     ScaleBoolArray(void);
01149     ScaleBoolArray(Space& home, int n);
01151     void subscribe(Space& home, Propagator& p);
01153     void cancel(Space& home, Propagator& p);
01155     void reschedule(Space& home, Propagator& p);
01157     void update(Space& home, ScaleBoolArray& sba);
01159     ScaleBool* fst(void) const;
01161     ScaleBool* lst(void) const;
01163     void fst(ScaleBool* f);
01165     void lst(ScaleBool* l);
01167     bool empty(void) const;
01169     int size(void) const;
01170   private:
01172     class ScaleDec {
01173     public:
01174       bool
01175       operator ()(const ScaleBool& x, const ScaleBool& y);
01176     };
01177   public:
01179     void sort(void);
01180   };
01181 
01182 
01184   class EmptyScaleBoolArray {
01185   public:
01187     EmptyScaleBoolArray(void);
01189     EmptyScaleBoolArray(Space& home, int n);
01191     void subscribe(Space& home, Propagator& p);
01193     void cancel(Space& home, Propagator& p);
01195     void reschedule(Space& home, Propagator& p);
01197     void update(Space& home, EmptyScaleBoolArray& esba);
01199     ScaleBool* fst(void) const;
01201     ScaleBool* lst(void) const;
01203     void fst(ScaleBool* f);
01205     void lst(ScaleBool* l);
01207     bool empty(void) const;
01209     int size(void) const;
01211     void sort(void);
01212   };
01213 
01214 
01219   template<class SBAP, class SBAN, class VX, PropCond pcx>
01220   class LinBoolScale : public Propagator {
01221   protected:
01223     SBAP p;
01225     SBAN n;
01227     VX   x;
01229     int  c;
01230   public:
01232     LinBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
01234     LinBoolScale(Space& home, Propagator& pr,
01235                  SBAP& p, SBAN& n, VX x, int c);
01237     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
01239     virtual void reschedule(Space& home);
01241     virtual size_t dispose(Space& home);
01242   };
01243 
01250   template<class SBAP, class SBAN, class VX>
01251   class EqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
01252   protected:
01253     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::p;
01254     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::n;
01255     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::x;
01256     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::c;
01257   public:
01259     EqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
01261     EqBoolScale(Space& home, Propagator& pr,
01262                 SBAP& p, SBAN& n, VX x, int c);
01264     virtual Actor* copy(Space& home);
01266     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01268     static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
01269   };
01270 
01277   template<class SBAP, class SBAN, class VX>
01278   class LqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
01279   protected:
01280     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::p;
01281     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::n;
01282     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::x;
01283     using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::c;
01284   public:
01286     LqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
01288     LqBoolScale(Space& home, Propagator& pr,
01289                 SBAP& p, SBAN& n, VX x, int c);
01291     virtual Actor* copy(Space& home);
01293     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01295     static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
01296   };
01297 
01304   template<class SBAP, class SBAN, class VX>
01305   class NqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL> {
01306   protected:
01307     using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::p;
01308     using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::n;
01309     using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::x;
01310     using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::c;
01311   public:
01313     NqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
01315     NqBoolScale(Space& home, Propagator& pr,
01316                 SBAP& p, SBAN& n, VX x, int c);
01318     virtual Actor* copy(Space& home);
01320     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
01322     static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
01323   };
01324 
01325 }}}
01326 
01327 #include <gecode/int/linear/bool-scale.hpp>
01328 
01329 namespace Gecode { namespace Int { namespace Linear {
01330 
01335   template<class View>
01336   class Term {
01337   public:
01339     int a;
01341     View x;
01342   };
01343 
01358   template<class View>
01359   void estimate(Term<View>* t, int n, int c,
01360                 int& l, int& u);
01361 
01389   GECODE_INT_EXPORT void
01390   post(Home home, Term<IntView>* t, int n, IntRelType irt, int c,
01391        IntPropLevel=IPL_DEF);
01392 
01422   GECODE_INT_EXPORT void
01423   post(Home home, Term<IntView>* t, int n, IntRelType irt, int c, Reify r,
01424        IntPropLevel=IPL_DEF);
01425 
01453   GECODE_INT_EXPORT void
01454   post(Home home, Term<BoolView>* t, int n, IntRelType irt, int c,
01455        IntPropLevel=IPL_DEF);
01456 
01485   GECODE_INT_EXPORT void
01486   post(Home home, Term<BoolView>* t, int n, IntRelType irt, int c, Reify r,
01487        IntPropLevel=IPL_DEF);
01488 
01517   GECODE_INT_EXPORT void
01518   post(Home home, Term<BoolView>* t, int n, IntRelType irt, IntView y, int c=0,
01519        IntPropLevel=IPL_DEF);
01520 
01549   GECODE_INT_EXPORT void
01550   post(Home home, Term<BoolView>* t, int n, IntRelType irt, IntView y,
01551        Reify r, IntPropLevel=IPL_DEF);
01552 
01553 }}}
01554 
01555 #include <gecode/int/linear/post.hpp>
01556 
01557 #endif
01558 
01559 // STATISTICS: int-prop