branch-var.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 #include <functional>
00039
00040 namespace Gecode {
00041
00051 typedef std::function<double(const Space& home, double w, double b)>
00052 BranchTbl;
00053
00058 template<class Var>
00059 class VarBranch {
00060 public:
00062 typedef typename BranchTraits<Var>::Merit MeritFunction;
00063 protected:
00065 BranchTbl _tbl;
00067 Rnd _rnd;
00069 double _decay;
00071 AFC _afc;
00073 Action _act;
00075 CHB _chb;
00077 MeritFunction _mf;
00078 public:
00080 VarBranch(void);
00082 VarBranch(BranchTbl t);
00084 VarBranch(Rnd r);
00086 VarBranch(double d, BranchTbl t);
00088 VarBranch(AFC a, BranchTbl t);
00090 VarBranch(Action a, BranchTbl t);
00092 VarBranch(CHB c, BranchTbl t);
00094 VarBranch(MeritFunction f, BranchTbl t);
00096 BranchTbl tbl(void) const;
00098 Rnd rnd(void) const;
00100 double decay(void) const;
00102 AFC afc(void) const;
00104 void afc(AFC a);
00106 Action action(void) const;
00108 void action(Action a);
00110 CHB chb(void) const;
00112 void chb(CHB chb);
00114 MeritFunction merit(void) const;
00115 };
00116
00117
00118 template<class Var>
00119 inline
00120 VarBranch<Var>::VarBranch(void)
00121 : _tbl(nullptr), _decay(1.0) {}
00122
00123 template<class Var>
00124 inline
00125 VarBranch<Var>::VarBranch(BranchTbl t)
00126 : _tbl(t), _decay(1.0) {}
00127
00128 template<class Var>
00129 inline
00130 VarBranch<Var>::VarBranch(double d, BranchTbl t)
00131 : _tbl(t), _decay(d) {}
00132
00133 template<class Var>
00134 inline
00135 VarBranch<Var>::VarBranch(AFC a, BranchTbl t)
00136 : _tbl(t), _decay(1.0), _afc(a) {
00137 if (!_afc)
00138 throw UninitializedAFC("VarBranch<Var>::VarBranch");
00139 }
00140
00141 template<class Var>
00142 inline
00143 VarBranch<Var>::VarBranch(Action a, BranchTbl t)
00144 : _tbl(t), _decay(1.0), _act(a) {
00145 if (!_act)
00146 throw UninitializedAction("VarBranch<Var>::VarBranch");
00147 }
00148
00149 template<class Var>
00150 inline
00151 VarBranch<Var>::VarBranch(CHB c, BranchTbl t)
00152 : _tbl(t), _decay(1.0), _chb(c) {
00153 if (!_chb)
00154 throw UninitializedCHB("VarBranch<Var>::VarBranch");
00155 }
00156
00157 template<class Var>
00158 inline
00159 VarBranch<Var>::VarBranch(Rnd r)
00160 : _tbl(nullptr), _rnd(r), _decay(1.0) {
00161 if (!_rnd)
00162 throw UninitializedRnd("VarBranch<Var>::VarBranch");
00163 }
00164
00165 template<class Var>
00166 inline
00167 VarBranch<Var>::VarBranch(MeritFunction f, BranchTbl t)
00168 : _tbl(t), _decay(1.0), _mf(f) {}
00169
00170 template<class Var>
00171 inline BranchTbl
00172 VarBranch<Var>::tbl(void) const {
00173 return _tbl;
00174 }
00175
00176 template<class Var>
00177 inline Rnd
00178 VarBranch<Var>::rnd(void) const {
00179 return _rnd;
00180 }
00181
00182 template<class Var>
00183 inline double
00184 VarBranch<Var>::decay(void) const {
00185 return _decay;
00186 }
00187
00188 template<class Var>
00189 inline AFC
00190 VarBranch<Var>::afc(void) const {
00191 return _afc;
00192 }
00193
00194 template<class Var>
00195 inline void
00196 VarBranch<Var>::afc(AFC a) {
00197 _afc=a;
00198 }
00199
00200 template<class Var>
00201 inline Action
00202 VarBranch<Var>::action(void) const {
00203 return _act;
00204 }
00205
00206 template<class Var>
00207 inline void
00208 VarBranch<Var>::action(Action a) {
00209 _act=a;
00210 }
00211
00212 template<class Var>
00213 inline CHB
00214 VarBranch<Var>::chb(void) const {
00215 return _chb;
00216 }
00217
00218 template<class Var>
00219 inline void
00220 VarBranch<Var>::chb(CHB chb) {
00221 _chb=chb;
00222 }
00223
00224 template<class Var>
00225 inline typename VarBranch<Var>::MeritFunction
00226 VarBranch<Var>::merit(void) const {
00227 return _mf;
00228 }
00229
00230 }
00231
00232