git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2003 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
2b17f36c9e
commit
aca68a1559
1 changed files with 31 additions and 28 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
//Init the number of threads per block
|
//Init the number of threads per block
|
||||||
#define BLOCK_SIZE 128
|
#define BLOCK_SIZE 512
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
@ -32,6 +32,34 @@ using namespace std;
|
||||||
// The simple HC algorithm explorer
|
// The simple HC algorithm explorer
|
||||||
#include <explorer/moSimpleHCexplorer.h>
|
#include <explorer/moSimpleHCexplorer.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the factorial of an unsigned integer
|
||||||
|
* @param i an integer
|
||||||
|
*/
|
||||||
|
|
||||||
|
unsigned long int factorial1(unsigned int i) {
|
||||||
|
if (i == 0)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return i * factorial1(i - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the neighborhood Size from the solution size and number of swap
|
||||||
|
* @param _size the solution size
|
||||||
|
* @param _Kswap the number of swap
|
||||||
|
*/
|
||||||
|
|
||||||
|
unsigned long int sizeMapping1( unsigned int _size, unsigned int _Kswap) {
|
||||||
|
|
||||||
|
unsigned long int _sizeMapping = _size;
|
||||||
|
for (unsigned int i = _Kswap; i > 0; i--) {
|
||||||
|
_sizeMapping *= (_size - i);
|
||||||
|
}
|
||||||
|
_sizeMapping /= factorial1(_Kswap + 1);
|
||||||
|
return _sizeMapping;
|
||||||
|
}
|
||||||
|
|
||||||
// REPRESENTATION
|
// REPRESENTATION
|
||||||
typedef moCudaBitVector<eoMaximizingFitness> solution;
|
typedef moCudaBitVector<eoMaximizingFitness> solution;
|
||||||
typedef moBitFlippingNeighbor<solution> Neighbor;
|
typedef moBitFlippingNeighbor<solution> Neighbor;
|
||||||
|
|
@ -117,7 +145,7 @@ void main_function(int argc, char **argv)
|
||||||
* Evaluation of a solution neighbor's
|
* Evaluation of a solution neighbor's
|
||||||
*
|
*
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
unsigned int sizeMap=sizeMapping(vecSize,KSwap);
|
unsigned long int sizeMap=sizeMapping1(vecSize,KSwap);
|
||||||
std::cout<<"sizeMap : "<<sizeMap<<std::endl;
|
std::cout<<"sizeMap : "<<sizeMap<<std::endl;
|
||||||
OneMaxIncrEval<Neighbor> incr_eval;
|
OneMaxIncrEval<Neighbor> incr_eval;
|
||||||
moCudaKswapEval<Neighbor,OneMaxIncrEval<Neighbor> > cueval(sizeMap,incr_eval);
|
moCudaKswapEval<Neighbor,OneMaxIncrEval<Neighbor> > cueval(sizeMap,incr_eval);
|
||||||
|
|
@ -186,31 +214,6 @@ void main_function(int argc, char **argv)
|
||||||
timer.deleteTimer();
|
timer.deleteTimer();
|
||||||
std::cout << "final: " << sol.fitness() << std::endl;
|
std::cout << "final: " << sol.fitness() << std::endl;
|
||||||
|
|
||||||
/* =========================================================
|
|
||||||
*
|
|
||||||
* Execute the Simple Hill climbing from random sollution
|
|
||||||
*
|
|
||||||
* ========================================================= */
|
|
||||||
/*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;
|
|
||||||
// Create timer for timing CUDA calculation
|
|
||||||
moCudaTimer timer1;
|
|
||||||
timer1.start();
|
|
||||||
simpleHC(sol1);
|
|
||||||
timer1.stop();
|
|
||||||
printf("CUDA execution time = %f ms\n",timer1.getTime());
|
|
||||||
timer1.deleteTimer();
|
|
||||||
std::cout << "final: " << sol1.fitness() << std::endl;*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue