Generated on Tue May 22 09:39:44 2018 for Gecode by doxygen 1.6.3

afc.hpp

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  *
00006  *  Copyright:
00007  *     Christian Schulte, 2013
00008  *
00009  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 namespace Gecode {
00035 
00040   class AFC {
00041   protected:
00043     int n;
00044   public:
00046 
00047 
00054     AFC(void);
00056     AFC(const AFC& a);
00058     AFC& operator =(const AFC& a);
00065     template<class Var>
00066     AFC(Home home, const VarArgArray<Var>& x, double d, bool share=true);
00073     template<class Var>
00074     void init(Home home, const VarArgArray<Var>& x, double d, bool share=true);
00076     operator bool(void) const;
00078     GECODE_KERNEL_EXPORT static const AFC def;
00080 
00082     ~AFC(void);
00083 
00085 
00086 
00087     int size(void) const;
00089 
00091 
00092 
00093     void decay(Space& home, double d);
00095     double decay(const Space& home) const;
00097   };
00098 
00103   template<class Char, class Traits>
00104   std::basic_ostream<Char,Traits>&
00105   operator <<(std::basic_ostream<Char,Traits>& os,
00106              const AFC& a);
00107 
00108   /*
00109    * AFC
00110    *
00111    */
00112   forceinline int
00113   AFC::size(void) const {
00114     assert(n >= 0);
00115     return n;
00116   }
00117 
00118   forceinline
00119   AFC::AFC(void) : n(-1) {}
00120 
00121   forceinline
00122   AFC::operator bool(void) const {
00123     return n >= 0;
00124   }
00125 
00126   template<class Var>
00127   forceinline
00128   AFC::AFC(Home home, const VarArgArray<Var>& x, double d, bool share)
00129     : n(x.size()) {
00130     if ((d < 0.0) || (d > 1.0))
00131       throw IllegalDecay("AFC");
00132     static_cast<Space&>(home).afc_decay(d);
00133     if (!share)
00134       static_cast<Space&>(home).afc_unshare();
00135   }
00136   template<class Var>
00137   forceinline void
00138   AFC::init(Home home, const VarArgArray<Var>& x, double d, bool share) {
00139     n = x.size();
00140     if ((d < 0.0) || (d > 1.0))
00141       throw IllegalDecay("AFC");
00142     static_cast<Space&>(home).afc_decay(d);
00143     if (!share)
00144       static_cast<Space&>(home).afc_unshare();
00145   }
00146 
00147 
00148   forceinline
00149   AFC::AFC(const AFC& a)
00150     : n(a.n) {}
00151   forceinline AFC&
00152   AFC::operator =(const AFC& a) {
00153     n=a.n;
00154     return *this;
00155   }
00156   forceinline
00157   AFC::~AFC(void) {}
00158 
00159   forceinline void
00160   AFC::decay(Space& home, double d) {
00161     if ((d < 0.0) || (d > 1.0))
00162       throw IllegalDecay("AFC");
00163     home.afc_decay(d);
00164   }
00165 
00166   forceinline double
00167   AFC::decay(const Space& home) const {
00168     return home.afc_decay();
00169   }
00170 
00171 
00172   template<class Char, class Traits>
00173   std::basic_ostream<Char,Traits>&
00174   operator <<(std::basic_ostream<Char,Traits>& os,
00175               const AFC& a) {
00176     (void)a;
00177     return os << "AFC(no information available)";
00178   }
00179 
00180 }
00181 
00182 // STATISTICS: kernel-branch