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:
parent
0a8ddd65d0
commit
2b96354018
8 changed files with 435 additions and 103 deletions
|
|
@ -32,27 +32,26 @@
|
|||
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>
|
||||
|
|
@ -61,15 +60,15 @@ using namespace std;
|
|||
// Simple HC algorithm
|
||||
#include <algo/moNeutralHC.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,eoMaximizingFitness> Neighbor;
|
||||
typedef moCudaOrderNeighborhood<Neighbor> Neighborhood;
|
||||
typedef moGPUBitVector<eoMaximizingFitness> solution;
|
||||
typedef moGPUBitNeighbor <eoMaximizingFitness> Neighbor;
|
||||
typedef moGPUOrderNeighborhoodByModif<Neighbor> Neighborhood;
|
||||
|
||||
void main_function(int argc, char **argv)
|
||||
{
|
||||
|
|
@ -92,16 +91,20 @@ 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();
|
||||
|
||||
//nbStep maximum step to do
|
||||
eoValueParam<unsigned int> nbStepParam(10, "nbStep", "maximum number of step", 'N');
|
||||
//Number of position to change
|
||||
eoValueParam<unsigned int> nbPosParam(1, "nbPos", "X Change", 'N');
|
||||
parser.processParam( nbPosParam, "Exchange" );
|
||||
unsigned nbPos = nbPosParam.value();
|
||||
|
||||
//nbStep maximum step to do
|
||||
eoValueParam<unsigned int> nbStepParam(10, "nbStep", "maximum number of step", 'n');
|
||||
parser.processParam( nbStepParam, "numberStep" );
|
||||
unsigned nbStep = nbStepParam.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");
|
||||
|
|
@ -117,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
|
||||
|
|
@ -151,7 +155,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);
|
||||
|
||||
/* =========================================================
|
||||
*
|
||||
|
|
@ -190,12 +194,12 @@ void main_function(int argc, char **argv)
|
|||
eval(sol);
|
||||
|
||||
std::cout << "initial: " << sol<< std::endl;
|
||||
moCudaTimer timer;
|
||||
moGPUTimer timer;
|
||||
timer.start();
|
||||
neutralHC(sol);
|
||||
timer.stop();
|
||||
std::cout << "final: " << sol << std::endl;
|
||||
printf("CUDA execution time = %f ms\n",timer.getTime());
|
||||
printf("Execution time = %f ms\n",timer.getTime());
|
||||
timer.deleteTimer();
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue