Type traits and enums#

enum class thread_safety#

This enum defines a set of values that can be used to specify the thread safety level of an object.

Most of the user-defined classes that can be implemented in pagmo (i.e., problems, algorithms, etc.) provide mechanisms to specify which thread safety level is provided by objects of these classes. The information on the thread safety level is used by pagmo to establish at runtime whether or not it is safe to use an object in a multithreaded context.

For instance, thread_island will refuse to run parallel optimisations in multiple threads if the involved problem or algorithm do not provide at least the basic thread safety level.

The thread safety levels are ordered in the following way: none < basic < constant.

enumerator none#

No thread safety: concurrent operations on distinct objects are unsafe.

enumerator basic#

Basic thread safety: concurrent operations on distinct objects are safe.

enumerator constant#

Constant thread safety: constant (i.e., read-only) concurrent operations on the same object are safe.

std::ostream &operator<<(std::ostream &os, thread_safety ts)#

Stream operator for thread_safety. It will direct to the stream os a human-readable representation of ts.

Parameters
  • os – an output stream.

  • ts – the thread_safety to be directed to the output stream.

Returns

a reference to os.

Throws

unspecified – any exception raised by the public interface of std::ostream.

template<typename T>
class is_udp#

Detect user-defined problems (UDP).

This type trait will be true if T is not cv/reference qualified, it is destructible, default, copy and move constructible, and if it satisfies the pagmo::has_fitness and pagmo::has_bounds type traits.

Types satisfying this type trait can be used as user-defined problems (UDP) in pagmo::problem.

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class is_uda#

Detect user-defined algorithms (UDA).

This type trait will be true if T is not cv/reference qualified, it is destructible, default, copy and move constructible, and if it satisfies the pagmo::has_evolve type trait.

Types satisfying this type trait can be used as user-defined algorithms (UDA) in pagmo::algorithm.

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_fitness#

Detect fitness() method.

This type trait will be true if T provides a method with the following signature:

vector_double fitness(const vector_double &) const;
The fitness() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_bounds#

Detect get_bounds() method.

This type trait will be true if T provides a method with the following signature:

std::pair<vector_double, vector_double> get_bounds() const;
The get_bounds() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_e_constraints#

Detect get_nec() method.

This type trait will be true if T provides a method with the following signature:

vector_double::size_type get_nec() const;
The get_nec() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_i_constraints#

Detect get_nic() method.

This type trait will be true if T provides a method with the following signature:

vector_double::size_type get_nic() const;
The get_nic() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_integer_part#

Detect get_nix() method.

This type trait will be true if T provides a method with the following signature:

vector_double::size_type get_nix() const;
The get_nix() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_name#

Detect get_name() method.

This type trait will be true if T provides a method with the following signature:

std::string get_name() const;
The get_name() method is part of the interface for the definition of problems and algorithms (see pagmo::problem and pagmo::algorithm).

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_extra_info#

Detect get_extra_info() method.

This type trait will be true if T provides a method with the following signature:

std::string get_extra_info() const;
The get_extra_info() method is part of the interface for the definition of problems and algorithms (see pagmo::problem and pagmo::algorithm).

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_get_thread_safety#

Detect get_thread_safety() method.

This type trait will be true if T provides a method with the following signature:

pagmo::thread_safety get_thread_safety() const;
The get_thread_safety() method is part of the interface for the definition of problems and algorithms (see pagmo::problem and pagmo::algorithm).

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_gradient#

Detect gradient() method.

This type trait will be true if T provides a method with the following signature:

vector_double gradient(const vector_double &) const;
The gradient() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class override_has_gradient#

Detect has_gradient() method.

This type trait will be true if T provides a method with the following signature:

bool has_gradient() const;
The has_gradient() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_gradient_sparsity#

Detect gradient_sparsity() method.

This type trait will be true if T provides a method with the following signature:

sparsity_pattern gradient_sparsity() const;
The gradient_sparsity() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class override_has_gradient_sparsity#

Detect has_gradient_sparsity() method.

This type trait will be true if T provides a method with the following signature:

bool has_gradient_sparsity() const;
The has_gradient_sparsity() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_hessians#

Detect hessians() method.

This type trait will be true if T provides a method with the following signature:

std::vector<vector_double> hessians(const vector_double &) const;
The hessians() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class override_has_hessians#

Detect has_hessians() method.

This type trait will be true if T provides a method with the following signature:

bool has_hessians() const;
The has_hessians() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_hessians_sparsity#

Detect hessians_sparsity() method.

This type trait will be true if T provides a method with the following signature:

std::vector<sparsity_pattern> hessians_sparsity() const;
The hessians_sparsity() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class override_has_hessians_sparsity#

Detect has_hessians_sparsity() method.

This type trait will be true if T provides a method with the following signature:

bool has_hessians_sparsity() const;
The has_hessians_sparsity() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_set_verbosity#

Detect set_verbosity() method.

This type trait will be true if T provides a method with the following signature:

void set_verbosity(unsigned);
The set_verbosity() method is part of the interface for the definition of an algorithm (see pagmo::algorithm).

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.

template<typename T>
class override_has_set_verbosity#

Detect has_set_verbosity() method.

This type trait will be true if T provides a method with the following signature:

bool has_set_verbosity() const;
The has_set_verbosity() method is part of the interface for the definition of an algorithm (see pagmo::algorithm).

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_evolve#

Detect evolve() method.

This type trait will be true if T provides a method with the following signature:

population evolve(const population &) const;
The evolve() method is part of the interface for the definition of an algorithm (see pagmo::algorithm).

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_get_nobj#

Detect get_nobj() method.

This type trait will be true if T provides a method with the following signature:

vector_double::size_type get_nobj() const;
The get_nobj() method is part of the interface for the definition of a problem (see pagmo::problem).

Public Static Attributes

static constexpr bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_set_seed#

Detect set_seed() method.

This type trait will be true if T provides a method with the following signature:

void set_seed(unsigned);
The set_seed() method is part of the interface for the definition of problems and algorithms (see pagmo::problem and pagmo::algorithm).

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.

template<typename T>
class override_has_set_seed#

Detect has_set_seed() method.

This type trait will be true if T provides a method with the following signature:

bool has_set_seed() const;
The has_set_seed() method is part of the interface for the definition of problems and algorithms (see pagmo::problem and pagmo::algorithm).

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.

template<typename T>
class has_run_evolve#

Detect run_evolve() method.

This type trait will be true if T provides a method with the following signature:

void run_evolve(island &) const;
The run_evolve() method is part of the interface for the definition of an island (see pagmo::island).

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.

template<typename T>
class is_udi#

Detect user-defined islands (UDI).

This type trait will be true if T is not cv/reference qualified, it is destructible, default, copy and move constructible, and if it satisfies the pagmo::has_run_evolve type trait.

Types satisfying this type trait can be used as user-defined islands (UDI) in pagmo::island.

Public Static Attributes

static const bool value = implementation_defined#

Value of the type trait.