Test peo modified
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@911 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
b87149ea75
commit
743d94aea0
17 changed files with 559 additions and 140 deletions
|
|
@ -1,55 +1,8 @@
|
|||
// Test : parallel transform
|
||||
#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( eoEvalFunc < Indi > & _eval, eoSelect < Indi > & _select, peoTransform < Indi > & _transform):
|
||||
loopEval(_eval),
|
||||
eval(loopEval),
|
||||
selectTransform( _select, _transform),
|
||||
breed(selectTransform) {}
|
||||
|
||||
void operator()(eoPop < Indi > & _pop)
|
||||
{
|
||||
eoPop < Indi > offspring, empty_pop;
|
||||
eval(empty_pop, _pop);
|
||||
eval(empty_pop, offspring);
|
||||
std::cout<<"\n\nBefore :\n"<<offspring;
|
||||
breed(_pop, offspring);
|
||||
eval(empty_pop, offspring);
|
||||
std::cout<<"\n\nAfter :\n"<<offspring;
|
||||
}
|
||||
eoPopLoopEval < Indi > loopEval;
|
||||
eoPopEvalFunc < Indi > & eval;
|
||||
eoSelectTransform < Indi > selectTransform;
|
||||
eoBreed < Indi > & breed;
|
||||
};
|
||||
#include <peo.h>
|
||||
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : parallel transform\n\n";
|
||||
rng.reseed (10);
|
||||
eoEvalFuncPtr < Indi > plainEval(f);
|
||||
eoEvalFuncCounter < Indi > eval(plainEval);
|
||||
eoUniformGenerator < double >uGen (0, 1);
|
||||
eoInitFixedLength < Indi > random (2, uGen);
|
||||
eoPop < Indi > empty_pop,pop(6, random);
|
||||
eoRankingSelect < Indi > selectionStrategy;
|
||||
eoSelectNumber < Indi > select(selectionStrategy,6);
|
||||
eoSegmentCrossover < Indi > crossover;
|
||||
eoUniformMutation < Indi > mutation(0.01);
|
||||
peoTransform<Indi> transform(crossover,0.8,mutation,0.3);
|
||||
Algorithm algo ( eval, select, transform );
|
||||
peoWrapper parallelAlgo( algo, pop);
|
||||
transform.setOwner(parallelAlgo);
|
||||
peo :: run();
|
||||
peo :: finalize();
|
||||
system("mpdboot");
|
||||
system("mpiexec -n 4 ./t-ParallelTransformLib @param ");
|
||||
system("mpdallexit");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue