test/simann_test.cc
changeset 2390 8450951a8e2d
parent 1956 a055123339d5
child 2391 14a343be7a5a
equal deleted inserted replaced
1:6cb7a981d131 2:8c175320d1a2
    21 using namespace lemon;
    21 using namespace lemon;
    22 
    22 
    23 class MyEntity : public EntityBase {
    23 class MyEntity : public EntityBase {
    24 public:
    24 public:
    25   double d, prev_d;
    25   double d, prev_d;
    26   MyEntity() : d(100000.0) { srand48(time(0)); }
    26   MyEntity() : d(100000.0) {}
    27   double mutate() {
    27   double mutate() {
    28     prev_d = d;
    28     prev_d = d;
    29     if (drand48() < 0.8) { d += 1.0; }
    29     if (rnd.boolean(0.8)) { d += 1.0; }
    30     else { d -= 1.0; }
    30     else { d -= 1.0; }
    31     return d;
    31     return d;
    32   }
    32   }
    33   void revert() { d = prev_d; }
    33   void revert() { d = prev_d; }
    34   MyEntity* clone() { return new MyEntity (*this); }
    34   MyEntity* clone() { return new MyEntity (*this); }