Test & Update for new version
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2678 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
3aaa0bd4e7
commit
f2b13bc8ba
18 changed files with 71 additions and 187 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUTimer.cu>
|
<t-moGPUTimer.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
<moTestClass.h>
|
<moTestClass.h>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
Karima Boufaras, Thé van Luong
|
||||||
|
|
||||||
This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUBitNeighbor.cu>
|
<t-moGPUBitNeighbor.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ int main() {
|
||||||
|
|
||||||
assert(test1.className()=="moGPUBitNeighbor");
|
assert(test1.className()=="moGPUBitNeighbor");
|
||||||
|
|
||||||
std::cout << "[t-moCudaBitNeighbor] => OK" << std::endl;
|
std::cout << "[t-moGPUBitNeighbor] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUBitVector.cu>
|
<t-moGPUBitVector.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <GPUType/moGPUBitVector.h>
|
#include <GPUType/moGPUBitVector.h>
|
||||||
#include <problems/eval/EvalOneMax.h>
|
#include <problems/eval/moGPUEvalOneMax.h>
|
||||||
#include <eo>
|
#include <eo>
|
||||||
|
|
||||||
typedef moGPUBitVector<eoMaximizingFitness> Solution;
|
typedef moGPUBitVector<eoMaximizingFitness> Solution;
|
||||||
|
|
@ -47,7 +47,7 @@ int main() {
|
||||||
|
|
||||||
std::cout << "[t-moGPUBitVector] => START" << std::endl;
|
std::cout << "[t-moGPUBitVector] => START" << std::endl;
|
||||||
|
|
||||||
EvalOneMax<Solution> eval;
|
moGPUEvalOneMax<Solution> eval;
|
||||||
|
|
||||||
//test default constructor
|
//test default constructor
|
||||||
Solution _sol;
|
Solution _sol;
|
||||||
|
|
@ -75,7 +75,7 @@ int main() {
|
||||||
assert(sol.fitness()==sum);
|
assert(sol.fitness()==sum);
|
||||||
|
|
||||||
//test size getter
|
//test size getter
|
||||||
assert(_sol.size()==0);
|
assert(_sol.size()==5);
|
||||||
assert(sol1.size()==5);
|
assert(sol1.size()==5);
|
||||||
|
|
||||||
//test size setter
|
//test size setter
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUEvalOneMax.cu>
|
<t-moGPUEvalOneMax.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ int main() {
|
||||||
|
|
||||||
|
|
||||||
Solution sol(5);
|
Solution sol(5);
|
||||||
moGPuEvalOneMax<Solution> eval;
|
moGPUEvalOneMax<Solution> eval;
|
||||||
int sum=0;
|
int sum=0;
|
||||||
|
|
||||||
eval(sol);
|
eval(sol);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUIntVector.cu>
|
<t-moGPUIntVector.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
@ -54,10 +54,10 @@ int main() {
|
||||||
Solution sol2(3);
|
Solution sol2(3);
|
||||||
|
|
||||||
//test copy constructor
|
//test copy constructor
|
||||||
sol1.fitness(500);
|
sol1.fitness(50);
|
||||||
Solution sol(sol1);
|
Solution sol(sol1);
|
||||||
assert(sol.size()==5);
|
assert(sol.size()==5);
|
||||||
assert(sol.fitness()==500);
|
assert(sol.fitness()==50);
|
||||||
for(int i=0;i<5;i++)
|
for(int i=0;i<5;i++)
|
||||||
assert(sol[i]==sol1[i]);
|
assert(sol[i]==sol1[i]);
|
||||||
|
|
||||||
|
|
@ -82,10 +82,10 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//test assignement operator
|
//test assignement operator
|
||||||
sol2.fitness(200);
|
sol2.fitness(20);
|
||||||
sol1=sol2;
|
sol1=sol2;
|
||||||
assert(sol1.size()==3);
|
assert(sol1.size()==3);
|
||||||
assert(sol1.fitness()==200);
|
assert(sol1.fitness()==20);
|
||||||
for(int i=0;i<3;i++)
|
for(int i=0;i<3;i++)
|
||||||
assert(sol1[i]==sol2[i]);
|
assert(sol1[i]==sol2[i]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUMemory.cu>
|
<t-moGPUMemory.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUNeighborhoodSizeUtils.cpp>
|
<t-moGPUNeighborhoodSizeUtils.cpp>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Boufaras Karima, Thé Van Luong
|
Karima Boufaras, Thé Van Luong
|
||||||
|
|
||||||
This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
abiding by the rules of distribution of free software. You can ue,
|
abiding by the rules of distribution of free software. You can ue,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUObject.cu>
|
<t-moGPUObject.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
@ -41,10 +41,14 @@
|
||||||
__device__ int * dev_data;
|
__device__ int * dev_data;
|
||||||
|
|
||||||
//kernel to launch to test GPU global variable
|
//kernel to launch to test GPU global variable
|
||||||
|
|
||||||
__global__ void testKernel(int * _data,unsigned _size){
|
__global__ void testKernel(int * _data,unsigned _size){
|
||||||
|
|
||||||
// The thread identifier within a grid block's
|
// The thread identifier within a grid block's
|
||||||
int id = blockIdx.x * blockDim.x + threadIdx.x;
|
int id = blockIdx.x * blockDim.x + threadIdx.x;
|
||||||
|
|
||||||
if(id<_size)
|
if(id<_size)
|
||||||
|
|
||||||
_data[id]=2*dev_data[id];
|
_data[id]=2*dev_data[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-OneMaxIncrEval.cu>
|
<t-OneMaxIncrEval.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
@ -37,9 +37,10 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <neighborhood/moGPUBitNeighbor.h>
|
#include <neighborhood/moGPUBitNeighbor.h>
|
||||||
#include <GPUType/moGPUBitVector.h>
|
#include <GPUType/moGPUBitVector.h>
|
||||||
#include <problems/eval/EvalOneMax.h>
|
#include <problems/eval/moGPUEvalOneMax.h>
|
||||||
#include <problems/eval/OneMaxIncrEval.h>
|
#include <problems/eval/moGPUOneMaxIncrEval.h>
|
||||||
|
|
||||||
|
#define NB_POS 1
|
||||||
|
|
||||||
typedef moGPUBitVector<eoMaximizingFitness> Solution;
|
typedef moGPUBitVector<eoMaximizingFitness> Solution;
|
||||||
typedef moGPUBitNeighbor <Solution,eoMaximizingFitness> Neighbor;
|
typedef moGPUBitNeighbor <Solution,eoMaximizingFitness> Neighbor;
|
||||||
|
|
@ -47,12 +48,12 @@ typedef moGPUBitNeighbor <Solution,eoMaximizingFitness> Neighbor;
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
|
|
||||||
std::cout << "[t-OneMaxIncrEval] => START" << std::endl;
|
std::cout << "[t-moGPUOneMaxIncrEval] => START" << std::endl;
|
||||||
|
|
||||||
|
|
||||||
Solution sol(5);
|
Solution sol(5);
|
||||||
EvalOneMax<Solution> eval;
|
moGPUEvalOneMax<Solution> eval;
|
||||||
OneMaxIncrEval<Neighbor> incr_eval;
|
moGPUOneMaxIncrEval<Neighbor> incr_eval;
|
||||||
int sum=0;
|
int sum=0;
|
||||||
int fitness=0;
|
int fitness=0;
|
||||||
|
|
||||||
|
|
@ -66,18 +67,17 @@ int main() {
|
||||||
eval(sol);
|
eval(sol);
|
||||||
assert((int)(sol.fitness())==0);
|
assert((int)(sol.fitness())==0);
|
||||||
|
|
||||||
|
sol[0]=1;
|
||||||
fitness=incr_eval(sol,fitness,0);
|
fitness=incr_eval(sol,fitness,0);
|
||||||
sol[0]=1;
|
assert((int)(fitness)==1);
|
||||||
eval(sol);
|
|
||||||
assert((int)(sol.fitness())==1);
|
assert((int)(sol.fitness())==1);
|
||||||
|
|
||||||
fitness=incr_eval(sol,fitness,0);
|
sol[2]=1;
|
||||||
sol[0]=0;
|
fitness=incr_eval(sol,fitness,2);
|
||||||
eval(sol);
|
assert((int)(fitness)==2);
|
||||||
assert((int)(sol.fitness())==0);
|
assert((int)(sol.fitness())==2);
|
||||||
|
|
||||||
std::cout << "[t-OneMaxIncrEval] => OK" << std::endl;
|
std::cout << "[t-moGPUOneMaxIncrEval] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUPermutationVector.cu>
|
<t-moGPUPermutationVector.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
@ -54,19 +54,18 @@ int main() {
|
||||||
Solution sol2(3);
|
Solution sol2(3);
|
||||||
|
|
||||||
//test copy constructor
|
//test copy constructor
|
||||||
sol1.fitness(200);
|
sol1.fitness(20);
|
||||||
Solution sol(sol1);
|
Solution sol(sol1);
|
||||||
assert(sol.size()==5);
|
assert(sol.size()==5);
|
||||||
assert(sol.fitness()==200);
|
assert(sol.fitness()==20);
|
||||||
for(int i=0;i<5;i++)
|
for(int i=0;i<5;i++)
|
||||||
assert(sol[i]==sol1[i]);
|
assert(sol[i]==sol1[i]);
|
||||||
|
|
||||||
//test discret vector (create) & getter
|
//test discret vector create & getter
|
||||||
for(int i=0;i<5;i++)
|
for(int i=0;i<5;i++)
|
||||||
assert((sol1[i]>=0)||(sol1[i]<5));
|
assert((sol1[i]>=0)||(sol1[i]<5));
|
||||||
|
|
||||||
//test size getter
|
//test size getter
|
||||||
assert(_sol.size()==0);
|
|
||||||
assert(sol1.size()==5);
|
assert(sol1.size()==5);
|
||||||
assert(sol2.size()==3);
|
assert(sol2.size()==3);
|
||||||
|
|
||||||
|
|
@ -78,12 +77,12 @@ int main() {
|
||||||
//test discret vector
|
//test discret vector
|
||||||
for(int i=0;i<3;i++)
|
for(int i=0;i<3;i++)
|
||||||
assert((sol2[i]>=0)||(sol2[i]<3));
|
assert((sol2[i]>=0)||(sol2[i]<3));
|
||||||
sol2.fitness(300);
|
sol2.fitness(30);
|
||||||
|
|
||||||
//test assignement operator
|
//test assignement operator
|
||||||
sol1=sol2;
|
sol1=sol2;
|
||||||
assert(sol1.size()==3);
|
assert(sol1.size()==3);
|
||||||
assert(sol1.fitness()==300);
|
assert(sol1.fitness()==30);
|
||||||
for(int i=0;i<3;i++)
|
for(int i=0;i<3;i++)
|
||||||
assert(sol1[i]==sol2[i]);
|
assert(sol1[i]==sol2[i]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPURealVector.cu>
|
<t-moGPURealVector.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
@ -55,18 +55,19 @@ int main() {
|
||||||
Solution sol2(3);
|
Solution sol2(3);
|
||||||
|
|
||||||
//test copy constructor
|
//test copy constructor
|
||||||
sol1.fitness(100);
|
sol1.fitness(10);
|
||||||
Solution sol(sol1);
|
Solution sol(sol1);
|
||||||
assert(sol.size()==5);
|
assert(sol.size()==5);
|
||||||
assert(sol.fitness()==100);
|
assert(sol.fitness()==10);
|
||||||
for(int i=0;i<5;i++)
|
for(int i=0;i<5;i++)
|
||||||
assert(sol[i]==sol1[i]);
|
assert(sol[i]==sol1[i]);
|
||||||
|
|
||||||
//test Real vector (create)& getter
|
//test Real vector (create)& getter
|
||||||
float tmp;
|
int tmp,tmp1;
|
||||||
for(int i=0;i<5;i++){
|
tmp=(1/(sol1[0]+1))*10;
|
||||||
tmp=1/sol1[i];
|
tmp1=(int)(1/(sol1[0]+));
|
||||||
assert(abs(tmp)>0);
|
|
||||||
|
assert(tmp1>tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//test size getter
|
//test size getter
|
||||||
|
|
@ -80,10 +81,10 @@ int main() {
|
||||||
assert(sol[i]==sol1[i]);
|
assert(sol[i]==sol1[i]);
|
||||||
|
|
||||||
//test assignement operator
|
//test assignement operator
|
||||||
sol2.fitness(200);
|
sol2.fitness(20);
|
||||||
sol1=sol2;
|
sol1=sol2;
|
||||||
assert(sol1.size()==3);
|
assert(sol1.size()==3);
|
||||||
assert(sol1.fitness()==200);
|
assert(sol1.fitness()==20);
|
||||||
for(int i=0;i<3;i++)
|
for(int i=0;i<3;i++)
|
||||||
assert(sol1[i]==sol2[i]);
|
assert(sol1[i]==sol2[i]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUXBitFlippingNeighbor.cu>
|
<t-moGPUXBitFlippingNeighbor.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUXChangeNeighbor.cpp>
|
<t-moGPUXChangeNeighbor.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Boufaras Karima, Thé Van Luong
|
Karima Boufaras, Thé Van Luong
|
||||||
|
|
||||||
This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
abiding by the rules of distribution of free software. You can ue,
|
abiding by the rules of distribution of free software. You can ue,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUXChangeNeighborhood.cpp>
|
<t-moGPUXChange.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
@ -36,18 +36,18 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <eoInt.h>
|
#include <eoInt.h>
|
||||||
#include <neighborhood/moGPUXSwapNeighbor.h>
|
#include <neighborhood/moGPUXSwapN.h>
|
||||||
#include <neighborhood/moXGPUChangeNeighborhood.h>
|
#include <neighborhood/moGPUXChange.h>
|
||||||
#include <neighborhood/moGPUNeighborhoodSizeUtils.h>
|
#include <neighborhood/moGPUNeighborhoodSizeUtils.h>
|
||||||
#include <eo>
|
#include <eo>
|
||||||
|
|
||||||
typedef eoInt<eoMaximizingFitness> Solution;
|
typedef eoInt<eoMaximizingFitness> Solution;
|
||||||
typedef moXSwapNeighbor<Solution> Neighbor;
|
typedef moGPUXSwapN<Solution> Neighbor;
|
||||||
typedef moXChangeNeighborhood<Neighbor> Neighborhood;
|
typedef moGPUXChange<Neighbor> Neighborhood;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
std::cout << "[t-moGPUXChangeNeighborhood] => START" << std::endl;
|
std::cout << "[t-moGPUXChange] => START" << std::endl;
|
||||||
|
|
||||||
//test factorial
|
//test factorial
|
||||||
assert(factorial(10) == 3628800);
|
assert(factorial(10) == 3628800);
|
||||||
|
|
@ -171,7 +171,7 @@ int main() {
|
||||||
delete[] (second);
|
delete[] (second);
|
||||||
delete[] (third);
|
delete[] (third);
|
||||||
delete[] (forth);
|
delete[] (forth);
|
||||||
std::cout << "[t-moGPUXChangeNeighborhood] => OK" << std::endl;
|
std::cout << "[t-moGPUXChange] => OK" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUXSwapNeighbor.cpp>
|
<t-moGPUXSwapNeighbor.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
<t-moGPUXBitFlippingNeighbor.cpp>
|
<t-moGPUXBitFlippingN.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <neighborhood/moGPUXBitFlippingNeighbor.h>
|
#include <neighborhood/moGPUXBitFlippingN.h>
|
||||||
#include <eo>
|
#include <eo>
|
||||||
#include <ga/eoBit.h>
|
#include <ga/eoBit.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
||||||
/*
|
|
||||||
<t-moGPUXSwapNeighbor.cpp>
|
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
|
||||||
|
|
||||||
This software is governed by the CeCILL license under French law and
|
|
||||||
abiding by the rules of distribution of free software. You can use,
|
|
||||||
modify and/ or redistribute the software under the terms of the CeCILL
|
|
||||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
|
||||||
"http://www.cecill.info".
|
|
||||||
|
|
||||||
As a counterpart to the access to the source code and rights to copy,
|
|
||||||
modify and redistribute granted by the license, users are provided only
|
|
||||||
with a limited warranty and the software's author, the holder of the
|
|
||||||
economic rights, and the successive licensors have only limited liability.
|
|
||||||
|
|
||||||
In this respect, the user's attention is drawn to the risks associated
|
|
||||||
with loading, using, modifying and/or developing or reproducing the
|
|
||||||
software by the user in light of its specific status of free software,
|
|
||||||
that may mean that it is complicated to manipulate, and that also
|
|
||||||
therefore means that it is reserved for developers and experienced
|
|
||||||
professionals having in-depth computer knowledge. Users are therefore
|
|
||||||
encouraged to load and test the software's suitability as regards their
|
|
||||||
requirements in conditions enabling the security of their systems and/or
|
|
||||||
data to be ensured and, more generally, to use and operate it in the
|
|
||||||
same conditions as regards security.
|
|
||||||
The fact that you are presently reading this means that you have had
|
|
||||||
knowledge of the CeCILL license and that you accept its terms.
|
|
||||||
|
|
||||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
|
||||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iostream>
|
|
||||||
#include <eoInt.h>
|
|
||||||
#include <neighborhood/moGPUXSwapNeighbor.h>
|
|
||||||
#include <eo>
|
|
||||||
|
|
||||||
typedef eoInt<eoMaximizingFitness> Solution;
|
|
||||||
typedef moGPUXSwapNeighbor<Solution> Neighbor;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
|
|
||||||
std::cout << "[t-moGPUXSwapNeighbor] => START" << std::endl;
|
|
||||||
|
|
||||||
Solution sol1(5);
|
|
||||||
for (int i = 4; i >=0; i--)
|
|
||||||
sol1[4-i] = i;
|
|
||||||
|
|
||||||
//test constructor
|
|
||||||
Neighbor neighbor(2);
|
|
||||||
assert(neighbor.index() == 0);
|
|
||||||
assert(neighbor.getXChange() == 2);
|
|
||||||
|
|
||||||
//test setter of one index
|
|
||||||
for (unsigned int i = 0; i < neighbor.getXChange(); i++)
|
|
||||||
neighbor.setIndice(i, i);
|
|
||||||
|
|
||||||
//test getter of one index
|
|
||||||
for (unsigned int i = 0; i < neighbor.getXChange(); i++)
|
|
||||||
assert(neighbor.getIndice(i) == i);
|
|
||||||
|
|
||||||
//test move
|
|
||||||
neighbor.move(sol1);
|
|
||||||
assert(sol1[neighbor.getIndice(0)] == 3);
|
|
||||||
assert(sol1[neighbor.getIndice(1)] == 4);
|
|
||||||
|
|
||||||
//test moveBack
|
|
||||||
neighbor.moveBack(sol1);
|
|
||||||
assert(sol1[neighbor.getIndice(0)] == 4);
|
|
||||||
assert(sol1[neighbor.getIndice(1)] == 3);
|
|
||||||
|
|
||||||
//test set & get indice
|
|
||||||
neighbor.setIndice(0, 1);
|
|
||||||
neighbor.setIndice(1, 2);
|
|
||||||
assert(neighbor.getIndice(0) == 1);
|
|
||||||
assert(neighbor.getIndice(1) == 2);
|
|
||||||
|
|
||||||
//test move
|
|
||||||
neighbor.move(sol1);
|
|
||||||
assert(sol1[neighbor.getIndice(0)] == 2);
|
|
||||||
assert(sol1[neighbor.getIndice(1)] == 3);
|
|
||||||
|
|
||||||
//test move back
|
|
||||||
neighbor.moveBack(sol1);
|
|
||||||
assert(sol1[neighbor.getIndice(0)] == 3);
|
|
||||||
assert(sol1[neighbor.getIndice(1)] == 2);
|
|
||||||
|
|
||||||
Neighbor neighbor2(3);
|
|
||||||
|
|
||||||
//test setter of one index
|
|
||||||
neighbor2.setIndice(0, 0);
|
|
||||||
neighbor2.setIndice(1, 1);
|
|
||||||
neighbor2.setIndice(2, 2);
|
|
||||||
|
|
||||||
//test getter of one index
|
|
||||||
assert(neighbor2.getIndice(0) == 0);
|
|
||||||
assert(neighbor2.getIndice(1) == 1);
|
|
||||||
assert(neighbor2.getIndice(2) == 2);
|
|
||||||
|
|
||||||
//test move
|
|
||||||
neighbor2.move(sol1);
|
|
||||||
assert(sol1[neighbor2.getIndice(0)] == 3);
|
|
||||||
assert(sol1[neighbor2.getIndice(1)] == 2);
|
|
||||||
assert(sol1[neighbor2.getIndice(2)] == 4);
|
|
||||||
|
|
||||||
//test moveBack
|
|
||||||
neighbor2.moveBack(sol1);
|
|
||||||
assert(sol1[neighbor2.getIndice(0)] == 4);
|
|
||||||
assert(sol1[neighbor2.getIndice(1)] == 3);
|
|
||||||
assert(sol1[neighbor2.getIndice(2)] == 2);
|
|
||||||
|
|
||||||
std::cout << "[t-moGPUXSwapNeighbor] => OK" << std::endl;
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue