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

@ -33,38 +33,36 @@
*/
//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/moGPUEvalByModif.h>
#include <problems/eval/OneMaxIncrEval.h>
// One Max solution
#include <eval/moCudaVectorEval.h>
#include <cudaType/moCudaBitVector.h>
//To compute execution time
#include <performance/moCudaTimer.h>
#include <GPUType/moGPUBitVector.h>
// One Max neighbor
#include <neighborhood/moCudaBitNeighbor.h>
#include <neighborhood/moGPUBitNeighbor.h>
// One Max ordered neighborhood
#include <neighborhood/moCudaRndWithReplNeighborhood.h>
#include <neighborhood/moGPURndWithReplNeighborhoodByModif.h>
// The Solution and neighbor comparator
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
//To compute execution time
#include <performance/moGPUTimer.h>
//Algorithm and its components
#include <coolingSchedule/moCoolingSchedule.h>
#include <algo/moSA.h>
// The simulated annealing algorithm explorer
#include <explorer/moSAexplorer.h>
//comparator
#include <comparator/moSolNeighborComparator.h>
//continuators
#include <continuator/moTrueContinuator.h>
#include <continuator/moCheckpoint.h>
@ -76,10 +74,9 @@ using namespace std;
// Define types of the representation solution, different neighbors and neighborhoods
//------------------------------------------------------------------------------------
// REPRESENTATION
typedef moCudaBitVector<eoMaximizingFitness> solution;
typedef moCudaBitNeighbor <solution,eoMaximizingFitness> Neighbor;
typedef moCudaRndWithReplNeighborhood<Neighbor> Neighborhood;
typedef moGPUBitVector<eoMaximizingFitness> solution;
typedef moGPUBitNeighbor <eoMaximizingFitness> Neighbor;
typedef moGPURndWithReplNeighborhoodByModif<Neighbor> Neighborhood;
void main_function(int argc, char **argv)
{
@ -104,6 +101,11 @@ void main_function(int argc, char **argv)
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");
@ -153,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);
/* =========================================================
*
@ -192,9 +194,15 @@ void main_function(int argc, char **argv)
std::cout << "#########################################" << std::endl;
std::cout << "initial : " << sol << std::endl;
moGPUTimer timer1;
timer1.start();
SA(sol);
timer1.stop();
std::cout << "final : " << sol << std::endl;
std::cout << "#########################################" << std::endl;
printf("Execution time = %f ms\n",timer1.getTime());
timer1.deleteTimer();
}