afc.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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
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