Add the SMP module
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2714 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
409a1b21b8
commit
0890c67d31
43 changed files with 4030 additions and 41 deletions
43
trunk/smp/src/MWAlgo/eoEasyEA.cpp
Normal file
43
trunk/smp/src/MWAlgo/eoEasyEA.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
template<template <class> class EOAlgo, class EOT>
|
||||
void paradiseo::smp::MWModel<EOAlgo,EOT>::operator()(eoPop<EOT>& _pop, const eoEasyEA_tag&)
|
||||
{
|
||||
|
||||
if (this->isFirstCall)
|
||||
{
|
||||
size_t total_capacity = _pop.capacity() + this->offspring.capacity();
|
||||
_pop.reserve(total_capacity);
|
||||
this->offspring.reserve(total_capacity);
|
||||
this->isFirstCall = false;
|
||||
}
|
||||
|
||||
eoPop<EOT> empty_pop;
|
||||
|
||||
this->popEval(empty_pop, _pop); // A first eval of pop.
|
||||
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
unsigned pSize = _pop.size();
|
||||
this->offspring.clear(); // new offspring
|
||||
this->breed(_pop, this->offspring);
|
||||
|
||||
scheduler(EOAlgo<EOT>::eval, this->offspring); // eval of parents + offspring if necessary
|
||||
|
||||
this->replace(_pop, this->offspring); // after replace, the new pop. is in _pop
|
||||
|
||||
if (pSize > _pop.size())
|
||||
throw std::runtime_error("Population shrinking!");
|
||||
else if (pSize < _pop.size())
|
||||
throw std::runtime_error("Population growing!");
|
||||
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::string s = e.what();
|
||||
s.append( " in eoEasyEA");
|
||||
throw std::runtime_error( s );
|
||||
}
|
||||
}
|
||||
while (this->continuator( _pop ) );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue