Generated on Wed Jan 4 17:49:08 2006 for Gecode by doxygen 1.4.6

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: 2005-11-04 13:56:04 +0100 (Fri, 04 Nov 2005) $ by $Author: schulte $
00012  *     $Revision: 2497 $
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 "int.hh"
00028 
00034 namespace Gecode { namespace Int { namespace Count {
00035 
00040   template <class VX, class VY, class VZ, class Rel, bool shr>
00041   class Base : public Propagator {
00042   protected:
00044     ViewArray<VX> x;
00046     VY y;
00048     VZ z;
00050     int   c;
00052     Rel   r;
00054     Base(Space* home, bool shr, Base& p);
00056     Base(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00057   public:
00059     virtual ~Base(void);
00061     virtual PropCost cost(void) const;
00062   protected:
00064     int atleast(void) const;
00066     int atmost(void) const;
00068     static bool sharing(const ViewArray<VX>& x, const VY& y, const VZ& z);
00069   };
00070 
00083   template <class VX, class VY, class VZ, class Rel, bool shr>
00084   class Eq : public Base<VX,VY,VZ,Rel,shr> {
00085   protected:
00086     using Base<VX,VY,VZ,Rel,shr>::x;
00087     using Base<VX,VY,VZ,Rel,shr>::z;
00088     using Base<VX,VY,VZ,Rel,shr>::c;
00089     using Base<VX,VY,VZ,Rel,shr>::r;
00090     using Base<VX,VY,VZ,Rel,shr>::y;
00091     using Base<VX,VY,VZ,Rel,shr>::atleast;
00092     using Base<VX,VY,VZ,Rel,shr>::atmost;
00093 
00095     Eq(Space* home, bool shr, Eq& p);
00096   public:
00098     Eq(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00100     virtual Actor* copy(Space* home, bool shr);
00102     virtual ExecStatus propagate(Space* home);
00104     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00105   };
00106 
00119   template <class VX, class VY, class VZ, class Rel, bool shr>
00120   class Nq : public Base<VX,VY,VZ,Rel,shr> {
00121   protected:
00122     using Base<VX,VY,VZ,Rel,shr>::x;
00123     using Base<VX,VY,VZ,Rel,shr>::z;
00124     using Base<VX,VY,VZ,Rel,shr>::c;
00125     using Base<VX,VY,VZ,Rel,shr>::r;
00126     using Base<VX,VY,VZ,Rel,shr>::y;
00127     using Base<VX,VY,VZ,Rel,shr>::atleast;
00128     using Base<VX,VY,VZ,Rel,shr>::atmost;
00129 
00131     Nq(Space* home, bool shr, Nq& p);
00132   public:
00134     Nq(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00136     virtual Actor* copy(Space* home, bool shr);
00138     virtual ExecStatus propagate(Space* home);
00140     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00141   };
00142 
00155   template <class VX, class VY, class VZ, class Rel, bool shr>
00156   class Lq : public Base<VX,VY,VZ,Rel,shr> {
00157   protected:
00158     using Base<VX,VY,VZ,Rel,shr>::x;
00159     using Base<VX,VY,VZ,Rel,shr>::z;
00160     using Base<VX,VY,VZ,Rel,shr>::c;
00161     using Base<VX,VY,VZ,Rel,shr>::r;
00162     using Base<VX,VY,VZ,Rel,shr>::y;
00163     using Base<VX,VY,VZ,Rel,shr>::atleast;
00164     using Base<VX,VY,VZ,Rel,shr>::atmost;
00165 
00167     Lq(Space* home, bool shr, Lq& p);
00168   public:
00170     Lq(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00172     virtual Actor* copy(Space* home, bool shr);
00174     virtual ExecStatus propagate(Space* home);
00176     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00177   };
00178 
00191   template <class VX, class VY, class VZ, class Rel, bool shr>
00192   class Gq : public Base<VX,VY,VZ,Rel,shr> {
00193   protected:
00194     using Base<VX,VY,VZ,Rel,shr>::x;
00195     using Base<VX,VY,VZ,Rel,shr>::z;
00196     using Base<VX,VY,VZ,Rel,shr>::c;
00197     using Base<VX,VY,VZ,Rel,shr>::r;
00198     using Base<VX,VY,VZ,Rel,shr>::y;
00199     using Base<VX,VY,VZ,Rel,shr>::atleast;
00200     using Base<VX,VY,VZ,Rel,shr>::atmost;
00201 
00203     Gq(Space* home, bool shr, Gq& p);
00204   public:
00206     Gq(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00208     virtual Actor* copy(Space* home, bool share);
00210     virtual ExecStatus propagate(Space* home);
00212     static ExecStatus post(Space* home, ViewArray<VX>& x, VY y, VZ z, int c);
00213   };
00214 
00215 }}}
00216 
00217 #include "int/count/count.icc"
00218 
00219 namespace Gecode { namespace Int { namespace Count {
00220 
00225   template <class VX>
00226   class RelEqBnd {
00227   public:
00229     PropCond cond(void) const;
00231     RelTest holds(VX,VX);
00233     RelTest holds(VX x, ConstIntView y);
00235     ExecStatus post_true(Space* home, ViewArray<VX>& x, VX y);
00237     ExecStatus post_true(Space* home, ViewArray<VX>& x, ConstIntView y);
00239     ExecStatus post_false(Space* home, ViewArray<VX>& x, VX y);
00241     ExecStatus post_false(Space* home, ViewArray<VX>& x, ConstIntView y);
00242   };
00243 
00248   template <class VX>
00249   class RelEqDom {
00250   public:
00252     PropCond cond(void) const;
00254     RelTest holds(VX x, VX y);
00256     RelTest holds(VX x, ConstIntView y);
00258     ExecStatus post_true(Space* home, ViewArray<VX>& x, VX y);
00260     ExecStatus post_true(Space* home, ViewArray<VX>& x, ConstIntView y);
00262     ExecStatus post_false(Space* home, ViewArray<VX>& x, VX y);
00264     ExecStatus post_false(Space* home, ViewArray<VX>& x, ConstIntView y);
00265   };
00266 
00267 }}}
00268 
00269 #include "int/count/rel.icc"
00270 
00271 #endif
00272 
00273 // STATISTICS: int-prop
00274