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

This commit is contained in:
boufaras 2011-02-08 17:03:15 +00:00
commit a4bd87b0fd

View file

@ -30,7 +30,7 @@
ParadisEO WebSite : http://paradiseo.gforge.inria.fr ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr Contact: paradiseo-help@lists.gforge.inria.fr
*/ */
#ifndef __QAPIncrEval_H #ifndef __QAPIncrEval_H
#define __QAPIncrEval_H #define __QAPIncrEval_H
@ -44,7 +44,7 @@
template<class Neighbor> template<class Neighbor>
class QAPIncrEval: public moCudaEvalFunc<Neighbor> { class QAPIncrEval: public moCudaEvalFunc<Neighbor> {
public: public:
typedef typename Neighbor::EOT EOT; typedef typename Neighbor::EOT EOT;
typedef typename EOT::Fitness Fitness; typedef typename EOT::Fitness Fitness;
@ -63,17 +63,19 @@ public:
~QAPIncrEval() { ~QAPIncrEval() {
} }
/*functor of incremental evaluation of the solution(function inline can be called from host or device) /**
* functor of incremental evaluation of the solution(function inline can be called from host or device)
* @param _sol the solution to evaluate * @param _sol the solution to evaluate
* @param _fitness the fitness of the current solution * @param _fitness the fitness of the current solution
* @param _index the set of information to compute fitness neighbor * @param _index the set of information to compute fitness neighbor
*/ */
inline __host__ __device__ Fitness operator() (EOT & _sol,Fitness _fitness, unsigned int *_index) { inline __host__ __device__ Fitness operator() (EOT & _sol,Fitness _fitness, unsigned int *_index) {
Fitness tmp; Fitness tmp;
/* dev_a & dev_b are global device variable, data specific to QAP problem (flow & distance matices) /**
* dev_a & dev_b are global device variable, data specific to QAP problem (flow & distance matices)
* _index[0] the first position of swap * _index[0] the first position of swap
* _index[1] the second position of swap * _index[1] the second position of swap
* _index[2] the solution size * _index[2] the solution size
@ -83,9 +85,10 @@ inline __host__ __device__ Fitness operator() (EOT & _sol,Fitness _fitness, unsi
tmp=_fitness+compute_delta(dev_a,dev_b,_sol,_index[0],_index[1],_index[2],_index[3]); tmp=_fitness+compute_delta(dev_a,dev_b,_sol,_index[0],_index[1],_index[2],_index[3]);
return tmp; return tmp;
} }
/* compute the new fitness of the solution after permutation of pair(i,j)(function inline called from host device) /**
* compute the new fitness of the solution after permutation of pair(i,j)(function inline called from host device)
* @param _a the flow matrix of size*size (specific data of QAP problem must be declared as global device variable) * @param _a the flow matrix of size*size (specific data of QAP problem must be declared as global device variable)
* @param _b the distance matrix of size*size (specific data of QAP problem must be declared as global device variable) * @param _b the distance matrix of size*size (specific data of QAP problem must be declared as global device variable)
* @param _sol the solution to evaluate * @param _sol the solution to evaluate
@ -95,7 +98,7 @@ inline __host__ __device__ Fitness operator() (EOT & _sol,Fitness _fitness, unsi
* @param _id the neighbor identifier * @param _id the neighbor identifier
*/ */
inline __host__ __device__ int compute_delta(int * _a,int * _b,EOT & _sol, int _i, int _j,int _size, int _id){ inline __host__ __device__ int compute_delta(int * _a,int * _b,EOT & _sol, int _i, int _j,int _size, int _id){
int d; int d;
int k; int k;
@ -111,7 +114,7 @@ inline __host__ __device__ int compute_delta(int * _a,int * _b,EOT & _sol, int
(_a[_i*_size+k]-_a[_j*_size+k])*(_b[_sol[_j+_id*_size]*_size+_sol[k+_id*_size]]-_b[_sol[_i+_id*_size]*_size+_sol[k+_id*_size]]); (_a[_i*_size+k]-_a[_j*_size+k])*(_b[_sol[_j+_id*_size]*_size+_sol[k+_id*_size]]-_b[_sol[_i+_id*_size]*_size+_sol[k+_id*_size]]);
return(d); return(d);
} }
}; };