File: thread_bfe.rst

package info (click to toggle)
pagmo 2.19.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 85,228 kB
  • sloc: cpp: 1,753,592; makefile: 223; sh: 121; python: 46
file content (45 lines) | stat: -rw-r--r-- 2,184 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Multithreaded BFE
=================

.. versionadded:: 2.11

*#include <pagmo/batch_evaluators/thread_bfe.hpp>*

.. cpp:namespace-push:: pagmo

.. cpp:class:: thread_bfe

   This class is a user-defined batch fitness evaluator (UDBFE) that can be used to
   construct a :cpp:class:`~pagmo::bfe`.
   :cpp:class:`~pagmo::thread_bfe` will use multiple threads of execution to parallelise
   the evaluation of the fitnesses of a batch of input decision vectors.

   .. cpp:function:: vector_double operator()(problem p, const vector_double &dvs) const

      Call operator.

      The call operator will use the input problem *p* to evaluate
      the fitnesses of the decision vectors stored contiguously in *dvs*. The fitness evaluation
      will be run in parallel using multiple threads of execution. Because of this, the input
      problem *p* must provide at least the :cpp:enumerator:`~pagmo::thread_safety::basic`
      thread safety level, otherwise an exception will be raised (see :cpp:func:`pagmo::problem::get_thread_safety()`).

      If *p* provides at least the :cpp:enumerator:`~pagmo::thread_safety::constant` thread safety level,
      then *p* will be shared across multiple threads and its :cpp:func:`~problem::fitness()` function
      will be called simultaneously from different threads. Otherwise, copies of *p* will be created and
      the :cpp:func:`~problem::fitness()` function will be called on these copies.

      :param p: the input :cpp:class:`~pagmo::problem`.
      :param dvs: the input decision vectors that will be evaluated.

      :return: the fitness vectors corresponding to the input decision vectors in *dvs*.

      :exception std\:\:invalid_argument: if *p* does not provide at least the :cpp:enumerator:`~pagmo::thread_safety::basic` thread safety level.
      :exception std\:\:overflow_error: in case of (unlikely) internal overflow conditions.
      :exception unspecified: any exception raised by memory allocation failures or by the public API of :cpp:class:`~pagmo::problem`.

   .. cpp:function:: std::string get_name() const

      :return: a human-readable name for this :cpp:class:`~pagmo::thread_bfe`.

.. cpp:namespace-pop::