[Lemon-commits] [lemon_svn] ladanyi: r1546 - hugo/trunk/src/work/akos

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:46:08 CET 2006


Author: ladanyi
Date: Fri Feb 11 15:56:40 2005
New Revision: 1546

Modified:
   hugo/trunk/src/work/akos/simann.h

Log:
more docs

Modified: hugo/trunk/src/work/akos/simann.h
==============================================================================
--- hugo/trunk/src/work/akos/simann.h	(original)
+++ hugo/trunk/src/work/akos/simann.h	Fri Feb 11 15:56:40 2005
@@ -180,6 +180,7 @@
     double _temp = 1000.0, double _ann_fact = 0.9999) : iter(0), last_impr(0),
     max_iter(_max_iter), max_no_impr(_max_no_impr), temp(_temp),
     ann_fact(_ann_fact) {}
+    /*! \brief This is called when a neighbouring state gets accepted. */
     void acceptEvent() {
       iter++;
     }
@@ -215,6 +216,16 @@
 
   /*! \brief A controller with preset running time for the simulated annealing
    *  class.
+   *
+   *  With this controller you can set the running time of the annealing
+   *  process in advance. It works the following way: the controller measures
+   *  a kind of divergence. The divergence is the difference of the average
+   *  cost of the recently found solutions the cost of the best found one. In
+   *  case this divergence is greater than a given threshold, then we decrease
+   *  the annealing factor, that is we cool the system faster. In case the
+   *  divergence is lower than the threshold, then we increase the temperature.
+   *  The threshold is a function of the elapsed time which reaches zero at the
+   *  desired end time.
    */
   class AdvancedController : public SimAnnBase::Controller {
   private:
@@ -227,22 +238,32 @@
     double alpha;
     double beta;
     double gamma;
+    /*! \brief The time at the end of the algorithm. */
     double end_time;
+    /*! \brief The time at the start of the algorithm. */
     double start_time;
+    /*! \brief Starting threshold. */
     double start_threshold;
+    /*! \brief Average cost of recent solutions. */
     double avg_cost;
+    /*! \brief Temperature. */
     double temp;
+    /*! \brief Annealing factor. */
     double ann_fact;
+    /*! \brief Initial annealing factor. */
+    double init_ann_fact;
     bool warmup;
     /*! \brief Constructor.
      *  \param _end_time running time in seconds
      *  \param _alpha parameter used to calculate the running average
      *  \param _beta parameter used to decrease the annealing factor
      *  \param _gamma parameter used to increase the temperature
+     *  \param _ann_fact initial annealing factor
      */
     AdvancedController(double _end_time, double _alpha = 0.2,
-    double _beta = 0.9, double _gamma = 1.6) : alpha(_alpha), beta(_beta),
-    gamma(_gamma), end_time(_end_time), ann_fact(0.99999999), warmup(true) {}
+    double _beta = 0.9, double _gamma = 1.6, double _ann_fact = 0.9999) :
+    alpha(_alpha), beta(_beta), gamma(_gamma), end_time(_end_time),
+    ann_fact(_ann_fact), init_ann_fact(_ann_fact), warmup(true) {}
     void init() {
       avg_cost = base->getCurrCost();
     }
@@ -275,7 +296,8 @@
         else {
           // increase the temperature
           temp *= gamma;
-          ann_fact = 0.99999999; // !!!!!!!!!!!
+          // reset the annealing factor
+          ann_fact = init_ann_fact;
         }
         temp *= ann_fact;
         return elapsed_time < end_time;



More information about the Lemon-commits mailing list