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 bool initialized(void) const;
00072 void set(Space& home, double a=1.0);
00074 GECODE_KERNEL_EXPORT static const AFC def;
00076
00078
00079
00080 void update(Space& home, bool share, AFC& a);
00082 ~AFC(void);
00084
00086
00087
00088 int size(void) const;
00090
00092
00093
00094 void decay(Space& home, double d);
00096 double decay(const Space& home) const;
00098 };
00099
00104 template<class Char, class Traits>
00105 std::basic_ostream<Char,Traits>&
00106 operator <<(std::basic_ostream<Char,Traits>& os,
00107 const AFC& a);
00108
00109
00110
00111
00112
00113 forceinline int
00114 AFC::size(void) const {
00115 assert(n >= 0);
00116 return n;
00117 }
00118
00119 forceinline
00120 AFC::AFC(void) : n(-1) {}
00121
00122 forceinline bool
00123 AFC::initialized(void) const {
00124 return n >= 0;
00125 }
00126
00127 template<class Var>
00128 forceinline
00129 AFC::AFC(Home home, const VarArgArray<Var>& x, double d)
00130 : n(x.size()) {
00131 if ((d < 0.0) || (d > 1.0))
00132 throw IllegalDecay("AFC");
00133 static_cast<Space&>(home).afc_decay(d);
00134 }
00135 template<class Var>
00136 forceinline void
00137 AFC::init(Home home, const VarArgArray<Var>& x, double d) {
00138 n = x.size();
00139 if ((d < 0.0) || (d > 1.0))
00140 throw IllegalDecay("AFC");
00141 static_cast<Space&>(home).afc_decay(d);
00142 }
00143
00144
00145 forceinline
00146 AFC::AFC(const AFC& a)
00147 : n(a.n) {}
00148 forceinline AFC&
00149 AFC::operator =(const AFC& a) {
00150 n=a.n;
00151 return *this;
00152 }
00153 forceinline
00154 AFC::~AFC(void) {}
00155
00156 forceinline void
00157 AFC::update(Space&, bool, AFC& a) {
00158 n=a.n;
00159 }
00160
00161 forceinline void
00162 AFC::decay(Space& home, double d) {
00163 if ((d < 0.0) || (d > 1.0))
00164 throw IllegalDecay("AFC");
00165 home.afc_decay(d);
00166 }
00167
00168 forceinline void
00169 AFC::set(Space& home, double a) {
00170 home.afc_set(a);
00171 }
00172
00173 forceinline double
00174 AFC::decay(const Space& home) const {
00175 return home.afc_decay();
00176 }
00177
00178
00179 template<class Char, class Traits>
00180 std::basic_ostream<Char,Traits>&
00181 operator <<(std::basic_ostream<Char,Traits>& os,
00182 const AFC& a) {
00183 (void)a;
00184 return os << "AFC(no information available)";
00185 }
00186
00187 }
00188
00189