git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2093 331e1502-861f-0410-8da2-ba01fb791d7f

This commit is contained in:
boufaras 2011-01-28 16:38:00 +00:00
commit 47fac5086e

View file

@ -11,6 +11,7 @@ __device__ int * dev_b;
// The general include for eo
#include <eo>
#include <ga.h>
#include <eval/moCudakernelEval.h>
// Fitness function
#include <problems/eval/QAPEval.h>
// Cuda Fitness function
@ -24,27 +25,22 @@ __device__ int * dev_b;
#include <neighborhood/moKswapNeighbor.h>
//To compute execution time
#include <performance/moCudaTimer.h>
// QAP ordered neighborhood
//Kswap neighborhood
#include <neighborhood/moCudaKswapNeighborhood.h>
// The Solution and neighbor comparator
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
// The Iter continuator
#include <continuator/moIterContinuator.h>
// Local search algorithm
#include <algo/moLocalSearch.h>
// The Tabou Search algorithm explorer
#include <explorer/moTSexplorer.h>
//Algorithm and its components
// The Tabou Search algorithm
#include <algo/moTS.h>
//Tabu list
#include <memory/moNeighborVectorTabuList.h>
#include <memory/moIndexedVectorTabuList.h>
//Memories
#include <memory/moDummyIntensification.h>
#include <memory/moDummyDiversification.h>
#include <memory/moBestImprAspiration.h>
//#include <time.h>
#include <time.h>
typedef moCudaIntVector<eoMinimizingFitness> solution;
typedef moKswapNeighbor<solution> Neighbor;
@ -106,6 +102,7 @@ int main(int argc, char **argv)
ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file
}
/* =========================================================
*
* Random seed
@ -114,8 +111,8 @@ int main(int argc, char **argv)
//reproducible random seed: if you don't change SEED above,
// you'll aways get the same result, NOT a random run
rng.reseed(seed);
//srand(time(NULL));
// rng.reseed(seed);
srand(seed);
/* =========================================================
*
@ -125,6 +122,7 @@ int main(int argc, char **argv)
QAPData<int> _data(argv[1]);
unsigned vecSize=_data.sizeData;
/* =========================================================
*
* Initilisation of the solution
@ -135,14 +133,14 @@ int main(int argc, char **argv)
_data.cudaObject.memCopyGlobalVariable(dev_a,_data.a_d);
_data.cudaObject.memCopyGlobalVariable(dev_b,_data.b_d);
/* =========================================================
/*=========================================================
*
* Evaluation of a solution neighbor's
*
* ========================================================= */
QAPEval<solution> eval(_data);
unsigned long int sizeMap=sizeMapping(vecSize,KSwap);
// std::cout<<"sizeMap : "<<sizeMap<<std::endl;
unsigned long int sizeMap=sizeMapping(vecSize,1);
QAPIncrEval<Neighbor> incr_eval;
moCudaKswapEval<Neighbor,QAPIncrEval<Neighbor> > cueval(sizeMap,incr_eval);
@ -161,7 +159,7 @@ int main(int argc, char **argv)
*
* ========================================================= */
Neighborhood neighborhood(vecSize,KSwap,cueval);
Neighborhood neighborhood(vecSize,1,cueval);
/* =========================================================
*
@ -177,11 +175,10 @@ int main(int argc, char **argv)
*
* ========================================================= */
//moNeighborVectorTabuList<shiftNeighbor> tl(sizeTabuList,0);
sizeTabuList=(vecSize*(vecSize-1))/2;
duration=sizeTabuList/8;
// tabu list
moNeighborVectorTabuList<Neighbor> tl(sizeTabuList,duration);
moIndexedVectorTabuList<Neighbor> tl(sizeTabuList,duration);
/* =========================================================
*
@ -195,20 +192,11 @@ int main(int argc, char **argv)
/* =========================================================
*
* An explorer of solution neighborhood's
* The Tabu search algorithm
*
* ========================================================= */
moTSexplorer<Neighbor> explorer(neighborhood, cueval, comparator, solComparator, tl, inten, div, asp);
/* =========================================================
*
* the local search algorithm
*
* ========================================================= */
moLocalSearch<Neighbor> localSearch1(explorer, continuator, eval);
moTS<Neighbor> tabuSearch(neighborhood, eval, cueval, comparator, solComparator, continuator, tl, inten, div, asp);
/* =========================================================
*
@ -221,9 +209,10 @@ int main(int argc, char **argv)
std::cout << "initial: " << sol<< std::endl;
// Create timer for timing CUDA calculation
cudaFuncSetCacheConfig(kernelPermutation<solution,eoMinimizingFitness, Neighbor , QAPIncrEval<Neighbor> >, cudaFuncCachePreferL1);
moCudaTimer timer;
timer.start();
localSearch1(sol);
tabuSearch(sol);
std::cout << "final: " << sol << std::endl;
timer.stop();
printf("CUDA execution time = %f ms\n",timer.getTime());