test for different algorithm using oneMax problem

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2273 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
boufaras 2011-05-25 21:55:00 +00:00
commit 2b96354018
8 changed files with 435 additions and 103 deletions

View file

@ -32,27 +32,27 @@
Contact: paradiseo-help@lists.gforge.inria.fr
*/
//Init the number of threads per block
#define BLOCK_SIZE 256
#include <iostream>
#include <stdlib.h>
using namespace std;
//Include GPU Config File
#include "moGPUConfig.h"
// The general include for eo
#include <eo>
#include <ga.h>
// OneMax full eval function
#include <problems/eval/EvalOneMax.h>
// OneMax increment eval function
#include <eval/moCudaVectorEval.h>
#include <eval/moGPUEvalByModif.h>
#include <problems/eval/OneMaxIncrEval.h>
// One Max solution
#include <cudaType/moCudaBitVector.h>
#include <GPUType/moGPUBitVector.h>
// One Max neighbor
#include <neighborhood/moCudaBitNeighbor.h>
#include <neighborhood/moGPUBitNeighbor.h>
// One Max ordered neighborhood
#include <neighborhood/moCudaOrderNeighborhood.h>
#include <neighborhood/moGPUOrderNeighborhoodByModif.h>
// The Solution and neighbor comparator
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
@ -65,15 +65,15 @@ using namespace std;
// The simple HC algorithm explorer
#include <explorer/moSimpleHCexplorer.h>
//To compute execution time
#include <performance/moCudaTimer.h>
#include <performance/moGPUTimer.h>
//------------------------------------------------------------------------------------
// Define types of the representation solution, different neighbors and neighborhoods
//------------------------------------------------------------------------------------
// REPRESENTATION
typedef moCudaBitVector<eoMaximizingFitness> solution;
typedef moCudaBitNeighbor <solution> Neighbor;
typedef moCudaOrderNeighborhood<Neighbor> Neighborhood;
typedef moGPUBitVector<eoMaximizingFitness> solution;
typedef moGPUBitNeighbor <eoMaximizingFitness> Neighbor;
typedef moGPUOrderNeighborhoodByModif<Neighbor> Neighborhood;
void main_function(int argc, char **argv)
{
@ -96,10 +96,15 @@ void main_function(int argc, char **argv)
unsigned seed = seedParam.value();
// description of genotype
eoValueParam<unsigned int> vecSizeParam(8, "vecSize", "Genotype size", 'V');
eoValueParam<unsigned int> vecSizeParam(1, "vecSize", "Genotype size", 'V');
parser.processParam( vecSizeParam, "Representation" );
unsigned vecSize = vecSizeParam.value();
//Number of position to change
eoValueParam<unsigned int> nbPosParam(1, "nbPos", "X Change", 'N');
parser.processParam( nbPosParam, "Exchange" );
unsigned nbPos = nbPosParam.value();
// the name of the "status" file where all actual parameter values will be saved
string str_status = parser.ProgramName() + ".status"; // default value
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
@ -115,6 +120,7 @@ void main_function(int argc, char **argv)
ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file
}
/* =========================================================
*
* Random seed
@ -150,7 +156,7 @@ void main_function(int argc, char **argv)
* ========================================================= */
OneMaxIncrEval<Neighbor> incr_eval;
moCudaVectorEval<Neighbor,OneMaxIncrEval<Neighbor> > cueval(vecSize,incr_eval);
moGPUEvalByModif<Neighbor,OneMaxIncrEval<Neighbor> > cueval(vecSize,incr_eval);
/* =========================================================
*
@ -208,7 +214,7 @@ void main_function(int argc, char **argv)
std::cout << "initial: " << sol<< std::endl;
// Create timer for timing CUDA calculation
moCudaTimer timer;
moGPUTimer timer;
timer.start();
localSearch(sol);
timer.stop();
@ -226,12 +232,12 @@ void main_function(int argc, char **argv)
eval(sol1);
std::cout << "initial: " << sol1<< std::endl;
// Create timer for timing CUDA calculation
moCudaTimer timer1;
moGPUTimer timer1;
timer1.start();
simpleHC(sol1);
timer1.stop();
std::cout << "final: " << sol1 << std::endl;
printf("CUDA execution time = %f ms\n",timer1.getTime());
printf("Execution time = %f ms\n",timer1.getTime());
timer1.deleteTimer();
}