COIN-OR::LEMON - Graph Library

source: lemon-0.x/test/simann_test.cc @ 1951:cb7a6e0573bc

Last change on this file since 1951:cb7a6e0573bc was 1921:fb4a2a84d363, checked in by Akos Ladanyi, 18 years ago

test for simann

File size: 909 bytes
Line 
1#include <lemon/simann.h>
2
3using namespace lemon;
4
5class MyEntity : public EntityBase {
6public:
7  double d, prev_d;
8  MyEntity() : d(100000.0) { srand48(time(0)); }
9  double mutate() {
10    prev_d = d;
11    if (drand48() < 0.8) { d += 1.0; }
12    else { d -= 1.0; }
13    return d;
14  }
15  void revert() { d = prev_d; }
16  MyEntity* clone() { return new MyEntity (*this); }
17  void randomize() {}
18};
19
20int main() {
21  SimAnn simann;
22  SimpleController ctrl;
23  simann.setController(ctrl);
24  MyEntity ent;
25  simann.setEntity(ent);
26  simann.run();
27
28  //MyEntity *best_ent = (MyEntity *) simann.getBestEntity();
29  //std::cout << best_ent->d << std::endl;
30
31  SimAnn simann2;
32  AdvancedController ctrl2(2.0);
33  simann2.setController(ctrl2);
34  MyEntity ent2;
35  simann2.setEntity(ent2);
36  simann2.run();
37
38  //MyEntity *best_ent2 = (MyEntity *) simann2.getBestEntity();
39  //std::cout << best_ent2->d << std::endl;
40
41  return 0;
42}
Note: See TracBrowser for help on using the repository browser.