Test des Neighborhoods ajouté
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1665 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
2785b086a4
commit
88afa96663
8 changed files with 164 additions and 14 deletions
|
|
@ -28,7 +28,10 @@ LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib)
|
|||
### 3) Define your targets and link the librairies
|
||||
######################################################################################
|
||||
|
||||
SET (TEST_LIST t-moNeighbor)
|
||||
SET (TEST_LIST
|
||||
t-moNeighbor
|
||||
t-moBitNeighbor
|
||||
t-moBitNeighborhood)
|
||||
|
||||
FOREACH (test ${TEST_LIST})
|
||||
SET ("T_${test}_SOURCES" "${test}.cpp")
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
typedef EO<int> Solution;
|
||||
|
||||
class moDummyNeighbor : public moNeighbor<Solution,int>{
|
||||
|
||||
public:
|
||||
virtual void move(Solution & _solution){}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
54
branches/newMo/test/t-moBitNeighbor.cpp
Normal file
54
branches/newMo/test/t-moBitNeighbor.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include <neighborhood/moBitNeighbor.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moBitNeighbor] => START" << std::endl;
|
||||
|
||||
//init sol
|
||||
eoBit<int> sol;
|
||||
sol.push_back(true);
|
||||
sol.push_back(false);
|
||||
sol.push_back(true);
|
||||
|
||||
//verif du constructeur vide
|
||||
moBitNeighbor<int> test1;
|
||||
assert(test1.index()==0);
|
||||
|
||||
//verif du constructeur indiquant le bit
|
||||
moBitNeighbor<int> hop(34);
|
||||
assert(hop.index()==34);
|
||||
|
||||
//verif du setter d'index et du constructeur de copy
|
||||
test1.index(6);
|
||||
test1.fitness(2);
|
||||
moBitNeighbor<int> test2(test1);
|
||||
assert(test2.index()==6);
|
||||
assert(test2.fitness()==2);
|
||||
|
||||
//verif du getter
|
||||
assert(test1.index()==6);
|
||||
|
||||
//verif de l'operateur=
|
||||
test1.fitness(8);
|
||||
test1.index(2);
|
||||
test2=test1;
|
||||
assert(test2.fitness()==8);
|
||||
assert(test2.index()==2);
|
||||
|
||||
//verif de move
|
||||
test2.move(sol);
|
||||
assert(!sol[2]);
|
||||
|
||||
//verif de moveBack
|
||||
test2.moveBack(sol);
|
||||
assert(sol[2]);
|
||||
|
||||
test1.printOn(std::cout);
|
||||
test2.printOn(std::cout);
|
||||
|
||||
std::cout << "[t-moBitNeighbor] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
43
branches/newMo/test/t-moBitNeighborhood.cpp
Normal file
43
branches/newMo/test/t-moBitNeighborhood.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include <neighborhood/moBitNeighborhood.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moBitNeighborhood] => START" << std::endl;
|
||||
|
||||
//init sol
|
||||
eoBit<int> sol;
|
||||
sol.push_back(true);
|
||||
sol.push_back(false);
|
||||
sol.push_back(true);
|
||||
|
||||
moBitNeighbor<int> neighbor;
|
||||
|
||||
//verif du constructeur vide
|
||||
moBitNeighborhood<moBitNeighbor<int> > test;
|
||||
assert(test.position()==0);
|
||||
|
||||
//verif du hasneighbor
|
||||
assert(test.hasNeighbor(sol));
|
||||
|
||||
//verif de init
|
||||
test.init(sol, neighbor);
|
||||
assert(neighbor.index()==0);
|
||||
assert(test.position()==0);
|
||||
|
||||
//verif du next
|
||||
test.next(sol, neighbor);
|
||||
assert(neighbor.index()==1);
|
||||
assert(test.position()==1);
|
||||
|
||||
//verif du cont
|
||||
test.next(sol, neighbor);
|
||||
assert(test.cont(sol));
|
||||
test.next(sol, neighbor);
|
||||
assert(!test.cont(sol));
|
||||
|
||||
std::cout << "[t-moBitNeighborhood] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -5,6 +5,24 @@
|
|||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moNeighbor] => START" << std::endl;
|
||||
|
||||
moDummyNeighbor test1, test2;
|
||||
|
||||
test1.fitness(3);
|
||||
test2=test1;
|
||||
|
||||
assert(test1.fitness()==test2.fitness());
|
||||
|
||||
moDummyNeighbor test3(test1);
|
||||
|
||||
assert(test1.fitness()==test3.fitness());
|
||||
|
||||
test1.printOn(std::cout);
|
||||
test2.printOn(std::cout);
|
||||
test3.printOn(std::cout);
|
||||
|
||||
std::cout << "[t-moNeighbor] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue