Ajout de la marche aléatoire neutre avec le prg de test.
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1689 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
db2846ef23
commit
d6146b471d
6 changed files with 501 additions and 41 deletions
40
branches/newMo/tutorial/oneMax/src/funcRoyalRoad.h
Normal file
40
branches/newMo/tutorial/oneMax/src/funcRoyalRoad.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
#ifndef __funcRoyalRoad
|
||||
#define __funcRoyalRoad
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
template< class EOT >
|
||||
class FuncRoyalRoad : public eoEvalFunc<EOT>
|
||||
{
|
||||
// number of blocks
|
||||
unsigned n;
|
||||
|
||||
// size of a block
|
||||
unsigned k;
|
||||
|
||||
public:
|
||||
FuncRoyalRoad(unsigned _n, unsigned _k) : n(_n), k(_k) {};
|
||||
|
||||
~FuncRoyalRoad(void) {} ;
|
||||
|
||||
virtual void operator() (EOT & _solution)
|
||||
{
|
||||
unsigned sum = 0;
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
j = 0;
|
||||
while (_solution[i * n + j] && j < k) j++;
|
||||
|
||||
if (j == k)
|
||||
sum++;
|
||||
}
|
||||
|
||||
_solution.fitness(sum);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue