Generated on Mon May 10 06:46:35 2010 for Gecode by doxygen 1.6.3

count.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  *
00007  *  Copyright:
00008  *     Christian Schulte, 2002
00009  *     Guido Tack, 2004
00010  *
00011  *  Last modified:
00012  *     $Date: 2009-10-12 17:36:53 +0200 (Mon, 12 Oct 2009) $ by $Author: schulte $
00013  *     $Revision: 9878 $
00014  *
00015  *  This file is part of Gecode, the generic constraint
00016  *  development environment:
00017  *     http://www.gecode.org
00018  *
00019  *  Permission is hereby granted, free of charge, to any person obtaining
00020  *  a copy of this software and associated documentation files (the
00021  *  "Software"), to deal in the Software without restriction, including
00022  *  without limitation the rights to use, copy, modify, merge, publish,
00023  *  distribute, sublicense, and/or sell copies of the Software, and to
00024  *  permit persons to whom the Software is furnished to do so, subject to
00025  *  the following conditions:
00026  *
00027  *  The above copyright notice and this permission notice shall be
00028  *  included in all copies or substantial portions of the Software.
00029  *
00030  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00031  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00032  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00033  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00034  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00035  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00036  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00037  *
00038  */
00039 
00040 #ifndef __GECODE_INT_COUNT_HH__
00041 #define __GECODE_INT_COUNT_HH__
00042 
00043 #include <gecode/int.hh>
00044 
00050 namespace Gecode { namespace Int { namespace Count {
00051 
00057 
00058   template<class VX>
00059   RelTest holds(VX x, VX y);
00061   template<class VX>
00062   RelTest holds(VX x, ConstIntView y);
00064   template<class VX>
00065   bool post_true(Home home, ViewArray<VX>& x, VX y);
00067   template<class VX>
00068   bool post_true(Home home, ViewArray<VX>& x, ConstIntView y);
00070   template<class VX>
00071   bool post_false(Home home, ViewArray<VX>& x, VX y);
00073   template<class VX>
00074   bool post_false(Home home, ViewArray<VX>& x, ConstIntView y);
00076 
00077 }}}
00078 
00079 #include <gecode/int/count/rel.hpp>
00080 
00081 
00082 namespace Gecode { namespace Int { namespace Count {
00083 
00088   template<class VX, class VY>
00089   class BaseInt : public Propagator {
00090   protected:
00092     ViewArray<VX> x;
00094     int n_s;
00096     VY y;
00098     int c;
00100     BaseInt(Space& home, bool share, BaseInt& p);
00102     BaseInt(Home home, ViewArray<VX>& x, int n_s, VY y, int c);
00103   public:
00105     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00107     virtual size_t dispose(Space& home);
00108   };
00109 
00119   template<class VX, class VY>
00120   class EqInt : public BaseInt<VX,VY> {
00121   protected:
00122     using BaseInt<VX,VY>::x;
00123     using BaseInt<VX,VY>::n_s;
00124     using BaseInt<VX,VY>::y;
00125     using BaseInt<VX,VY>::c;
00127     EqInt(Space& home, bool share, EqInt& p);
00129     EqInt(Home home, ViewArray<VX>& x, int n_s, VY y, int c);
00130   public:
00132     virtual Actor* copy(Space& home, bool share);
00134     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00136     static ExecStatus post(Home home, ViewArray<VX>& x, VY y, int c);
00137   };
00138 
00148   template<class VX, class VY>
00149   class GqInt : public BaseInt<VX,VY> {
00150   protected:
00151     using BaseInt<VX,VY>::x;
00152     using BaseInt<VX,VY>::n_s;
00153     using BaseInt<VX,VY>::y;
00154     using BaseInt<VX,VY>::c;
00156     GqInt(Space& home, bool share, GqInt& p);
00158     GqInt(Home home, ViewArray<VX>& x, int n_s, VY y, int c);
00159   public:
00161     virtual Actor* copy(Space& home, bool share);
00163     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00165     static ExecStatus post(Home home, ViewArray<VX>& x, VY y, int c);
00166   };
00167 
00177   template<class VX, class VY>
00178   class LqInt : public BaseInt<VX,VY> {
00179   protected:
00180     using BaseInt<VX,VY>::x;
00181     using BaseInt<VX,VY>::n_s;
00182     using BaseInt<VX,VY>::y;
00183     using BaseInt<VX,VY>::c;
00185     LqInt(Space& home, bool share, LqInt& p);
00187     LqInt(Home home, ViewArray<VX>& x, int n_s, VY y, int c);
00188   public:
00190     virtual Actor* copy(Space& home, bool share);
00192     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00194     static ExecStatus post(Home home, ViewArray<VX>& x, VY y, int c);
00195   };
00196 
00206   template<class VX, class VY>
00207   class NqInt : public BinaryPropagator<VX,PC_INT_DOM> {
00208   protected:
00209     using BinaryPropagator<VX,PC_INT_DOM>::x0;
00210     using BinaryPropagator<VX,PC_INT_DOM>::x1;
00212     ViewArray<VX> x;
00214     VY y;
00216     int c;
00218     bool resubscribe(Space& home, VX& z);
00220     NqInt(Home home,  ViewArray<VX>& x, VY y, int c);
00222     NqInt(Space& home, bool share, NqInt& p);
00223   public:
00225     virtual Actor* copy(Space& home, bool share);
00227     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00229     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00231     static  ExecStatus post(Home home, ViewArray<VX>& x, VY y, int c);
00233     virtual size_t dispose(Space& home);
00234   };
00235 
00236 }}}
00237 
00238 #include <gecode/int/count/int.hpp>
00239 
00240 
00241 namespace Gecode { namespace Int { namespace Count {
00242 
00247   template<class VX, class VY, class VZ, bool shr>
00248   class BaseView : public Propagator {
00249   protected:
00251     ViewArray<VX> x;
00253     VY y;
00255     VZ z;
00257     int   c;
00259     BaseView(Space& home, bool share, BaseView& p);
00261     BaseView(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00262   public:
00264     virtual size_t dispose(Space& home);
00266     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00267   protected:
00269     void count(Space& home);
00271     int atleast(void) const;
00273     int atmost(void) const;
00275     static bool sharing(const ViewArray<VX>& x, const VY& y, const VZ& z);
00276   };
00277 
00287   template<class VX, class VY, class VZ, bool shr>
00288   class EqView : public BaseView<VX,VY,VZ,shr> {
00289   protected:
00290     using BaseView<VX,VY,VZ,shr>::x;
00291     using BaseView<VX,VY,VZ,shr>::z;
00292     using BaseView<VX,VY,VZ,shr>::c;
00293     using BaseView<VX,VY,VZ,shr>::y;
00294     using BaseView<VX,VY,VZ,shr>::count;
00295     using BaseView<VX,VY,VZ,shr>::atleast;
00296     using BaseView<VX,VY,VZ,shr>::atmost;
00297 
00299     EqView(Space& home, bool share, EqView& p);
00300   public:
00302     EqView(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00304     virtual Actor* copy(Space& home, bool share);
00306     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00308     static ExecStatus post(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00309   };
00310 
00320   template<class VX, class VY, class VZ, bool shr>
00321   class NqView : public BaseView<VX,VY,VZ,shr> {
00322   protected:
00323     using BaseView<VX,VY,VZ,shr>::x;
00324     using BaseView<VX,VY,VZ,shr>::z;
00325     using BaseView<VX,VY,VZ,shr>::c;
00326     using BaseView<VX,VY,VZ,shr>::y;
00327     using BaseView<VX,VY,VZ,shr>::count;
00328     using BaseView<VX,VY,VZ,shr>::atleast;
00329     using BaseView<VX,VY,VZ,shr>::atmost;
00330 
00332     NqView(Space& home, bool share, NqView& p);
00333   public:
00335     NqView(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00337     virtual Actor* copy(Space& home, bool share);
00339     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00341     static ExecStatus post(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00342   };
00343 
00353   template<class VX, class VY, class VZ, bool shr>
00354   class LqView : public BaseView<VX,VY,VZ,shr> {
00355   protected:
00356     using BaseView<VX,VY,VZ,shr>::x;
00357     using BaseView<VX,VY,VZ,shr>::z;
00358     using BaseView<VX,VY,VZ,shr>::c;
00359     using BaseView<VX,VY,VZ,shr>::y;
00360     using BaseView<VX,VY,VZ,shr>::count;
00361     using BaseView<VX,VY,VZ,shr>::atleast;
00362     using BaseView<VX,VY,VZ,shr>::atmost;
00363 
00365     LqView(Space& home, bool share, LqView& p);
00366   public:
00368     LqView(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00370     virtual Actor* copy(Space& home, bool share);
00372     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00374     static ExecStatus post(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00375   };
00376 
00386   template<class VX, class VY, class VZ, bool shr>
00387   class GqView : public BaseView<VX,VY,VZ,shr> {
00388   protected:
00389     using BaseView<VX,VY,VZ,shr>::x;
00390     using BaseView<VX,VY,VZ,shr>::z;
00391     using BaseView<VX,VY,VZ,shr>::c;
00392     using BaseView<VX,VY,VZ,shr>::y;
00393     using BaseView<VX,VY,VZ,shr>::count;
00394     using BaseView<VX,VY,VZ,shr>::atleast;
00395     using BaseView<VX,VY,VZ,shr>::atmost;
00396 
00398     GqView(Space& home, bool share, GqView& p);
00399   public:
00401     GqView(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00403     virtual Actor* copy(Space& home, bool share);
00405     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00407     static ExecStatus post(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00408   };
00409 
00410 }}}
00411 
00412 #include <gecode/int/count/view.hpp>
00413 
00414 #endif
00415 
00416 // STATISTICS: int-prop
00417