[Lemon-commits] [lemon_svn] ladanyi: r2496 - hugo/trunk/test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:53:06 CET 2006
Author: ladanyi
Date: Sun Jan 29 23:10:06 2006
New Revision: 2496
Added:
hugo/trunk/test/simann_test.cc
Modified:
hugo/trunk/test/Makefile.am
Log:
test for simann
Modified: hugo/trunk/test/Makefile.am
==============================================================================
--- hugo/trunk/test/Makefile.am (original)
+++ hugo/trunk/test/Makefile.am Sun Jan 29 23:10:06 2006
@@ -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)
Added: hugo/trunk/test/simann_test.cc
==============================================================================
--- (empty file)
+++ hugo/trunk/test/simann_test.cc Sun Jan 29 23:10:06 2006
@@ -0,0 +1,42 @@
+#include <lemon/simann.h>
+
+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;
+}
More information about the Lemon-commits
mailing list