review and update the documentation
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2350 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
208f31012d
commit
11f0957f07
1 changed files with 18 additions and 27 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
<testSimpleHC.cu>
|
<testSimpleHCByCpy.cu>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||||
|
|
||||||
Karima Boufaras, Thé Van LUONG
|
Karima Boufaras, Thé Van LUONG
|
||||||
|
|
@ -42,16 +42,17 @@ using namespace std;
|
||||||
// The general include for eo
|
// The general include for eo
|
||||||
#include <eo>
|
#include <eo>
|
||||||
#include <ga.h>
|
#include <ga.h>
|
||||||
// OneMax full eval function
|
// One Max full eval function
|
||||||
#include <problems/eval/EvalOneMax.h>
|
#include <problems/eval/EvalOneMax.h>
|
||||||
// OneMax increment eval function
|
//Parallel evaluation of neighborhood on GPU
|
||||||
#include <eval/moGPUEvalByCpy.h>
|
#include <eval/moGPUEvalByCpy.h>
|
||||||
|
// One Max increment evaluation function
|
||||||
#include <problems/eval/OneMaxIncrEval.h>
|
#include <problems/eval/OneMaxIncrEval.h>
|
||||||
// One Max solution
|
// One Max solution
|
||||||
#include <GPUType/moGPUBitVector.h>
|
#include <GPUType/moGPUBitVector.h>
|
||||||
// One Max neighbor
|
// Bit neighbor
|
||||||
#include <neighborhood/moGPUBitNeighbor.h>
|
#include <neighborhood/moGPUBitNeighbor.h>
|
||||||
// One Max ordered neighborhood
|
// Ordered neighborhood
|
||||||
#include <neighborhood/moGPUOrderNeighborhoodByCpy.h>
|
#include <neighborhood/moGPUOrderNeighborhoodByCpy.h>
|
||||||
// The Solution and neighbor comparator
|
// The Solution and neighbor comparator
|
||||||
#include <comparator/moNeighborComparator.h>
|
#include <comparator/moNeighborComparator.h>
|
||||||
|
|
@ -70,7 +71,7 @@ using namespace std;
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Define types of the representation solution, different neighbors and neighborhoods
|
// Define types of the representation solution, different neighbors and neighborhoods
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// REPRESENTATION
|
|
||||||
typedef moGPUBitVector<eoMaximizingFitness> solution;
|
typedef moGPUBitVector<eoMaximizingFitness> solution;
|
||||||
typedef moGPUBitNeighbor<eoMaximizingFitness> Neighbor;
|
typedef moGPUBitNeighbor<eoMaximizingFitness> Neighbor;
|
||||||
typedef moGPUOrderNeighborhoodByCpy<Neighbor> Neighborhood;
|
typedef moGPUOrderNeighborhoodByCpy<Neighbor> Neighborhood;
|
||||||
|
|
@ -95,16 +96,6 @@ void main_function(int argc, char **argv)
|
||||||
parser.processParam( seedParam );
|
parser.processParam( seedParam );
|
||||||
unsigned seed = seedParam.value();
|
unsigned seed = seedParam.value();
|
||||||
|
|
||||||
// description of genotype
|
|
||||||
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
|
// the name of the "status" file where all actual parameter values will be saved
|
||||||
string str_status = parser.ProgramName() + ".status"; // default value
|
string str_status = parser.ProgramName() + ".status"; // default value
|
||||||
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
|
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
|
||||||
|
|
@ -131,7 +122,6 @@ void main_function(int argc, char **argv)
|
||||||
// you'll aways get the same result, NOT a random run
|
// you'll aways get the same result, NOT a random run
|
||||||
rng.reseed(seed);
|
rng.reseed(seed);
|
||||||
srand(seed);
|
srand(seed);
|
||||||
|
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -139,7 +129,7 @@ void main_function(int argc, char **argv)
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
|
|
||||||
solution sol(vecSize);
|
solution sol(SIZE);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -156,7 +146,7 @@ void main_function(int argc, char **argv)
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
|
|
||||||
OneMaxIncrEval<Neighbor> incr_eval;
|
OneMaxIncrEval<Neighbor> incr_eval;
|
||||||
moGPUEvalByCpy<Neighbor,OneMaxIncrEval<Neighbor> > cueval(vecSize,incr_eval);
|
moGPUEvalByCpy<Neighbor,OneMaxIncrEval<Neighbor> > gpuEval(SIZE,incr_eval);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -173,7 +163,7 @@ void main_function(int argc, char **argv)
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
|
|
||||||
Neighborhood neighborhood(vecSize,cueval);
|
Neighborhood neighborhood(SIZE,gpuEval);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -181,7 +171,7 @@ void main_function(int argc, char **argv)
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
|
|
||||||
moSimpleHCexplorer<Neighbor> explorer(neighborhood, cueval,
|
moSimpleHCexplorer<Neighbor> explorer(neighborhood, gpuEval,
|
||||||
comparator, solComparator);
|
comparator, solComparator);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
|
|
@ -201,7 +191,7 @@ void main_function(int argc, char **argv)
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
|
|
||||||
moSimpleHC<Neighbor> simpleHC(neighborhood,eval,cueval);
|
moSimpleHC<Neighbor> simpleHC(neighborhood,eval,gpuEval);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -213,12 +203,13 @@ void main_function(int argc, char **argv)
|
||||||
eval(sol);
|
eval(sol);
|
||||||
|
|
||||||
std::cout << "initial: " << sol<< std::endl;
|
std::cout << "initial: " << sol<< std::endl;
|
||||||
// Create timer for timing CUDA calculation
|
// Create timer for timing GPU calculation
|
||||||
moGPUTimer timer;
|
moGPUTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
//Run the local search with Simple Hill climbing explorer
|
||||||
localSearch(sol);
|
localSearch(sol);
|
||||||
timer.stop();
|
timer.stop();
|
||||||
printf("CUDA execution time = %f ms\n",timer.getTime());
|
printf("GPU execution time = %f ms\n",timer.getTime());
|
||||||
timer.deleteTimer();
|
timer.deleteTimer();
|
||||||
std::cout << "final: " << sol << std::endl;
|
std::cout << "final: " << sol << std::endl;
|
||||||
|
|
||||||
|
|
@ -228,16 +219,16 @@ void main_function(int argc, char **argv)
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
cout<<endl;
|
cout<<endl;
|
||||||
solution sol1(vecSize);
|
solution sol1(SIZE);
|
||||||
eval(sol1);
|
eval(sol1);
|
||||||
std::cout << "initial: " << sol1<< std::endl;
|
std::cout << "initial: " << sol1<< std::endl;
|
||||||
// Create timer for timing CUDA calculation
|
|
||||||
moGPUTimer timer1;
|
moGPUTimer timer1;
|
||||||
timer1.start();
|
timer1.start();
|
||||||
|
// Run Simple Hill Climbing
|
||||||
simpleHC(sol1);
|
simpleHC(sol1);
|
||||||
timer1.stop();
|
timer1.stop();
|
||||||
std::cout << "final: " << sol1 << std::endl;
|
std::cout << "final: " << sol1 << std::endl;
|
||||||
printf("Execution time = %f ms\n",timer1.getTime());
|
printf("GPU execution time = %f ms\n",timer1.getTime());
|
||||||
timer1.deleteTimer();
|
timer1.deleteTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue