Unconstrain#

class unconstrain#

The unconstrain meta-problem.

This meta-problem transforms a constrained problem into an unconstrained problem applying one of the following methods:

  • Death penalty: simply penalizes all objectives by the same high value if the fitness vector is infeasible as checked by pagmo::problem::feasibility_f().

  • Kuri’s death penalty: defined by Angel Kuri Morales et al., penalizes all objectives according to the rate of satisfied constraints.

  • Weighted violations penalty: penalizes all objectives by the weighted sum of the constraint violations.

  • Ignore the constraints: simply ignores the constraints.

  • Ignore the objectives: ignores the objectives and defines as a new single objective the overall constraints violation (i.e. the sum of the L2 norms of the equalities and inequalities violations)

See: Coello Coello, C. A. (2002). Theoretical and numerical constraint-handling techniques used with evolutionary algorithms: a survey of the state of the art. Computer methods in applied mechanics and engineering, 191(11), 1245-1287.

See: Kuri Morales, A. and Quezada, C.C. A Universal eclectic genetic algorithm for constrained optimization, Proceedings 6th European Congress on Intelligent Techniques & Soft Computing, EUFIT’98, 518-522, 1998.

Public Functions

unconstrain()#

Default constructor.

The default constructor will initialize a pagmo::null_problem unconstrained via the death penalty method.

template<typename T, ctor_enabler<T> = 0>
inline explicit unconstrain(T &&p, const std::string &method = "death penalty", const vector_double &weights = vector_double())#

Constructor from UDP and unconstrain method.

Wraps a user-defined problem so that its constraints will be removed

Note

This constructor is enabled only if T can be used to construct a pagmo::problem and if T, after the removal of reference and cv qualifiers, is not pagmo::unconstrain.

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

  • method – an std::string containing the name of the method to be used t remove the constraints: one of “death penalty”, “kuri”, “weighted”, “ignore_c” or “ignore_o”.

  • weights – an std::vector containing the weights in case “weighted” is selected as method.

Throws
  • std::invalid_argument – if the length of weights is not equal to the problem constraint dimension \( n_{ec} + n_{ic}\) when method is “weighted”, if the method is not one of “death penalty”, “kuri”, “weighted”, “ignore_c” or “ignore_o”, if the weights vector is not empty and the method is not “weighted” or if is already unconstrained

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

vector_double fitness(const vector_double&) const#

Fitness.

The unconstrained fitness computation.

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.

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.

vector_double batch_fitness(const vector_double &xs) const#

Batch fitness.

The batch fitness computation is forwarded to the inner UDP and then all are penalized.

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.

vector_double::size_type get_nobj() const#

Number of objectives.

Returns

the number of objectives of the inner problem.

vector_double::size_type get_nix() const#

Integer dimension.

Returns

the integer dimension of the inner problem.

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

Box-bounds.

Forwards the bounds computations to the inner pagmo::problem.

Throws

unspecified – any exception thrown by problem::get_bounds().

Returns

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

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

std::not_implemented_error – if the inner problem is not stochastic.

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.

std::string get_name() const#

Problem name.

This method will add [unconstrained] 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 unconstrain method 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.