Merge branch 'master' of ssh://trtp7097/home/bouvier/eo into eompi

This commit is contained in:
Johann Dreo 2012-07-20 11:27:38 +02:00
commit e7d38c54f0
31 changed files with 2280 additions and 53 deletions

View file

@ -120,21 +120,37 @@ struct CatBestAnswers : public eo::mpi::HandleResponseParallelApply<EOT>
best.fitness( 1000000000. );
}
/*
our structure inherits the member _wrapped from HandleResponseFunction,
which is a HandleResponseFunction pointer;
it inherits also the member _d (like Data), which is a pointer to the
ParallelApplyData used in the HandleResponseParallelApply&lt;EOT&gt;. Details
of this data are contained in the file eoParallelApply. We need just to know that
it contains a member assignedTasks which maps a worker rank and the sent slice
to be processed by the worker, and a reference to the processed table via the
call of the data() function.
*/
// if EOT were a template, we would have to do: (thank you C++ :)
// using eo::mpi::HandleResponseParallelApply<EOT>::_wrapped;
// using eo::mpi::HandleResponseParallelApply<EOT>::d;
void operator()(int wrkRank)
{
eo::mpi::ParallelApplyData<EOT> * d = _data;
// Retrieve informations about the slice processed by the worker
int index = d->assignedTasks[wrkRank].index;
int size = d->assignedTasks[wrkRank].size;
(*_wrapped)( wrkRank ); // call to the wrapped function HERE
// call to the wrapped function HERE
(*_wrapped)( wrkRank );
// Compare fitnesses of evaluated individuals with the best saved
for(int i = index; i < index+size; ++i)
{
if( best.fitness() < d->data()[ i ].fitness() )
if( best.fitness() < d->table()[ i ].fitness() )
{
eo::log << eo::quiet << "Better solution found:" << d->data()[i].fitness() << std::endl;
best = d->data()[ i ];
eo::log << eo::quiet << "Better solution found:" << d->table()[i].fitness() << std::endl;
best = d->table()[ i ];
}
}
}
@ -147,6 +163,7 @@ struct CatBestAnswers : public eo::mpi::HandleResponseParallelApply<EOT>
int main(int ac, char** av)
{
eo::mpi::Node::init( ac, av );
// eo::log << eo::setlevel( eo::debug );
eo::log << eo::setlevel( eo::quiet );
eoParser parser(ac, av);
@ -179,10 +196,15 @@ int main(int ac, char** av)
eo::log << "Size of population : " << popSize << std::endl;
/*
eo::mpi::ParallelApplyStore< EOT > store( eval, eo::mpi::DEFAULT_MASTER );
store.wrapHandleResponse( new CatBestAnswers );
eoParallelPopLoopEval< EOT > popEval( assign, eo::mpi::DEFAULT_MASTER, &store );
*/
eoParallelPopLoopEval< EOT > popEval( assign, eo::mpi::DEFAULT_MASTER, eval, 5 );
eo::log << eo::quiet << "Before first evaluation." << std::endl;
popEval( pop, pop );
eo::log << eo::quiet << "After first evaluation." << std::endl;

View file

@ -101,7 +101,7 @@ int main(int argc, char** argv)
// This is the only thing which changes: we wrap the IsFinished function.
// According to RAII, we'll delete the invokated wrapper at the end of the main ; the store won't delete it
// automatically.
IsFinishedParallelApply* wrapper = new ShowWrappedResult<int>;
IsFinishedParallelApply<int>* wrapper = new ShowWrappedResult<int>;
store.wrapIsFinished( wrapper );
ParallelApply<int> job( assign, eo::mpi::DEFAULT_MASTER, store );