git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2116 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
54920bd078
commit
48c715572c
1 changed files with 57 additions and 0 deletions
|
|
@ -31,3 +31,60 @@
|
||||||
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 __OneMaxIncrEval_H
|
||||||
|
#define __OneMaxIncrEval_H
|
||||||
|
|
||||||
|
#include <eval/moCudaEvalFunc.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Incremental Evaluation of OneMax
|
||||||
|
*/
|
||||||
|
|
||||||
|
template<class Neighbor>
|
||||||
|
class OneMaxIncrEval: public moCudaEvalFunc<Neighbor> {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
typedef typename EOT::Fitness Fitness;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
|
||||||
|
OneMaxIncrEval() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
|
|
||||||
|
~OneMaxIncrEval() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Incremental evaluation of the solution(function inline can be called from host or device)
|
||||||
|
* @param _bitVector the solution to evaluate
|
||||||
|
* @param _fitness the fitness of the current solution
|
||||||
|
* @param _index the index of solution neighbor
|
||||||
|
*/
|
||||||
|
|
||||||
|
inline __host__ __device__ Fitness operator() (EOT & _bitVector,Fitness _fitness, unsigned int * _index) {
|
||||||
|
|
||||||
|
Fitness tmp;
|
||||||
|
|
||||||
|
if (_bitVector[_index[0]] == 0)
|
||||||
|
|
||||||
|
tmp= _fitness+1;
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
tmp= _fitness-1;
|
||||||
|
|
||||||
|
return tmp;
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue