Generated on Tue Apr 18 10:21:36 2017 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  *  Last modified:
00010  *     $Date: 2017-03-08 11:58:56 +0100 (Wed, 08 Mar 2017) $ by $Author: schulte $
00011  *     $Revision: 15562 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 namespace Gecode {
00039 
00044   class AFC {
00045   protected:
00047     int n;
00048   public:
00050 
00051 
00058     AFC(void);
00060     AFC(const AFC& a);
00062     AFC& operator =(const AFC& a);
00064     template<class Var>
00065     AFC(Home home, const VarArgArray<Var>& x, double d);
00067     template<class Var>
00068     void init(Home home, const VarArgArray<Var>& x, double d);
00070     operator bool(void) const;
00072     GECODE_KERNEL_EXPORT static const AFC def;
00074 
00076 
00077 
00078     void update(Space& home, bool share, AFC& a);
00080     ~AFC(void);
00082 
00084 
00085 
00086     int size(void) const;
00088 
00090 
00091 
00092     void decay(Space& home, double d);
00094     double decay(const Space& home) const;
00096   };
00097 
00102   template<class Char, class Traits>
00103   std::basic_ostream<Char,Traits>&
00104   operator <<(std::basic_ostream<Char,Traits>& os,
00105              const AFC& a);
00106 
00107   /*
00108    * AFC
00109    *
00110    */
00111   forceinline int
00112   AFC::size(void) const {
00113     assert(n >= 0);
00114     return n;
00115   }
00116 
00117   forceinline
00118   AFC::AFC(void) : n(-1) {}
00119 
00120   forceinline
00121   AFC::operator bool(void) const {
00122     return n >= 0;
00123   }
00124 
00125   template<class Var>
00126   forceinline
00127   AFC::AFC(Home home, const VarArgArray<Var>& x, double d)
00128     : n(x.size()) {
00129     if ((d < 0.0) || (d > 1.0))
00130       throw IllegalDecay("AFC");
00131     static_cast<Space&>(home).afc_decay(d);
00132   }
00133   template<class Var>
00134   forceinline void
00135   AFC::init(Home home, const VarArgArray<Var>& x, double d) {
00136     n = x.size();
00137     if ((d < 0.0) || (d > 1.0))
00138       throw IllegalDecay("AFC");
00139     static_cast<Space&>(home).afc_decay(d);
00140   }
00141 
00142 
00143   forceinline
00144   AFC::AFC(const AFC& a)
00145     : n(a.n) {}
00146   forceinline AFC&
00147   AFC::operator =(const AFC& a) {
00148     n=a.n;
00149     return *this;
00150   }
00151   forceinline
00152   AFC::~AFC(void) {}
00153 
00154   forceinline void
00155   AFC::update(Space&, bool, AFC& a) {
00156     n=a.n;
00157   }
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