more docs
authorladanyi
Fri, 11 Feb 2005 14:56:40 +0000
changeset 114599c1aa395a58
parent 1144 1cfabf245433
child 1146 ebab0e5ec8b2
more docs
src/work/akos/simann.h
     1.1 --- a/src/work/akos/simann.h	Thu Feb 10 18:53:30 2005 +0000
     1.2 +++ b/src/work/akos/simann.h	Fri Feb 11 14:56:40 2005 +0000
     1.3 @@ -180,6 +180,7 @@
     1.4      double _temp = 1000.0, double _ann_fact = 0.9999) : iter(0), last_impr(0),
     1.5      max_iter(_max_iter), max_no_impr(_max_no_impr), temp(_temp),
     1.6      ann_fact(_ann_fact) {}
     1.7 +    /*! \brief This is called when a neighbouring state gets accepted. */
     1.8      void acceptEvent() {
     1.9        iter++;
    1.10      }
    1.11 @@ -215,6 +216,16 @@
    1.12  
    1.13    /*! \brief A controller with preset running time for the simulated annealing
    1.14     *  class.
    1.15 +   *
    1.16 +   *  With this controller you can set the running time of the annealing
    1.17 +   *  process in advance. It works the following way: the controller measures
    1.18 +   *  a kind of divergence. The divergence is the difference of the average
    1.19 +   *  cost of the recently found solutions the cost of the best found one. In
    1.20 +   *  case this divergence is greater than a given threshold, then we decrease
    1.21 +   *  the annealing factor, that is we cool the system faster. In case the
    1.22 +   *  divergence is lower than the threshold, then we increase the temperature.
    1.23 +   *  The threshold is a function of the elapsed time which reaches zero at the
    1.24 +   *  desired end time.
    1.25     */
    1.26    class AdvancedController : public SimAnnBase::Controller {
    1.27    private:
    1.28 @@ -227,22 +238,32 @@
    1.29      double alpha;
    1.30      double beta;
    1.31      double gamma;
    1.32 +    /*! \brief The time at the end of the algorithm. */
    1.33      double end_time;
    1.34 +    /*! \brief The time at the start of the algorithm. */
    1.35      double start_time;
    1.36 +    /*! \brief Starting threshold. */
    1.37      double start_threshold;
    1.38 +    /*! \brief Average cost of recent solutions. */
    1.39      double avg_cost;
    1.40 +    /*! \brief Temperature. */
    1.41      double temp;
    1.42 +    /*! \brief Annealing factor. */
    1.43      double ann_fact;
    1.44 +    /*! \brief Initial annealing factor. */
    1.45 +    double init_ann_fact;
    1.46      bool warmup;
    1.47      /*! \brief Constructor.
    1.48       *  \param _end_time running time in seconds
    1.49       *  \param _alpha parameter used to calculate the running average
    1.50       *  \param _beta parameter used to decrease the annealing factor
    1.51       *  \param _gamma parameter used to increase the temperature
    1.52 +     *  \param _ann_fact initial annealing factor
    1.53       */
    1.54      AdvancedController(double _end_time, double _alpha = 0.2,
    1.55 -    double _beta = 0.9, double _gamma = 1.6) : alpha(_alpha), beta(_beta),
    1.56 -    gamma(_gamma), end_time(_end_time), ann_fact(0.99999999), warmup(true) {}
    1.57 +    double _beta = 0.9, double _gamma = 1.6, double _ann_fact = 0.9999) :
    1.58 +    alpha(_alpha), beta(_beta), gamma(_gamma), end_time(_end_time),
    1.59 +    ann_fact(_ann_fact), init_ann_fact(_ann_fact), warmup(true) {}
    1.60      void init() {
    1.61        avg_cost = base->getCurrCost();
    1.62      }
    1.63 @@ -275,7 +296,8 @@
    1.64          else {
    1.65            // increase the temperature
    1.66            temp *= gamma;
    1.67 -          ann_fact = 0.99999999; // !!!!!!!!!!!
    1.68 +          // reset the annealing factor
    1.69 +          ann_fact = init_ann_fact;
    1.70          }
    1.71          temp *= ann_fact;
    1.72          return elapsed_time < end_time;