COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/akos/simann_test.cc @ 941:186aa53d2802

Last change on this file since 941:186aa53d2802 was 918:bb77eaa8fa0e, checked in by Akos Ladanyi, 20 years ago

Initial revision.

File size: 722 bytes
RevLine 
[918]1#include "SimAnn.h"
2#include <cstdlib>
3#include <cmath>
4#include <iostream>
5
6class MyController : public SimAnnBase::Controller {
7public:
8  long MaxIter, MaxNoImpr;
9  double af;
10  MyController() {
11    MaxIter = 500000;
12    MaxNoImpr = 20000;
13    af = 0.9999;
14    T = 1000;
15  }
16  bool next() {
17    T *= af;
18    std::cout << T << std::endl;
19    return !((sab->getIter() > MaxIter) || (sab->getIter() - sab->getLastImpr() > MaxNoImpr));
20  }
21  bool accept(double cost) {
22    return (drand48() <= exp(cost / T));
23  }
24};
25
26class MyEntity {
27public:
28  void init() {}
29  double mutate() { return 10.0; }
30};
31
32int main() {
33  SimAnn<MyEntity> sa;
34  MyController c;
35  sa.setController(c);
36  MyEntity ent;
37  sa.setEnt(ent);
38  sa.run();
39}
Note: See TracBrowser for help on using the repository browser.