From 50359071efb4977b00f6e9e04e2013070e4d9ee2 Mon Sep 17 00:00:00 2001 From: jhumeau Date: Thu, 21 Jan 2010 16:56:21 +0000 Subject: [PATCH] Ajout des tests des evals git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1666 331e1502-861f-0410-8da2-ba01fb791d7f --- branches/newMo/src/eval/moFullEvalByModif.h | 1 + .../newMo/src/explorer/moSimpleHCexplorer.h | 8 +++++ branches/newMo/src/neighborhood/moNeighbor.h | 4 +-- branches/newMo/test/CMakeLists.txt | 4 ++- branches/newMo/test/moTestClass.h | 18 ++++++++++++ branches/newMo/test/t-moFullEvalByCopy.cpp | 29 +++++++++++++++++++ branches/newMo/test/t-moFullEvalByModif.cpp | 29 +++++++++++++++++++ 7 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 branches/newMo/test/t-moFullEvalByCopy.cpp create mode 100644 branches/newMo/test/t-moFullEvalByModif.cpp diff --git a/branches/newMo/src/eval/moFullEvalByModif.h b/branches/newMo/src/eval/moFullEvalByModif.h index 03e630e65..9567aa31d 100644 --- a/branches/newMo/src/eval/moFullEvalByModif.h +++ b/branches/newMo/src/eval/moFullEvalByModif.h @@ -64,6 +64,7 @@ public: // tmp fitness value of the current solution Fitness tmpFit; + // save current fitness value tmpFit = _sol.fitness(); diff --git a/branches/newMo/src/explorer/moSimpleHCexplorer.h b/branches/newMo/src/explorer/moSimpleHCexplorer.h index 3618a14a2..f9bb03464 100644 --- a/branches/newMo/src/explorer/moSimpleHCexplorer.h +++ b/branches/newMo/src/explorer/moSimpleHCexplorer.h @@ -63,6 +63,14 @@ public: best=new Neighbor(); } + /** + * Destructor + */ + ~moSimpleHCexplorer(){ + delete current; + delete best; + } + /** * initParam: NOTHING TO DO */ diff --git a/branches/newMo/src/neighborhood/moNeighbor.h b/branches/newMo/src/neighborhood/moNeighbor.h index 6fadb2263..38531bcf7 100644 --- a/branches/newMo/src/neighborhood/moNeighbor.h +++ b/branches/newMo/src/neighborhood/moNeighbor.h @@ -43,11 +43,11 @@ /** * Container of the neighbor informations */ -template< class EOT , class Fitness > +template< class EOType , class Fitness > class moNeighbor : public eoObject, public eoPersistent { public: - + typedef EOType EOT; /** * Default Constructor */ diff --git a/branches/newMo/test/CMakeLists.txt b/branches/newMo/test/CMakeLists.txt index 09860566a..4a6d8d8eb 100644 --- a/branches/newMo/test/CMakeLists.txt +++ b/branches/newMo/test/CMakeLists.txt @@ -31,7 +31,9 @@ LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib) SET (TEST_LIST t-moNeighbor t-moBitNeighbor - t-moBitNeighborhood) + t-moBitNeighborhood + t-moFullEvalByCopy + t-moFullEvalByModif) FOREACH (test ${TEST_LIST}) SET ("T_${test}_SOURCES" "${test}.cpp") diff --git a/branches/newMo/test/moTestClass.h b/branches/newMo/test/moTestClass.h index 1a1299ca9..ca08fb8f6 100644 --- a/branches/newMo/test/moTestClass.h +++ b/branches/newMo/test/moTestClass.h @@ -2,7 +2,9 @@ #define _moTestClass_h #include +#include #include +#include typedef EO Solution; @@ -11,4 +13,20 @@ public: virtual void move(Solution & _solution){} }; +class moDummyBackableNeighbor : public moBackableNeighbor{ +public: + virtual void move(Solution & _solution){} + virtual void moveBack(Solution & _solution){} +}; + +class moDummyEval: public eoEvalFunc{ +public: + void operator()(Solution& _sol){ + if(_sol.invalid()) + _sol.fitness(100); + else + _sol.fitness(_sol.fitness()+50); + } +}; + #endif diff --git a/branches/newMo/test/t-moFullEvalByCopy.cpp b/branches/newMo/test/t-moFullEvalByCopy.cpp new file mode 100644 index 000000000..126902f51 --- /dev/null +++ b/branches/newMo/test/t-moFullEvalByCopy.cpp @@ -0,0 +1,29 @@ +#include "moTestClass.h" +#include + +#include +#include + +int main(){ + + //Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval + + std::cout << "[t-moFullEvalByCopy] => START" << std::endl; + + Solution sol; + moDummyNeighbor neighbor; + moDummyEval eval; + + //verif constructor + moFullEvalByCopy test(eval); + + sol.fitness(3); + + //verif operator() + test(sol,neighbor); + assert(sol.fitness()==3); + + std::cout << "[t-moFullEvalByCopy] => OK" << std::endl; + + return EXIT_SUCCESS; +} diff --git a/branches/newMo/test/t-moFullEvalByModif.cpp b/branches/newMo/test/t-moFullEvalByModif.cpp new file mode 100644 index 000000000..e7ac33ad5 --- /dev/null +++ b/branches/newMo/test/t-moFullEvalByModif.cpp @@ -0,0 +1,29 @@ +#include "moTestClass.h" +#include + +#include +#include + +int main(){ + + //Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval + + std::cout << "[t-moFullEvalByModif] => START" << std::endl; + + Solution sol; + moDummyBackableNeighbor neighbor; + moDummyEval eval; + + //verif constructor + moFullEvalByModif test(eval); + + sol.fitness(3); + + //verif operator() + test(sol,neighbor); + assert(sol.fitness()==3); + + std::cout << "[t-moFullEvalByModif] => OK" << std::endl; + + return EXIT_SUCCESS; +}