Clean src. Add setTopology to the island model

This commit is contained in:
quemy 2012-11-24 16:38:08 +01:00
commit ae4699176f
4 changed files with 31 additions and 35 deletions

View file

@ -55,11 +55,10 @@ void paradiseo::smp::Island<EOAlgo,EOT>::operator()()
{
stopped = false;
algo(pop);
stopped = true;
// Let's wait the end of communications with the island model
for(auto& message : sentMessages)
message.join();
stopped = true;
//std::cout << "Fin de l'île " << this << std::endl;
}
template<template <class> class EOAlgo, class EOT>
@ -77,15 +76,12 @@ eoPop<EOT>& paradiseo::smp::Island<EOAlgo,EOT>::getPop()
template<template <class> class EOAlgo, class EOT>
void paradiseo::smp::Island<EOAlgo,EOT>::check()
{
// std::cout << "On check" << std::endl;
// Sending
for(PolicyElement<EOT>& elem : migPolicy)
{
if(!elem(pop))
{
// std::cout << "On lance l'emmigration" << std::endl;
send(elem.getSelect());
}
}
// Receiving
receive();
}
@ -98,13 +94,12 @@ bool paradiseo::smp::Island<EOAlgo,EOT>::isStopped(void) const
template<template <class> class EOAlgo, class EOT>
void paradiseo::smp::Island<EOAlgo,EOT>::send(eoSelect<EOT>& _select)
{
// Allow island to work alone
if(model != nullptr)
{
//std::cout << "Ile lance la migration" << std::endl;
eoPop<EOT> migPop;
_select(pop, migPop);
//std::cout << " La population migrante est :" << std::endl << migPop << std::endl;
// Delete delivered messages
for(auto it = sentMessages.begin(); it != sentMessages.end(); it++)
if(!it->joinable())
@ -119,19 +114,12 @@ void paradiseo::smp::Island<EOAlgo,EOT>::receive(void)
{
std::lock_guard<std::mutex> lock(this->m);
while (!listImigrants.empty())
{
{
eoPop<EOT> offspring = listImigrants.front();
// Evaluate objects to integrate
//std::cout << "Evaluation des individus : " << std::endl;
for(auto& indi : offspring)
{
eval(indi);
//std::cout << indi << std::endl;
}
//std::cout << "Ile " << this << " recoit : " << std::endl;
//std::cout << offspring << std::endl;
intPolicy(pop, offspring);
listImigrants.pop();