Generated on Wed Nov 1 15:04:31 2006 for Gecode by doxygen 1.4.5

count.hh

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2002
00008  *     Guido Tack, 2004
00009  *
00010  *  Last modified:
00011  *     $Date: 2006-09-19 16:52:16 +0200 (Tue, 19 Sep 2006) $ by $Author: schulte $
00012  *     $Revision: 3684 $
00013  *
00014  *  This file is part of Gecode, the generic constraint
00015  *  development environment:
00016  *     http://www.gecode.org
00017  *
00018  *  See the file "LICENSE" for information on usage and
00019  *  redistribution of this file, and for a
00020  *     DISCLAIMER OF ALL WARRANTIES.
00021  *
00022  */
00023 
00024 #ifndef __GECODE_INT_COUNT_HH__
00025 #define __GECODE_INT_COUNT_HH__
00026 
00027 #include "gecode/int.hh"
00028 
00034 namespace Gecode { namespace Int { namespace Count {
00035 
00041 
00042   template <class VX>
00043   RelTest holds(VX x, VX y);
00045   template <class VX>
00046   RelTest holds(VX x, ConstIntView y);
00048   template <class VX>
00049   ExecStatus post_true(Space* home, ViewArray<VX>& x, VX y);
00051   template <class VX>
00052   ExecStatus post_true(Space* home, ViewArray<VX>& x, ConstIntView y);
00054   template <class VX>
00055   ExecStatus post_false(Space* home, ViewArray<VX>& x, VX y);
00057   template <class VX>
00058   ExecStatus post_false(Space* home, ViewArray<VX>& x, ConstIntView y);
00060 
00061 }}}
00062 
00063 #include "gecode/int/count/rel.icc"
00064 
00065 
00066 namespace Gecode { namespace Int { namespace Count {
00067 
00072   template <class VX, class VY>
00073   class BaseInt : public Propagator {
00074   protected:
00076     ViewArray<VX> x;
00078     int n_s;
00080     VY y;
00082     int c;
00084     BaseInt(Space* home, bool share, BaseInt& p);
00086     BaseInt(Space* home, ViewArray<VX>& x, int n_s, VY y, int c);
00087   public:
00089     virtual PropCost cost(void) const;
00091     virtual size_t dispose(Space* home);
00092   };
00093 
00103   template <class VX, class VY>
00104   class EqInt : public BaseInt<VX,VY> {
00105   protected:
00106     using BaseInt<VX,VY>::x;
00107     using BaseInt<VX,VY>::n_s;
00108     using BaseInt<VX,VY>::y;
00109     using BaseInt<VX,VY>::c;
00111     EqInt(Space* home, bool share, EqInt& p);
00113     EqInt(Space* home, ViewArray<VX>& x, int n_s, VY y, int c);
00114   public:
00116     virtual Actor* copy(Space* home, bool share);
00118     virtual ExecStatus propagate(Space* home);
00120     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, int c);
00121   };
00122 
00132   template <class VX, class VY>
00133   class GqInt : public BaseInt<VX,VY> {
00134   protected:
00135     using BaseInt<VX,VY>::x;
00136     using BaseInt<VX,VY>::n_s;
00137     using BaseInt<VX,VY>::y;
00138     using BaseInt<VX,VY>::c;
00140     GqInt(Space* home, bool share, GqInt& p);
00142     GqInt(Space* home, ViewArray<VX>& x, int n_s, VY y, int c);
00143   public:
00145     virtual Actor* copy(Space* home, bool share);
00147     virtual ExecStatus propagate(Space* home);
00149     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, int c);
00150   };
00151 
00161   template <class VX, class VY>
00162   class LqInt : public BaseInt<VX,VY> {
00163   protected:
00164     using BaseInt<VX,VY>::x;
00165     using BaseInt<VX,VY>::n_s;
00166     using BaseInt<VX,VY>::y;
00167     using BaseInt<VX,VY>::c;
00169     LqInt(Space* home, bool share, LqInt& p);
00171     LqInt(Space* home, ViewArray<VX>& x, int n_s, VY y, int c);
00172   public:
00174     virtual Actor* copy(Space* home, bool share);
00176     virtual ExecStatus propagate(Space* home);
00178     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, int c);
00179   };
00180 
00190   template<class VX, class VY>
00191   class NqInt : public BinaryPropagator<VX,PC_INT_DOM> {
00192   protected:
00193     using BinaryPropagator<VX,PC_INT_DOM>::x0;
00194     using BinaryPropagator<VX,PC_INT_DOM>::x1;
00196     ViewArray<VX> x;
00198     VY y;
00200     int c;
00202     bool resubscribe(Space* home, VX& z);
00204     NqInt(Space* home,  ViewArray<VX>& x, VY y, int c);
00206     NqInt(Space* home, bool share, NqInt& p);
00207   public:
00209     virtual Actor* copy(Space* home, bool share);
00211     virtual PropCost cost(void) const;
00213     virtual ExecStatus propagate(Space* home);
00215     static  ExecStatus post(Space* home, ViewArray<VX>& x, VY y, int c);
00217     virtual size_t dispose(Space* home);
00218   };
00219 
00220 }}}
00221 
00222 #include "gecode/int/count/int.icc"
00223 
00224 
00225 namespace Gecode { namespace Int { namespace Count {
00226 
00231   template <class VX, class VY, class VZ, bool shr>
00232   class BaseView : public Propagator {
00233   protected:
00235     ViewArray<VX> x;
00237     VY y;
00239     VZ z;
00241     int   c;
00243     BaseView(Space* home, bool shr, BaseView& p);
00245     BaseView(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00246   public:
00248     virtual size_t dispose(Space* home);
00250     virtual PropCost cost(void) const;
00251   protected:
00253     void count(Space* home);
00255     int atleast(void) const;
00257     int atmost(void) const;
00259     static bool sharing(const ViewArray<VX>& x, const VY& y, const VZ& z);
00260   };
00261 
00271   template <class VX, class VY, class VZ, bool shr>
00272   class EqView : public BaseView<VX,VY,VZ,shr> {
00273   protected:
00274     using BaseView<VX,VY,VZ,shr>::x;
00275     using BaseView<VX,VY,VZ,shr>::z;
00276     using BaseView<VX,VY,VZ,shr>::c;
00277     using BaseView<VX,VY,VZ,shr>::y;
00278     using BaseView<VX,VY,VZ,shr>::count;
00279     using BaseView<VX,VY,VZ,shr>::atleast;
00280     using BaseView<VX,VY,VZ,shr>::atmost;
00281 
00283     EqView(Space* home, bool shr, EqView& p);
00284   public:
00286     EqView(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00288     virtual Actor* copy(Space* home, bool shr);
00290     virtual ExecStatus propagate(Space* home);
00292     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00293   };
00294 
00304   template <class VX, class VY, class VZ, bool shr>
00305   class NqView : public BaseView<VX,VY,VZ,shr> {
00306   protected:
00307     using BaseView<VX,VY,VZ,shr>::x;
00308     using BaseView<VX,VY,VZ,shr>::z;
00309     using BaseView<VX,VY,VZ,shr>::c;
00310     using BaseView<VX,VY,VZ,shr>::y;
00311     using BaseView<VX,VY,VZ,shr>::count;
00312     using BaseView<VX,VY,VZ,shr>::atleast;
00313     using BaseView<VX,VY,VZ,shr>::atmost;
00314 
00316     NqView(Space* home, bool shr, NqView& p);
00317   public:
00319     NqView(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00321     virtual Actor* copy(Space* home, bool shr);
00323     virtual ExecStatus propagate(Space* home);
00325     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00326   };
00327 
00337   template <class VX, class VY, class VZ, bool shr>
00338   class LqView : public BaseView<VX,VY,VZ,shr> {
00339   protected:
00340     using BaseView<VX,VY,VZ,shr>::x;
00341     using BaseView<VX,VY,VZ,shr>::z;
00342     using BaseView<VX,VY,VZ,shr>::c;
00343     using BaseView<VX,VY,VZ,shr>::y;
00344     using BaseView<VX,VY,VZ,shr>::count;
00345     using BaseView<VX,VY,VZ,shr>::atleast;
00346     using BaseView<VX,VY,VZ,shr>::atmost;
00347 
00349     LqView(Space* home, bool shr, LqView& p);
00350   public:
00352     LqView(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00354     virtual Actor* copy(Space* home, bool shr);
00356     virtual ExecStatus propagate(Space* home);
00358     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00359   };
00360 
00370   template <class VX, class VY, class VZ, bool shr>
00371   class GqView : public BaseView<VX,VY,VZ,shr> {
00372   protected:
00373     using BaseView<VX,VY,VZ,shr>::x;
00374     using BaseView<VX,VY,VZ,shr>::z;
00375     using BaseView<VX,VY,VZ,shr>::c;
00376     using BaseView<VX,VY,VZ,shr>::y;
00377     using BaseView<VX,VY,VZ,shr>::count;
00378     using BaseView<VX,VY,VZ,shr>::atleast;
00379     using BaseView<VX,VY,VZ,shr>::atmost;
00380 
00382     GqView(Space* home, bool shr, GqView& p);
00383   public:
00385     GqView(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00387     virtual Actor* copy(Space* home, bool share);
00389     virtual ExecStatus propagate(Space* home);
00391     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00392   };
00393 
00394 }}}
00395 
00396 #include "gecode/int/count/view.icc"
00397 
00398 #endif
00399 
00400 // STATISTICS: int-prop
00401