git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2093 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
66aa25e161
commit
47fac5086e
1 changed files with 87 additions and 98 deletions
|
|
@ -11,6 +11,7 @@ __device__ int * dev_b;
|
||||||
// The general include for eo
|
// The general include for eo
|
||||||
#include <eo>
|
#include <eo>
|
||||||
#include <ga.h>
|
#include <ga.h>
|
||||||
|
#include <eval/moCudakernelEval.h>
|
||||||
// Fitness function
|
// Fitness function
|
||||||
#include <problems/eval/QAPEval.h>
|
#include <problems/eval/QAPEval.h>
|
||||||
// Cuda Fitness function
|
// Cuda Fitness function
|
||||||
|
|
@ -24,27 +25,22 @@ __device__ int * dev_b;
|
||||||
#include <neighborhood/moKswapNeighbor.h>
|
#include <neighborhood/moKswapNeighbor.h>
|
||||||
//To compute execution time
|
//To compute execution time
|
||||||
#include <performance/moCudaTimer.h>
|
#include <performance/moCudaTimer.h>
|
||||||
// QAP ordered neighborhood
|
//Kswap neighborhood
|
||||||
#include <neighborhood/moCudaKswapNeighborhood.h>
|
#include <neighborhood/moCudaKswapNeighborhood.h>
|
||||||
// The Solution and neighbor comparator
|
// The Solution and neighbor comparator
|
||||||
#include <comparator/moNeighborComparator.h>
|
#include <comparator/moNeighborComparator.h>
|
||||||
#include <comparator/moSolNeighborComparator.h>
|
#include <comparator/moSolNeighborComparator.h>
|
||||||
// The Iter continuator
|
// The Iter continuator
|
||||||
#include <continuator/moIterContinuator.h>
|
#include <continuator/moIterContinuator.h>
|
||||||
// Local search algorithm
|
// The Tabou Search algorithm
|
||||||
#include <algo/moLocalSearch.h>
|
|
||||||
// The Tabou Search algorithm explorer
|
|
||||||
#include <explorer/moTSexplorer.h>
|
|
||||||
//Algorithm and its components
|
|
||||||
#include <algo/moTS.h>
|
#include <algo/moTS.h>
|
||||||
//Tabu list
|
//Tabu list
|
||||||
#include <memory/moNeighborVectorTabuList.h>
|
#include <memory/moIndexedVectorTabuList.h>
|
||||||
//Memories
|
//Memories
|
||||||
#include <memory/moDummyIntensification.h>
|
#include <memory/moDummyIntensification.h>
|
||||||
#include <memory/moDummyDiversification.h>
|
#include <memory/moDummyDiversification.h>
|
||||||
#include <memory/moBestImprAspiration.h>
|
#include <memory/moBestImprAspiration.h>
|
||||||
//#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
typedef moCudaIntVector<eoMinimizingFitness> solution;
|
typedef moCudaIntVector<eoMinimizingFitness> solution;
|
||||||
typedef moKswapNeighbor<solution> Neighbor;
|
typedef moKswapNeighbor<solution> Neighbor;
|
||||||
|
|
@ -106,6 +102,7 @@ int main(int argc, char **argv)
|
||||||
ofstream os(statusParam.value().c_str());
|
ofstream os(statusParam.value().c_str());
|
||||||
os << parser;// and you can use that file as parameter file
|
os << parser;// and you can use that file as parameter file
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
* Random seed
|
* Random seed
|
||||||
|
|
@ -114,8 +111,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
//reproducible random seed: if you don't change SEED above,
|
//reproducible random seed: if you don't change SEED above,
|
||||||
// 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(time(NULL));
|
srand(seed);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -125,6 +122,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
QAPData<int> _data(argv[1]);
|
QAPData<int> _data(argv[1]);
|
||||||
unsigned vecSize=_data.sizeData;
|
unsigned vecSize=_data.sizeData;
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
* Initilisation of the solution
|
* 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_a,_data.a_d);
|
||||||
_data.cudaObject.memCopyGlobalVariable(dev_b,_data.b_d);
|
_data.cudaObject.memCopyGlobalVariable(dev_b,_data.b_d);
|
||||||
|
|
||||||
/* =========================================================
|
/*=========================================================
|
||||||
*
|
*
|
||||||
* Evaluation of a solution neighbor's
|
* Evaluation of a solution neighbor's
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
|
|
||||||
QAPEval<solution> eval(_data);
|
QAPEval<solution> eval(_data);
|
||||||
unsigned long int sizeMap=sizeMapping(vecSize,KSwap);
|
unsigned long int sizeMap=sizeMapping(vecSize,1);
|
||||||
// std::cout<<"sizeMap : "<<sizeMap<<std::endl;
|
|
||||||
QAPIncrEval<Neighbor> incr_eval;
|
QAPIncrEval<Neighbor> incr_eval;
|
||||||
moCudaKswapEval<Neighbor,QAPIncrEval<Neighbor> > cueval(sizeMap,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;
|
sizeTabuList=(vecSize*(vecSize-1))/2;
|
||||||
duration=sizeTabuList/8;
|
duration=sizeTabuList/8;
|
||||||
// tabu list
|
// 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);
|
moTS<Neighbor> tabuSearch(neighborhood, eval, cueval, comparator, solComparator, continuator, tl, inten, div, asp);
|
||||||
|
|
||||||
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* the local search algorithm
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
|
|
||||||
moLocalSearch<Neighbor> localSearch1(explorer, continuator, eval);
|
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -221,9 +209,10 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
std::cout << "initial: " << sol<< std::endl;
|
std::cout << "initial: " << sol<< std::endl;
|
||||||
// Create timer for timing CUDA calculation
|
// Create timer for timing CUDA calculation
|
||||||
|
cudaFuncSetCacheConfig(kernelPermutation<solution,eoMinimizingFitness, Neighbor , QAPIncrEval<Neighbor> >, cudaFuncCachePreferL1);
|
||||||
moCudaTimer timer;
|
moCudaTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
localSearch1(sol);
|
tabuSearch(sol);
|
||||||
std::cout << "final: " << sol << std::endl;
|
std::cout << "final: " << sol << std::endl;
|
||||||
timer.stop();
|
timer.stop();
|
||||||
printf("CUDA execution time = %f ms\n",timer.getTime());
|
printf("CUDA execution time = %f ms\n",timer.getTime());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue