ParadisEO - PEO Lesson 3: Parallel evaluation

Note: All the components are not presented in this lesson (binary, topology, asynchronous or synchronous... ). To know the completeness of components refer to API documentation of ParadisEO-EO and ParadisEO-PEO.

Introduction

In many optimization problems, the evaluation step is very time consuming. Evaluating individuals on several processes might be, therefore, worthwhile. However, one should take into account the communication time between processes. Indeed, communication time could disadvantage the gain obtained by parallelizing the evaluation step. It is up to the user then to find the right number of processes on which to run the parallel evaluation of his optimization problem.

Requirements

If you still have not seen the previous lessons, we strongly advise you to do so. It would help you understanding what it is done here.

Implementation

All that is needed is to wrap our evaluation function into a functor. Then, this latter is itself wrapped into a peoPopEval. You do not need to do more than that. Easy, is it not?

For a parallel evaluation

  ProblemEvalFunc plainEval;
  peoPopEval<Problem> eval(plainEval);

Now, you must be familiar with the declaration of a parallel algorithm:

Parallel algorithm

  eoEasyEA<Problem> gga(genCont, eval, select, transform, replace);

  peoWrapper parallel( gga, pop);
  eval.setOwner(parallel);

  peo :: run();
  peo :: finalize();
  if (getNodeRank()==1) //If your runner is on the node 1
    {
      pop.sort();
      std::cout << "Final population :\n" << pop << std::endl;
    }

Launching the program

You are ready to run your program !!