git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2117 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
48c715572c
commit
1343b27d98
6 changed files with 183 additions and 246 deletions
|
|
@ -1,5 +1,6 @@
|
|||
//Init the number of threads per block
|
||||
#define BLOCK_SIZE 128
|
||||
#define BLOCK_SIZE 256
|
||||
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
using namespace std;
|
||||
|
|
@ -7,17 +8,15 @@ using namespace std;
|
|||
// The general include for eo
|
||||
#include <eo>
|
||||
#include <ga.h>
|
||||
// Fitness function
|
||||
// OneMax full eval function
|
||||
#include <problems/eval/EvalOneMax.h>
|
||||
// Cuda Fitness function
|
||||
// OneMax increment eval function
|
||||
#include <eval/moCudaVectorEval.h>
|
||||
#include <problems/eval/OneMaxIncrEval.h>
|
||||
// One Max solution
|
||||
#include <cudaType/moCudaBitVector.h>
|
||||
// One Max neighbor
|
||||
#include <neighborhood/moCudaBitNeighbor.h>
|
||||
//To compute execution time
|
||||
#include <performance/moCudaTimer.h>
|
||||
// One Max ordered neighborhood
|
||||
#include <neighborhood/moCudaOrderNeighborhood.h>
|
||||
// The Solution and neighbor comparator
|
||||
|
|
@ -31,7 +30,12 @@ using namespace std;
|
|||
#include <algo/moSimpleHC.h>
|
||||
// The simple HC algorithm explorer
|
||||
#include <explorer/moSimpleHCexplorer.h>
|
||||
//To compute execution time
|
||||
#include <performance/moCudaTimer.h>
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Define types of the representation solution, different neighbors and neighborhoods
|
||||
//------------------------------------------------------------------------------------
|
||||
// REPRESENTATION
|
||||
typedef moCudaBitVector<eoMaximizingFitness> solution;
|
||||
typedef moCudaBitNeighbor <solution> Neighbor;
|
||||
|
|
@ -96,9 +100,6 @@ void main_function(int argc, char **argv)
|
|||
* ========================================================= */
|
||||
|
||||
solution sol(vecSize);
|
||||
if(vecSize<64)
|
||||
for(unsigned i=0;i<vecSize;i++) cout<<sol[i]<<" ";
|
||||
cout<<endl;
|
||||
|
||||
/* =========================================================
|
||||
*
|
||||
|
|
@ -171,7 +172,7 @@ void main_function(int argc, char **argv)
|
|||
//Can be eval here, else it will be done at the beginning of the localSearch
|
||||
eval(sol);
|
||||
|
||||
std::cout << "initial: " << sol.fitness()<< std::endl;
|
||||
std::cout << "initial: " << sol<< std::endl;
|
||||
// Create timer for timing CUDA calculation
|
||||
moCudaTimer timer;
|
||||
timer.start();
|
||||
|
|
@ -179,34 +180,25 @@ void main_function(int argc, char **argv)
|
|||
timer.stop();
|
||||
printf("CUDA execution time = %f ms\n",timer.getTime());
|
||||
timer.deleteTimer();
|
||||
std::cout << "final: " << sol.fitness() << std::endl;
|
||||
std::cout << "final: " << sol << std::endl;
|
||||
|
||||
/* =========================================================
|
||||
*
|
||||
* Execute the Simple Hill climbing from random sollution
|
||||
*
|
||||
* ========================================================= */
|
||||
cout<<endl;
|
||||
solution sol1(vecSize);
|
||||
if(vecSize<64)
|
||||
for(unsigned i=0;i<vecSize;i++) cout<<sol1[i]<<" ";
|
||||
cout<<endl;
|
||||
cout<<endl;
|
||||
|
||||
|
||||
eval(sol1);
|
||||
|
||||
std::cout << "initial: " << sol1.fitness()<< std::endl;
|
||||
std::cout << "initial: " << sol1<< std::endl;
|
||||
// Create timer for timing CUDA calculation
|
||||
moCudaTimer timer1;
|
||||
timer1.start();
|
||||
simpleHC(sol1);
|
||||
timer1.stop();
|
||||
std::cout << "final: " << sol1 << std::endl;
|
||||
printf("CUDA execution time = %f ms\n",timer1.getTime());
|
||||
timer1.deleteTimer();
|
||||
std::cout << "final: " << sol1.fitness() << std::endl;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// A main that catches the exceptions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue