esa / pagmo2

A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pagmo2/
GNU General Public License v3.0
829 stars 161 forks source link

Batch evaluators improvements #283

Closed bluescarni closed 4 years ago

bluescarni commented 5 years ago

PR #226 introduced a new framework of batch evaluators to implement an (often requested) finer level of parallelism in pagmo.

The core new feature is a class, called bfe (short for "batch fitness evaluator"), that other pagmo classes (e.g., population, algorithms, etc.) can use when the need arise to evaluate a large batch of individuals, possibly in a parallelised and/or vectorised fashion. For instance, the bfe class is now used by the population class to implement the parallel initialisation of the fitnesses of its individuals.

The bfe class, similarly to other pagmo classes such as problem, algorithm, etc. is a type-erased container that stores internally what we call a UDBFE (user-defined batch fitness evaluator), which actually implements the evaluation of the fitnesses of a batch of input decision vectors. The thread_bfe UDBFE, for instance, parallelises the evaluation of a batch of decision vectors using the Intel TBB library.

In addition to the bfe class, pagmo problems can now implement an additional, optional method, called batch_fitness(), which implements the batch fitness evaluation functionality on a problem-by-problem basis. That is, whereas a thread_bfe is capable of accelerating the evaluation of a generic pagmo problem via the multi-threaded invocation of the problem's fitness() method, the batch_fitness() method is usable only by those problem actually implementing it. The batch_fitness() method requires, essentially, the implementation of the fitness function of a problem in two places, fitness() and batch_fitness(); the payoff is that the batch_fitness() method allows, for instance, to implement the parallelised evaluation of a group of individuals using specialised hardware(e.g., GPUs, SIMD instructions, etc.), which would not be otherwise possible with the bfe class (which only "sees" the fitness() method of the problem as a black box).

226 contains a complete, tested and API-documented batch fitness evaluation API for C++. The python exposition, however is incomplete, and user-docs and tutorials need also to be written, given the non-trivial nature of this new feature. This PR tracks the progress of the missing pieces.

Python

C++

Docs

bluescarni commented 4 years ago

This is now being worked on in #380.

bluescarni commented 4 years ago

Most of the todo items were completed in #380, the rest is more long term. Will close this for now.