Generated on Wed Mar 19 07:29:56 2008 for Gecode by doxygen 1.5.5

arithmetic.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: 2008-02-25 00:16:01 +0100 (Mon, 25 Feb 2008) $ by $Author: schulte $
00013  *     $Revision: 6288 $
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_ARITHMETIC_HH__
00041 #define __GECODE_INT_ARITHMETIC_HH__
00042 
00043 #include "gecode/int.hh"
00044 
00045 #include "gecode/int/rel.hh"
00046 #include "gecode/int/linear.hh"
00047 
00053 namespace Gecode { namespace Int { namespace Arithmetic {
00054 
00061   template <class View>
00062   class AbsBnd : public BinaryPropagator<View,PC_INT_BND> {
00063   protected:
00064     using BinaryPropagator<View,PC_INT_BND>::x0;
00065     using BinaryPropagator<View,PC_INT_BND>::x1;
00066 
00068     AbsBnd(Space* home, bool share, AbsBnd& p);
00070     AbsBnd(Space* home, View x0, View x1);
00071   public:
00072 
00074     virtual Actor* copy(Space* home, bool share);
00081     virtual PropCost cost(ModEventDelta med) const;
00083     virtual ExecStatus  propagate(Space* home, ModEventDelta med);
00085     static  ExecStatus  post(Space* home, View x0, View x1);
00087     static void post(Space* home, Reflection::VarMap& vars,
00088                      const Reflection::ActorSpec& spec);
00090     virtual Reflection::ActorSpec spec(const Space* home,
00091                                         Reflection::VarMap& m) const;
00093     static Support::Symbol ati(void);
00094   };
00095 
00103   template <class View>
00104   ExecStatus prop_bnd(Space* home, Propagator* p, ViewArray<View>&);
00105 
00112   template <class View>
00113   class AbsDom : public BinaryPropagator<View,PC_INT_DOM> {
00114   protected:
00115     using BinaryPropagator<View,PC_INT_DOM>::x0;
00116     using BinaryPropagator<View,PC_INT_DOM>::x1;
00117 
00119     AbsDom(Space* home, bool share, AbsDom& p);
00121     AbsDom(Space* home, View x0, View x1);
00122   public:
00124     virtual Actor* copy(Space* home, bool share);
00132     virtual PropCost cost(ModEventDelta med) const;
00134     virtual ExecStatus  propagate(Space* home, ModEventDelta med);
00136     static  ExecStatus  post(Space* home, View x0, View x1);
00138     static void post(Space* home, Reflection::VarMap& vars,
00139                      const Reflection::ActorSpec& spec);
00141     virtual Reflection::ActorSpec spec(const Space* home,
00142                                         Reflection::VarMap& m) const;
00144     static Support::Symbol ati(void);
00145   };
00146 
00153   template <class View>
00154   class Max : public TernaryPropagator<View,PC_INT_BND> {
00155   protected:
00156     using TernaryPropagator<View,PC_INT_BND>::x0;
00157     using TernaryPropagator<View,PC_INT_BND>::x1;
00158     using TernaryPropagator<View,PC_INT_BND>::x2;
00159 
00161     Max(Space* home, bool share, Max& p);
00163     Max(Space* home, View x0, View x1, View x2);
00164   public:
00166     Max(Space* home, bool share, Propagator& p, View x0, View x1, View x2);
00168     virtual Actor* copy(Space* home, bool share);
00170     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00172     static  ExecStatus post(Space* home, View x0, View x1, View x2);
00174     static void post(Space* home, Reflection::VarMap& vars,
00175                      const Reflection::ActorSpec& spec);
00177     virtual Reflection::ActorSpec spec(const Space* home,
00178                                         Reflection::VarMap& m) const;
00180     static Support::Symbol ati(void);
00181   };
00182 
00189   template <class View>
00190   class NaryMax : public NaryOnePropagator<View,PC_INT_BND> {
00191   protected:
00192     using NaryOnePropagator<View,PC_INT_BND>::x;
00193     using NaryOnePropagator<View,PC_INT_BND>::y;
00194 
00196     NaryMax(Space* home, bool share, NaryMax& p);
00198     NaryMax(Space* home, ViewArray<View>& x, View y);
00199   public:
00201     virtual Actor* copy(Space* home, bool share);
00203     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00205     static  ExecStatus post(Space* home, ViewArray<View>& x, View y);
00207     static void post(Space* home, Reflection::VarMap& vars,
00208                      const Reflection::ActorSpec& spec);
00210     virtual Reflection::ActorSpec spec(const Space* home,
00211                                         Reflection::VarMap& m) const;
00213     static Support::Symbol ati(void);
00214   };
00215 
00216 
00217 
00218 
00224   template <class VA, class VB>
00225   class SqrPlus : public MixBinaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND> {
00226   protected:
00227     using MixBinaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND>::x0;
00228     using MixBinaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND>::x1;
00230     SqrPlus(Space* home, VA x0, VB x1);
00232     SqrPlus(Space* home, bool share, SqrPlus<VA,VB>& p);
00233   public:
00235     static ExecStatus post(Space* home, VA x0, VB x1);
00237     static void post(Space* home, Reflection::VarMap& vars,
00238                      const Reflection::ActorSpec& spec);
00240     virtual Actor* copy(Space* home, bool share);
00242     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00244     virtual Reflection::ActorSpec spec(const Space* home,
00245                                         Reflection::VarMap& m) const;
00247     static Support::Symbol ati(void);
00248   };
00249 
00256   template <class View>
00257   class Sqr : public BinaryPropagator<View,PC_INT_BND> {
00258   protected:
00259     using BinaryPropagator<View,PC_INT_BND>::x0;
00260     using BinaryPropagator<View,PC_INT_BND>::x1;
00261 
00263     Sqr(Space* home, bool share, Sqr<View>& p);
00265     Sqr(Space* home, View x0, View x1);
00266   public:
00268     virtual Actor* copy(Space* home, bool share);
00270     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00272     virtual PropCost cost(ModEventDelta med) const;
00274     static void post(Space* home, Reflection::VarMap& vars,
00275                      const Reflection::ActorSpec& spec);
00277     static ExecStatus post(Space* home, View x0, View x1);
00279     virtual Reflection::ActorSpec spec(const Space* home,
00280                                        Reflection::VarMap& m) const;
00282     static Support::Symbol ati(void);
00283   };
00284 
00285 
00286 
00293   template <class View>
00294   class Sqrt : public BinaryPropagator<View,PC_INT_BND> {
00295   protected:
00296     using BinaryPropagator<View,PC_INT_BND>::x0;
00297     using BinaryPropagator<View,PC_INT_BND>::x1;
00298 
00300     Sqrt(Space* home, bool share, Sqrt<View>& p);
00302     Sqrt(Space* home, View x0, View x1);
00303   public:
00305     virtual Actor* copy(Space* home, bool share);
00307     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00309     virtual PropCost cost(ModEventDelta med) const;
00311     static void post(Space* home, Reflection::VarMap& vars,
00312                      const Reflection::ActorSpec& spec);
00314     static ExecStatus post(Space* home, View x0, View x1);
00316     virtual Reflection::ActorSpec spec(const Space* home,
00317                                        Reflection::VarMap& m) const;
00319     static Support::Symbol ati(void);
00320   };
00321 
00322 
00323 
00330   template <class View>
00331   class MultZeroOne : public BinaryPropagator<View,PC_INT_BND> {
00332   protected:
00333     using BinaryPropagator<View,PC_INT_BND>::x0;
00334     using BinaryPropagator<View,PC_INT_BND>::x1;
00335 
00337     MultZeroOne(Space* home, bool share, MultZeroOne<View>& p);
00339     MultZeroOne(Space* home, View x0, View x1);
00340   public:
00342     virtual Actor* copy(Space* home, bool share);
00344     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00346     static void post(Space* home, Reflection::VarMap& vars,
00347                      const Reflection::ActorSpec& spec);
00349     static ExecStatus post(Space* home, View x0, View x1);
00351     virtual Reflection::ActorSpec spec(const Space* home,
00352                                        Reflection::VarMap& m) const;
00354     static Support::Symbol ati(void);
00355   };
00356 
00357 
00358 
00364   template <class Val, class VA, class VB, class VC>
00365   class MultPlus : 
00366     public MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND> {
00367   protected:
00368     using MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND>::x0;
00369     using MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND>::x1;
00370     using MixTernaryPropagator<VA,PC_INT_BND,VB,PC_INT_BND,VC,PC_INT_BND>::x2;
00371   public:
00373     MultPlus(Space* home, VA x0, VB x1, VC x2);
00375     MultPlus(Space* home, bool share, MultPlus<Val,VA,VB,VC>& p);
00377     static ExecStatus post(Space* home, VA x0, VB x1, VC x2);
00379     static void post(Space* home, Reflection::VarMap& vars,
00380                      const Reflection::ActorSpec& spec);
00382     virtual Actor* copy(Space* home, bool share);
00384     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00386     virtual Reflection::ActorSpec spec(const Space* home,
00387                                         Reflection::VarMap& m) const;
00389     static Support::Symbol ati(void);
00390   };
00391 
00399   template <class View>
00400   class Mult : public TernaryPropagator<View,PC_INT_BND> {
00401   protected:
00402     using TernaryPropagator<View,PC_INT_BND>::x0;
00403     using TernaryPropagator<View,PC_INT_BND>::x1;
00404     using TernaryPropagator<View,PC_INT_BND>::x2;
00405 
00407     Mult(Space* home, bool share, Mult<View>& p);
00408   public:
00410     Mult(Space* home, View x0, View x1, View x2);
00412     static  ExecStatus post(Space* home, View x0, View x1, View x2);
00414     static void post(Space* home, Reflection::VarMap& vars,
00415                      const Reflection::ActorSpec& spec);
00417     virtual Actor* copy(Space* home, bool share);
00419     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00421     virtual PropCost cost(ModEventDelta med) const;
00423     virtual Reflection::ActorSpec spec(const Space* home,
00424                                         Reflection::VarMap& m) const;
00426     static Support::Symbol ati(void);
00427   };
00428 
00429 }}}
00430 
00431 #include "gecode/int/arithmetic/abs.icc"
00432 #include "gecode/int/arithmetic/max.icc"
00433 #include "gecode/int/arithmetic/sqr.icc"
00434 #include "gecode/int/arithmetic/sqrt.icc"
00435 #include "gecode/int/arithmetic/mult.icc"
00436 
00437 #endif
00438 
00439 // STATISTICS: int-prop
00440