new style peo

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1021 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
canape 2008-02-29 14:08:59 +00:00
commit edb6d65a7b
34 changed files with 407 additions and 386 deletions

View file

@ -48,7 +48,7 @@ int main (int __argc, char *__argv[])
{
peo :: init( __argc, __argv );
if (getNodeRank()==1)
std::cout<<"\n\nTest : Asynchronous island with EA\n\n";
std::cout<<"\n\nTest : Asynchronous island with EA\n\n";
rng.reseed (10);
RingTopology topology;
eoGenContinue < Indi > genContPara (10);
@ -63,7 +63,8 @@ int main (int __argc, char *__argv[])
eoSegmentCrossover<Indi> crossover;
eoUniformMutation<Indi> mutation(0.01);
peoTransform<Indi> transform(crossover,0.8,mutation,0.3);
/*p*/eoPop < Indi > pop;
/*p*/
eoPop < Indi > pop;
pop.append (10, random);
eoPlusReplacement<Indi> replace;
eoRandomSelect<Indi> mig_select_one;
@ -90,7 +91,8 @@ int main (int __argc, char *__argv[])
eoSegmentCrossover<Indi> crossover2;
eoUniformMutation<Indi> mutation2(0.01);
peoTransform<Indi> transform2(crossover2,0.8,mutation2,0.3);
/*p*/eoPop < Indi > pop2;
/*p*/
eoPop < Indi > pop2;
pop2.append (10, random2);
eoPlusReplacement<Indi> replace2;
eoRandomSelect<Indi> mig_select_one2;

View file

@ -49,7 +49,7 @@ int main (int __argc, char *__argv[])
{
peo :: init( __argc, __argv );
if (getNodeRank()==1)
std::cout<<"\n\nTest : Synchronous island with EA\n\n";
std::cout<<"\n\nTest : Synchronous island with EA\n\n";
rng.reseed (10);
RingTopology topology;
eoGenContinue < Indi > genContPara (10);

View file

@ -39,5 +39,5 @@
int main (int __argc, char *__argv[])
{
system("mpdallexit");
system("mpdallexit");
}

View file

@ -39,5 +39,5 @@
int main (int __argc, char *__argv[])
{
system("mpdboot");
system("mpdboot");
}

View file

@ -39,29 +39,29 @@
#include <peo>
struct Algorithm
{
void operator()(double & _d)
{
_d = _d * _d;
}
};
struct Algorithm
{
void operator()(double & _d)
{
_d = _d * _d;
}
};
int main (int __argc, char * * __argv)
{
peo :: init (__argc, __argv);
if (getNodeRank()==1)
std::cout<<"\n\nTest : multistart\n\n";
std::cout<<"\n\nTest : multistart\n\n";
std::vector < double > v;
if (getNodeRank()==1)
std::cout<<"\n\nBefore :";
for(unsigned i = 0; i< 10; i++)
{
v.push_back(i);
if (getNodeRank()==1)
std::cout<<"\n"<<v[i];
}
std::cout<<"\n\nBefore :";
for (unsigned i = 0; i< 10; i++)
{
v.push_back(i);
if (getNodeRank()==1)
std::cout<<"\n"<<v[i];
}
Algorithm algo;
peoMultiStart < double > initParallel (algo);
peoWrapper parallelAlgo (initParallel, v);
@ -69,9 +69,9 @@ int main (int __argc, char * * __argv)
peo :: run( );
peo :: finalize( );
if (getNodeRank()==1)
{
std::cout<<"\n\nAfter :\n";
for(unsigned i = 0; i< 10; i++)
std::cout<<v[i]<<"\n";
}
{
std::cout<<"\n\nAfter :\n";
for (unsigned i = 0; i< 10; i++)
std::cout<<v[i]<<"\n";
}
}

View file

@ -47,7 +47,7 @@ int main (int __argc, char *__argv[])
{
peo :: init( __argc, __argv );
if (getNodeRank()==1)
std::cout<<"\n\nTest : PSO Global Best\n\n";
std::cout<<"\n\nTest : PSO Global Best\n\n";
rng.reseed (10);
RingTopology topologyMig;
eoGenContinue < Indi > genContPara (10);

View file

@ -47,7 +47,7 @@ int main (int __argc, char *__argv[])
{
peo :: init( __argc, __argv );
if (getNodeRank()==1)
std::cout<<"\n\nTest : PSO Worst Position\n\n";
std::cout<<"\n\nTest : PSO Worst Position\n\n";
rng.reseed (10);
RingTopology topologyMig;
eoGenContinue < Indi > genContPara (10);

View file

@ -44,22 +44,22 @@ 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;
};
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";
std::cout<<"\n\nTest : parallel evaluation\n\n";
rng.reseed (10);
peoEvalFunc<Indi, double, const Indi& > plainEval(f);
peoPopEval< Indi > eval(plainEval);
@ -72,8 +72,8 @@ int main (int __argc, char *__argv[])
peo :: run();
peo :: finalize();
if (getNodeRank()==1)
{
{
pop.sort();
std::cout<<pop;
}
}
}

View file

@ -44,35 +44,35 @@ 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),
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;
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;
eoSelectTransform < Indi > selectTransform;
eoBreed < Indi > & breed;
};
};
int main (int __argc, char *__argv[])
{
peo :: init( __argc, __argv );
if (getNodeRank()==1)
std::cout<<"\n\nTest : parallel transform\n\n";
std::cout<<"\n\nTest : parallel transform\n\n";
rng.reseed (10);
eoEvalFuncPtr < Indi > plainEval(f);
eoEvalFuncCounter < Indi > eval(plainEval);