Constrained optimization utilities
Constrained optimization utilities#
A number of utilities to compute quantities that are of relevance to constrained optimization tasks.

std::vector<pop_size_t> pagmo::sort_population_con(const std::vector<vector_double>&, vector_double::size_type, const vector_double&)#
Sorts a population in a singleobjective, constrained, case (from a vector of tolerances)
Sorts a population (intended here as an
std::vector<vector_double>
containing single objective fitness vectors) with respect to the following strict ordering:\(f_1 \prec f_2\) if \(f_1\) is feasible and \(f_2\) is not.
\(f_1 \prec f_2\) if \(f_1\) is they are both infeasible, but \(f_1\) violates fewer constraints than \(f_2\), or in case they both violate the same number of constraints, if the \(L_2\) norm of the overall constraint violation is smaller.
\(f_1 \prec f_2\) if both fitness vectors are feasible and the objective value in \(f_1\) is smaller than the objective value in \(f_2\)
Note
The fitness vectors are assumed to contain exactly one objective,
neq
equality constraints and the rest (if any) inequality constraints Parameters
input_f – an
std::vector
of fitness vectors (containing objectives and constraints)neq – number of equality constraints
tol – a vector_double containing tolerances to be accounted for in the constraints
 Throws
std::invalid_argument – If the input fitness vectors do not have all the same size \(n >=1\)
std::invalid_argument – If
neq
is larger than \(n  1\) (too many constraints)std::invalid_argument – If the size of the
tol
is not \(n  1\)
 Returns
an
std::vector
of indexes containing the sorted population

std::vector<pop_size_t> pagmo::sort_population_con(const std::vector<vector_double> &input_f, vector_double::size_type neq, double tol)#
Sorts a population in a singleobjective, constrained, case (from a scalar tolerance)
 Parameters
input_f – an
std::vector
of fitness vectors (containing objectives and constraints)neq – number of equality constraints
tol – scalar tolerance to be accounted for in the constraints
 Throws
std::invalid_argument – If the input fitness vectors do not have all the same size \(n >=1\)
std::invalid_argument – If
neq
is larger than \(n  1\) (too many constraints)
 Returns
an
std::vector
of indexes containing the sorted population

bool pagmo::compare_fc(const vector_double&, const vector_double&, vector_double::size_type, const vector_double&)#
Compares two fitness vectors in a singleobjective, constrained, case (from a vector of tolerances)
Comparison between two fitness vectors (assuming a singleobjective optimization) with respect to the following strict ordering:
\(f_1 \prec f_2\) if \(f_1\) is feasible and \(f_2\) is not.
\(f_1 \prec f_2\) if \(f_1\) is they are both infeasible, but \(f_1\) violates fewer constraints than \(f_2\), or in case they both violate the same number of constraints, if the \(L_2\) norm of the overall constraint violation is smaller.
\(f_1 \prec f_2\) if both fitness vectors are feasible and the objective value in \(f_1\) is smaller than the objective value in \(f_2\)
Note
The fitness vectors are assumed to contain exactly one objective,
neq
equality constraints and the rest (if any) inequality constraints Parameters
f1 – first fitness vector
f2 – second fitness vector
neq – number of equality constraints
tol – a vector_double containing the tolerances to be accounted for in the constraints
 Throws
std::invalid_argument – If
f1
andf2
do not have equal size \(n\)std::invalid_argument – If
f1
does not have at least size 1std::invalid_argument – If
neq
is larger than \(n  1\) (too many constraints)std::invalid_argument – If the size of the
tol
is not exactly the size off1
 1
 Returns
true if
f1
is “better” thanf2

bool pagmo::compare_fc(const vector_double&, const vector_double&, vector_double::size_type, double)#
Compares two fitness vectors in a singleobjective, constrained, case (from a scalar tolerance)
 Parameters
f1 – first fitness vector
f2 – second fitness vector
neq – number of equality constraints
tol – a vector_double containing the tolerances to be accounted for in the constraints
 Throws
std::invalid_argument – If
f1
andf2
do not have equal size \(n\)std::invalid_argument – If
f1
does not have at least size 1std::invalid_argument – If
neq
is larger than \(n  1\) (too many constraints)
 Returns
true if
f1
is “better” thanf2