Updated because of the recent changes in simann.h.
authorladanyi
Thu, 04 Nov 2004 18:52:31 +0000
changeset 95875f749682240
parent 957 4dd4eaee28e7
child 959 c80ef5912903
Updated because of the recent changes in simann.h.
src/work/akos/simann_test.cc
     1.1 --- a/src/work/akos/simann_test.cc	Thu Nov 04 18:48:58 2004 +0000
     1.2 +++ b/src/work/akos/simann_test.cc	Thu Nov 04 18:52:31 2004 +0000
     1.3 @@ -1,48 +1,18 @@
     1.4 -#include "simann.h"
     1.5  #include <cstdlib>
     1.6  #include <cmath>
     1.7 -#include <iostream>
     1.8 +#include "simann.h"
     1.9  
    1.10  using namespace lemon;
    1.11  
    1.12 -class MyController : public SimAnnBase::Controller {
    1.13 -public:
    1.14 -  long iter, last_impr, max_iter, max_no_impr;
    1.15 -  double temp, annealing_factor;
    1.16 -  MyController() {
    1.17 -    iter = last_impr = 0;
    1.18 -    max_iter = 500000;
    1.19 -    max_no_impr = 20000;
    1.20 -    annealing_factor = 0.9999;
    1.21 -    temp = 1000;
    1.22 -  }
    1.23 -  void acceptEvent() {
    1.24 -    iter++;
    1.25 -  }
    1.26 -  void improveEvent() {
    1.27 -    last_impr = iter;
    1.28 -  }
    1.29 -  void rejectEvent() {
    1.30 -    iter++;
    1.31 -  }
    1.32 -  bool next() {
    1.33 -    temp *= annealing_factor;
    1.34 -    bool quit = (iter > max_iter) || (iter - last_impr > max_no_impr);
    1.35 -    return !quit;
    1.36 -  }
    1.37 -  bool accept(double cost_diff) {
    1.38 -    return (drand48() <= exp(cost_diff / temp));
    1.39 -  }
    1.40 -};
    1.41 -
    1.42  class MyEntity {
    1.43  public:
    1.44    double mutate() { return 10.0; }
    1.45 +  void revert() {}
    1.46  };
    1.47  
    1.48  int main() {
    1.49    SimAnn<MyEntity> simann;
    1.50 -  MyController ctrl;
    1.51 +  SimpleController ctrl;
    1.52    simann.setController(ctrl);
    1.53    MyEntity ent;
    1.54    simann.setEntity(ent);