# HG changeset patch # User ladanyi # Date 1138572606 0 # Node ID fb4a2a84d3637c9ae205e326aba94a803fae0108 # Parent e9e27c5a53bf66b95d35d911036ff84832f15816 test for simann diff -r e9e27c5a53bf -r fb4a2a84d363 test/Makefile.am --- a/test/Makefile.am Sun Jan 29 22:07:52 2006 +0000 +++ b/test/Makefile.am Sun Jan 29 22:10:06 2006 +0000 @@ -35,7 +35,8 @@ unionfind_test \ ugraph_test \ xy_test \ - heap_test + heap_test \ + simann_test if HAVE_GLPK check_PROGRAMS += lp_test @@ -72,6 +73,7 @@ xy_test_SOURCES = xy_test.cc ugraph_test_SOURCES = ugraph_test.cc heap_test_SOURCES = heap_test.cc +simann_test_SOURCES = simann_test.cc lp_test_SOURCES = lp_test.cc lp_test_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) diff -r e9e27c5a53bf -r fb4a2a84d363 test/simann_test.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/simann_test.cc Sun Jan 29 22:10:06 2006 +0000 @@ -0,0 +1,42 @@ +#include + +using namespace lemon; + +class MyEntity : public EntityBase { +public: + double d, prev_d; + MyEntity() : d(100000.0) { srand48(time(0)); } + double mutate() { + prev_d = d; + if (drand48() < 0.8) { d += 1.0; } + else { d -= 1.0; } + return d; + } + void revert() { d = prev_d; } + MyEntity* clone() { return new MyEntity (*this); } + void randomize() {} +}; + +int main() { + SimAnn simann; + SimpleController ctrl; + simann.setController(ctrl); + MyEntity ent; + simann.setEntity(ent); + simann.run(); + + //MyEntity *best_ent = (MyEntity *) simann.getBestEntity(); + //std::cout << best_ent->d << std::endl; + + SimAnn simann2; + AdvancedController ctrl2(2.0); + simann2.setController(ctrl2); + MyEntity ent2; + simann2.setEntity(ent2); + simann2.run(); + + //MyEntity *best_ent2 = (MyEntity *) simann2.getBestEntity(); + //std::cout << best_ent2->d << std::endl; + + return 0; +}