Changeset 1145:99c1aa395a58 in lemon-0.x for src/work
- Timestamp:
- 02/11/05 15:56:40 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1546
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/akos/simann.h
r1142 r1145 181 181 max_iter(_max_iter), max_no_impr(_max_no_impr), temp(_temp), 182 182 ann_fact(_ann_fact) {} 183 /*! \brief This is called when a neighbouring state gets accepted. */ 183 184 void acceptEvent() { 184 185 iter++; … … 216 217 /*! \brief A controller with preset running time for the simulated annealing 217 218 * class. 219 * 220 * With this controller you can set the running time of the annealing 221 * process in advance. It works the following way: the controller measures 222 * a kind of divergence. The divergence is the difference of the average 223 * cost of the recently found solutions the cost of the best found one. In 224 * case this divergence is greater than a given threshold, then we decrease 225 * the annealing factor, that is we cool the system faster. In case the 226 * divergence is lower than the threshold, then we increase the temperature. 227 * The threshold is a function of the elapsed time which reaches zero at the 228 * desired end time. 218 229 */ 219 230 class AdvancedController : public SimAnnBase::Controller { … … 228 239 double beta; 229 240 double gamma; 241 /*! \brief The time at the end of the algorithm. */ 230 242 double end_time; 243 /*! \brief The time at the start of the algorithm. */ 231 244 double start_time; 245 /*! \brief Starting threshold. */ 232 246 double start_threshold; 247 /*! \brief Average cost of recent solutions. */ 233 248 double avg_cost; 249 /*! \brief Temperature. */ 234 250 double temp; 251 /*! \brief Annealing factor. */ 235 252 double ann_fact; 253 /*! \brief Initial annealing factor. */ 254 double init_ann_fact; 236 255 bool warmup; 237 256 /*! \brief Constructor. … … 240 259 * \param _beta parameter used to decrease the annealing factor 241 260 * \param _gamma parameter used to increase the temperature 261 * \param _ann_fact initial annealing factor 242 262 */ 243 263 AdvancedController(double _end_time, double _alpha = 0.2, 244 double _beta = 0.9, double _gamma = 1.6) : alpha(_alpha), beta(_beta), 245 gamma(_gamma), end_time(_end_time), ann_fact(0.99999999), warmup(true) {} 264 double _beta = 0.9, double _gamma = 1.6, double _ann_fact = 0.9999) : 265 alpha(_alpha), beta(_beta), gamma(_gamma), end_time(_end_time), 266 ann_fact(_ann_fact), init_ann_fact(_ann_fact), warmup(true) {} 246 267 void init() { 247 268 avg_cost = base->getCurrCost(); … … 276 297 // increase the temperature 277 298 temp *= gamma; 278 ann_fact = 0.99999999; // !!!!!!!!!!! 299 // reset the annealing factor 300 ann_fact = init_ann_fact; 279 301 } 280 302 temp *= ann_fact;
Note: See TracChangeset
for help on using the changeset viewer.