Test peo modified
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@910 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
d3b84924bb
commit
b87149ea75
11 changed files with 217 additions and 215 deletions
42
trunk/paradiseo-peo/test/t-ParallelEval.cpp
Normal file
42
trunk/paradiseo-peo/test/t-ParallelEval.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// Test : parallel evaluation
|
||||
#include <peo>
|
||||
#include <es.h>
|
||||
typedef eoReal<double> Indi;
|
||||
double f (const Indi & _indi)
|
||||
{
|
||||
double sum=_indi[0]+_indi[1];
|
||||
return (-sum);
|
||||
}
|
||||
struct Algorithm
|
||||
{
|
||||
Algorithm( peoPopEval < Indi > & _eval): eval( _eval ){}
|
||||
void operator()(eoPop < Indi > & _pop)
|
||||
{
|
||||
eoPop < Indi > empty_pop;
|
||||
eval(empty_pop, _pop);
|
||||
}
|
||||
peoPopEval < Indi > & eval;
|
||||
};
|
||||
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : parallel evaluation\n\n";
|
||||
rng.reseed (10);
|
||||
peoEvalFunc<Indi, double, const Indi& > plainEval(f);
|
||||
peoPopEval< Indi > eval(plainEval);
|
||||
eoUniformGenerator < double >uGen (0, 1);
|
||||
eoInitFixedLength < Indi > random (2, uGen);
|
||||
eoPop < Indi > pop(20, random);
|
||||
Algorithm algo ( eval );
|
||||
peoWrapper parallelAlgo( algo, pop);
|
||||
eval.setOwner(parallelAlgo);
|
||||
peo :: run();
|
||||
peo :: finalize();
|
||||
if (getNodeRank()==1)
|
||||
{
|
||||
pop.sort();
|
||||
std::cout<<pop;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue