Ajout des tests des evals

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1666 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-01-21 16:56:21 +00:00
commit 50359071ef
7 changed files with 90 additions and 3 deletions

View file

@ -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")

View file

@ -2,7 +2,9 @@
#define _moTestClass_h
#include <EO.h>
#include <eoEvalFunc.h>
#include <neighborhood/moNeighbor.h>
#include <neighborhood/moBackableNeighbor.h>
typedef EO<int> Solution;
@ -11,4 +13,20 @@ public:
virtual void move(Solution & _solution){}
};
class moDummyBackableNeighbor : public moBackableNeighbor<Solution,int>{
public:
virtual void move(Solution & _solution){}
virtual void moveBack(Solution & _solution){}
};
class moDummyEval: public eoEvalFunc<Solution>{
public:
void operator()(Solution& _sol){
if(_sol.invalid())
_sol.fitness(100);
else
_sol.fitness(_sol.fitness()+50);
}
};
#endif

View file

@ -0,0 +1,29 @@
#include "moTestClass.h"
#include <eval/moFullEvalByCopy.h>
#include <cstdlib>
#include <cassert>
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<moDummyNeighbor> test(eval);
sol.fitness(3);
//verif operator()
test(sol,neighbor);
assert(sol.fitness()==3);
std::cout << "[t-moFullEvalByCopy] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,29 @@
#include "moTestClass.h"
#include <eval/moFullEvalByModif.h>
#include <cstdlib>
#include <cassert>
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<moDummyBackableNeighbor> test(eval);
sol.fitness(3);
//verif operator()
test(sol,neighbor);
assert(sol.fitness()==3);
std::cout << "[t-moFullEvalByModif] => OK" << std::endl;
return EXIT_SUCCESS;
}