test/simann_test.cc
author alpar
Wed, 01 Feb 2006 11:33:16 +0000
changeset 1937 7a7a1f95cc24
child 1956 a055123339d5
permissions -rw-r--r--
Some useful scripts:
check-compiler: test whether the repo compiles warningless
with various compilers.
check-integrity: checks whether everything is svn-added,
the makefiles are correct etc.
release: creates a version numbered release. Is modifies the repository.
DO NOT PLAY WITH IT!
     1 #include <lemon/simann.h>
     2 
     3 using namespace lemon;
     4 
     5 class MyEntity : public EntityBase {
     6 public:
     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 
    20 int 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 }