Translate#

class translate#

The translate meta-problem.

This meta-problem translates the whole search space of an input problem by a fixed translation vector. pagmo::translate objects are user-defined problems that can be used in the definition of a pagmo::problem.

Public Functions

translate()#

Default constructor.

The constructor will initialize a non-translated default-constructed pagmo::problem.

template<typename T, ctor_enabler<T> = 0>
inline explicit translate(T &&p, const vector_double &translation)#

Constructor from problem and translation vector.

Wraps a user-defined problem so that its fitness , bounds, etc. will be shifted by a translation vector.

Note

This constructor is enabled only if T can be used to construct a pagmo::problem.

Parameters
  • p – a pagmo::problem or a user-defined problem (UDP).

  • translation – an std::vector containing the translation to apply.

Throws
  • std::invalid_argument – if the length of translation is not equal to the problem dimension \( n_x\).

  • unspecified – any exception thrown by the pagmo::problem constructor.

vector_double fitness(const vector_double&) const#

Fitness.

The fitness computation is forwarded to the inner UDP, after the translation of x.

Parameters

x – the decision vector.

Throws

unspecified – any exception thrown by memory errors in standard containers, or by problem::fitness().

Returns

the fitness of x.

vector_double batch_fitness(const vector_double&) const#

Batch fitness.

The batch fitness computation is forwarded to the inner UDP, after the translation of xs.

Parameters

xs – the input decision vectors.

Throws

unspecified – any exception thrown by memory errors in standard containers, threading primitives, or by problem::batch_fitness().

Returns

the fitnesses of xs.

bool has_batch_fitness() const#

Check if the inner problem can compute fitnesses in batch mode.

Returns

the output of the has_batch_fitness() member function invoked by the inner problem.

std::pair<vector_double, vector_double> get_bounds() const#

Box-bounds.

The box-bounds returned by this method are the translated box-bounds of the inner UDP.

Throws

unspecified – any exception thrown by memory errors in standard containers, or by problem::get_bounds().

Returns

the lower and upper bounds for each of the decision vector components.

vector_double::size_type get_nobj() const#

Number of objectives.

Returns

the number of objectives of the inner problem.

vector_double::size_type get_nec() const#

Equality constraint dimension.

Returns the number of equality constraints of the inner problem.

Returns

the number of equality constraints of the inner problem.

vector_double::size_type get_nic() const#

Inequality constraint dimension.

Returns the number of inequality constraints of the inner problem.

Returns

the number of inequality constraints of the inner problem.

vector_double::size_type get_nix() const#

Integer dimension.

Returns

the integer dimension of the inner problem.

bool has_gradient() const#

Checks if the inner problem has gradients.

The has_gradient() computation is forwarded to the inner problem.

Returns

a flag signalling the availability of the gradient in the inner problem.

vector_double gradient(const vector_double&) const#

Gradients.

The gradients computation is forwarded to the inner problem, after the translation of x.

Parameters

x – the decision vector.

Throws

unspecified – any exception thrown by memory errors in standard containers, or by problem::gradient().

Returns

the gradient of the fitness function.

bool has_gradient_sparsity() const#

Checks if the inner problem has gradient sparisty implemented.

The has_gradient_sparsity() computation is forwarded to the inner problem.

Returns

a flag signalling the availability of the gradient sparisty in the inner problem.

sparsity_pattern gradient_sparsity() const#

Gradient sparsity.

The gradient_sparsity computation is forwarded to the inner problem.

Returns

the gradient sparsity of the inner problem.

bool has_hessians() const#

Checks if the inner problem has hessians.

The has_hessians() computation is forwarded to the inner problem.

Returns

a flag signalling the availability of the hessians in the inner problem.

std::vector<vector_double> hessians(const vector_double&) const#

Hessians.

The hessians() computation is forwarded to the inner problem, after the translation of x.

Parameters

x – the decision vector.

Throws

unspecified – any exception thrown by memory errors in standard containers, or by problem::hessians().

Returns

the hessians of the fitness function computed at x.

bool has_hessians_sparsity() const#

Checks if the inner problem has hessians sparisty implemented.

The has_hessians_sparsity() computation is forwarded to the inner problem.

Returns

a flag signalling the availability of the hessians sparisty in the inner problem.

std::vector<sparsity_pattern> hessians_sparsity() const#

Hessians sparsity.

The hessians_sparsity() computation is forwarded to the inner problem.

Returns

the hessians sparsity of the inner problem.

bool has_set_seed() const#

Calls has_set_seed() of the inner problem.

Calls the method has_set_seed() of the inner problem.

Returns

a flag signalling whether the inner problem is stochastic.

void set_seed(unsigned)#

Calls set_seed() of the inner problem.

Calls the method set_seed() of the inner problem.

Parameters

seed – seed to be set.

Throws

unspecified – any exception thrown by the method set_seed() of the inner problem.

std::string get_name() const#

Problem name.

This method will add [translated] to the name provided by the inner problem.

Throws

unspecified – any exception thrown by problem::get_name() or memory errors in standard classes.

Returns

a string containing the problem name.

std::string get_extra_info() const#

Extra info.

This method will append a description of the translation vector to the extra info provided by the inner problem.

Throws

unspecified – any exception thrown by problem::get_extra_info(), the public interface of std::ostringstream or memory errors in standard classes.

Returns

a string containing extra info on the problem.

const vector_double &get_translation() const#

Get the translation vector.

Returns

a reference to the translation vector.

thread_safety get_thread_safety() const#

Problem’s thread safety level.

The thread safety of a meta-problem is defined by the thread safety of the inner pagmo::problem.

Returns

the thread safety level of the inner pagmo::problem.

const problem &get_inner_problem() const#

Getter for the inner problem.

Returns a const reference to the inner pagmo::problem.

Returns

a const reference to the inner pagmo::problem.

problem &get_inner_problem()#

Getter for the inner problem.

Returns a reference to the inner pagmo::problem.

Note

The ability to extract a non const reference is provided only in order to allow to call non-const methods on the internal pagmo::problem instance. Assigning a new pagmo::problem via this reference is undefined behaviour.

Returns

a reference to the inner pagmo::problem.