COIN-OR::LEMON - Graph Library

Changeset 958:75f749682240 in lemon-0.x for src/work


Ignore:
Timestamp:
11/04/04 19:52:31 (20 years ago)
Author:
Akos Ladanyi
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1341
Message:

Updated because of the recent changes in simann.h.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/akos/simann_test.cc

    r942 r958  
    1 #include "simann.h"
    21#include <cstdlib>
    32#include <cmath>
    4 #include <iostream>
     3#include "simann.h"
    54
    65using namespace lemon;
    7 
    8 class MyController : public SimAnnBase::Controller {
    9 public:
    10   long iter, last_impr, max_iter, max_no_impr;
    11   double temp, annealing_factor;
    12   MyController() {
    13     iter = last_impr = 0;
    14     max_iter = 500000;
    15     max_no_impr = 20000;
    16     annealing_factor = 0.9999;
    17     temp = 1000;
    18   }
    19   void acceptEvent() {
    20     iter++;
    21   }
    22   void improveEvent() {
    23     last_impr = iter;
    24   }
    25   void rejectEvent() {
    26     iter++;
    27   }
    28   bool next() {
    29     temp *= annealing_factor;
    30     bool quit = (iter > max_iter) || (iter - last_impr > max_no_impr);
    31     return !quit;
    32   }
    33   bool accept(double cost_diff) {
    34     return (drand48() <= exp(cost_diff / temp));
    35   }
    36 };
    376
    387class MyEntity {
    398public:
    409  double mutate() { return 10.0; }
     10  void revert() {}
    4111};
    4212
    4313int main() {
    4414  SimAnn<MyEntity> simann;
    45   MyController ctrl;
     15  SimpleController ctrl;
    4616  simann.setController(ctrl);
    4717  MyEntity ent;
Note: See TracChangeset for help on using the changeset viewer.