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:
parent
88afa96663
commit
50359071ef
7 changed files with 90 additions and 3 deletions
|
|
@ -64,6 +64,7 @@ public:
|
||||||
// tmp fitness value of the current solution
|
// tmp fitness value of the current solution
|
||||||
Fitness tmpFit;
|
Fitness tmpFit;
|
||||||
|
|
||||||
|
|
||||||
// save current fitness value
|
// save current fitness value
|
||||||
tmpFit = _sol.fitness();
|
tmpFit = _sol.fitness();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,14 @@ public:
|
||||||
best=new Neighbor();
|
best=new Neighbor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
|
~moSimpleHCexplorer(){
|
||||||
|
delete current;
|
||||||
|
delete best;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initParam: NOTHING TO DO
|
* initParam: NOTHING TO DO
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@
|
||||||
/**
|
/**
|
||||||
* Container of the neighbor informations
|
* Container of the neighbor informations
|
||||||
*/
|
*/
|
||||||
template< class EOT , class Fitness >
|
template< class EOType , class Fitness >
|
||||||
class moNeighbor : public eoObject, public eoPersistent
|
class moNeighbor : public eoObject, public eoPersistent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef EOType EOT;
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,9 @@ LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib)
|
||||||
SET (TEST_LIST
|
SET (TEST_LIST
|
||||||
t-moNeighbor
|
t-moNeighbor
|
||||||
t-moBitNeighbor
|
t-moBitNeighbor
|
||||||
t-moBitNeighborhood)
|
t-moBitNeighborhood
|
||||||
|
t-moFullEvalByCopy
|
||||||
|
t-moFullEvalByModif)
|
||||||
|
|
||||||
FOREACH (test ${TEST_LIST})
|
FOREACH (test ${TEST_LIST})
|
||||||
SET ("T_${test}_SOURCES" "${test}.cpp")
|
SET ("T_${test}_SOURCES" "${test}.cpp")
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
#define _moTestClass_h
|
#define _moTestClass_h
|
||||||
|
|
||||||
#include <EO.h>
|
#include <EO.h>
|
||||||
|
#include <eoEvalFunc.h>
|
||||||
#include <neighborhood/moNeighbor.h>
|
#include <neighborhood/moNeighbor.h>
|
||||||
|
#include <neighborhood/moBackableNeighbor.h>
|
||||||
|
|
||||||
typedef EO<int> Solution;
|
typedef EO<int> Solution;
|
||||||
|
|
||||||
|
|
@ -11,4 +13,20 @@ public:
|
||||||
virtual void move(Solution & _solution){}
|
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
|
#endif
|
||||||
|
|
|
||||||
29
branches/newMo/test/t-moFullEvalByCopy.cpp
Normal file
29
branches/newMo/test/t-moFullEvalByCopy.cpp
Normal 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;
|
||||||
|
}
|
||||||
29
branches/newMo/test/t-moFullEvalByModif.cpp
Normal file
29
branches/newMo/test/t-moFullEvalByModif.cpp
Normal 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;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue