PaGMO  1.1.5
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Friends
pagmo::problem::base Class Referenceabstract

Base problem class. More...

#include <base.h>

Inherited by pagmo::problem::ackley, pagmo::problem::antibodies_problem, pagmo::problem::base_meta, pagmo::problem::base_stochastic, pagmo::problem::base_tsp, pagmo::problem::base_unc_mo, pagmo::problem::branin, pagmo::problem::bukin, pagmo::problem::cassini_1, pagmo::problem::cassini_2, pagmo::problem::cec2006, pagmo::problem::cec2009, pagmo::problem::cec2013, pagmo::problem::dejong, pagmo::problem::earth_planet, pagmo::problem::fon, pagmo::problem::golomb_ruler, pagmo::problem::griewank, pagmo::problem::gtoc5_flyby, pagmo::problem::gtoc5_launch, pagmo::problem::gtoc5_rendezvous, pagmo::problem::gtoc5_self_flyby, pagmo::problem::gtoc_1, pagmo::problem::gtoc_2, pagmo::problem::himmelblau, pagmo::problem::identity, pagmo::problem::island_init, pagmo::problem::kur, pagmo::problem::laplace, pagmo::problem::lavor_maculan, pagmo::problem::lennard_jones, pagmo::problem::levy5, pagmo::problem::luksan_vlcek_1, pagmo::problem::luksan_vlcek_2, pagmo::problem::luksan_vlcek_3, pagmo::problem::messenger, pagmo::problem::messenger_full, pagmo::problem::mga_1dsm_alpha, pagmo::problem::mga_1dsm_tof, pagmo::problem::mga_incipit, pagmo::problem::mga_incipit_cstrs, pagmo::problem::mga_part, pagmo::problem::mga_target_event, pagmo::problem::michalewicz, pagmo::problem::pol, pagmo::problem::pressure_vessel, pagmo::problem::rastrigin, pagmo::problem::rosenbrock, pagmo::problem::rosetta, pagmo::problem::sagas, pagmo::problem::sample_return, pagmo::problem::sch, pagmo::problem::schwefel, pagmo::problem::snopt_toyprob, pagmo::problem::string_match, pagmo::problem::tandem, pagmo::problem::tens_comp_string, and pagmo::problem::welded_beam.

Public Types

typedef decision_vector::size_type size_type
 Problem's size type: the same as pagmo::decision_vector's size type.
 
typedef fitness_vector::size_type f_size_type
 Fitness' size type: the same as pagmo::fitness_vector's size type.
 
typedef constraint_vector::size_type c_size_type
 Constraints' size type: the same as pagmo::constraint_vector's size type.
 

Public Member Functions

 base (int, int=0, int=1, int=0, int=0, const double &=0)
 Constructor from global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More...
 
 base (int, int, int, int, int, const std::vector< double > &)
 Constructor from global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More...
 
 base (const double &, const double &, int, int=0, int=1, int=0, int=0, const double &=0)
 Constructor from values for lower and upper bounds, global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More...
 
 base (const decision_vector &, const decision_vector &, int=0, int=1, int=0, int=0, const double &=0)
 Constructor from upper/lower bounds, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More...
 
template<std::size_t N>
 base (const double(&v1)[N], const double(&v2)[N], int ni=0, int nf=1, int nc=0, int nic=0, const double &c_tol=0)
 Constructor from raw arrays, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More...
 
template<class Iterator1 , class Iterator2 >
 base (Iterator1 start1, Iterator1 end1, Iterator2 start2, Iterator2 end2, int ni=0, int nf=1, int nc=0, int nic=0, const double &c_tol=0)
 Constructor from iterators, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More...
 
virtual ~base ()
 Trivial destructor. More...
 
virtual base_ptr clone () const =0
 Clone method. More...
 
std::string human_readable () const
 Return human readable representation of the problem. More...
 
virtual std::string human_readable_extra () const
 Extra information in human readable format. More...
 
bool operator== (const base &) const
 Equality operator. More...
 
bool operator!= (const base &) const
 Inequality operator. More...
 
bool is_compatible (const base &) const
 Compatibility operator. More...
 
bool compare_x (const decision_vector &, const decision_vector &) const
 Compare decision vectors. More...
 
bool verify_x (const decision_vector &) const
 Verify compatibility of decision vector x with problem. More...
 
bool compare_fc (const fitness_vector &, const constraint_vector &, const fitness_vector &, const constraint_vector &) const
 Simultaneous fitness-constraint comparison. More...
 
virtual void pre_evolution (population &) const
 Pre-evolution hook. More...
 
virtual void post_evolution (population &) const
 Post-evolution hook. More...
 
virtual void set_sparsity (int &lenG, std::vector< int > &iGfun, std::vector< int > &jGvar) const
 Sets the sparsity pattern of the gradient. More...
 
Bounds setters/getters.

Methods used to manipulate problem bounds.

const decision_vectorget_lb () const
 Lower bounds getter. More...
 
const decision_vectorget_ub () const
 Upper bounds getter. More...
 
void set_bounds (const decision_vector &, const decision_vector &)
 Bounds setter from pagmo::decision_vector. More...
 
template<class Iterator1 , class Iterator2 >
void set_bounds (Iterator1 start1, Iterator1 end1, Iterator2 start2, Iterator2 end2)
 Bounds setter from iterators. More...
 
template<std::size_t N>
void set_bounds (const double(&v1)[N], const double(&v2)[N])
 Bounds setter from raw arrays. More...
 
void set_bounds (const double &, const double &)
 Set bounds to specified values. More...
 
void set_bounds (int, const double &, const double &)
 Set bounds to specified values. More...
 
void set_lb (const decision_vector &)
 Set lower bounds from pagmo::decision_vector. More...
 
void set_lb (int, const double &)
 Set specific lower bound to value. More...
 
void set_lb (const double &)
 Set all lower bounds to value. More...
 
template<class Iterator >
void set_lb (Iterator start, Iterator end)
 Lower bounds setter from iterators. More...
 
template<std::size_t N>
void set_lb (const double(&v)[N])
 Lower bounds setter from raw array. More...
 
void set_ub (const decision_vector &)
 Set upper bounds from pagmo::decision_vector. More...
 
void set_ub (int, const double &)
 Set specific upper bound to value. More...
 
void set_ub (const double &)
 Set all upper bounds to value. More...
 
template<class Iterator >
void set_ub (Iterator start, Iterator end)
 Upper bounds setter from iterators. More...
 
template<std::size_t N>
void set_ub (const double(&v)[N])
 Upper bounds setter from raw array. More...
 
Properties getters.
unsigned int get_fevals () const
 Return number of function evaluations. More...
 
unsigned int get_cevals () const
 Return number of constraints function evaluations. More...
 
size_type get_dimension () const
 Return global dimension. More...
 
size_type get_i_dimension () const
 Return integer dimension. More...
 
f_size_type get_f_dimension () const
 Return fitness dimension. More...
 
c_size_type get_c_dimension () const
 Return global constraints dimension. More...
 
c_size_type get_ic_dimension () const
 Return inequality constraints dimension. More...
 
const std::vector< double > & get_c_tol () const
 Return constraints tolerance. More...
 
double get_diameter () const
 Get the diameter of the problem. More...
 
virtual std::string get_name () const
 Get problem's name. More...
 

Static Public Attributes

static const std::size_t cache_capacity = 5
 Capacity of the internal caches.
 

Protected Member Functions

virtual bool equality_operator_extra (const base &) const
 Extra requirements for equality. More...
 
virtual bool compare_fc_impl (const fitness_vector &, const constraint_vector &, const fitness_vector &, const constraint_vector &) const
 Implementation of simultaneous fitness-constraint comparison. More...
 
void estimate_sparsity (const decision_vector &, int &lenG, std::vector< int > &iGfun, std::vector< int > &jGvar) const
 Heuristics to estimate the sparsity pattern of the problem. More...
 
void estimate_sparsity (int &lenG, std::vector< int > &iGfun, std::vector< int > &jGvar) const
 Heuristics to estimate the sparsity pattern of the problem. More...
 

Friends

class base_meta
 
class boost::serialization::access
 

Constraints-related methods.

Methods used to calculate and compare constraints.

constraint_vector compute_constraints (const decision_vector &) const
 Compute constraints and return constraint vector. More...
 
void compute_constraints (constraint_vector &, const decision_vector &) const
 Compute constraints and write them into contraint vector. More...
 
bool compare_constraints (const constraint_vector &, const constraint_vector &) const
 Compare constraint vectors. More...
 
bool test_constraint (const constraint_vector &, const c_size_type &) const
 Test i-th constraint of c (using tolerance information). More...
 
bool feasibility_x (const decision_vector &) const
 Test feasibility of decision vector. More...
 
bool feasibility_c (const constraint_vector &) const
 Test feasibility of constraint vector. More...
 
virtual void compute_constraints_impl (constraint_vector &, const decision_vector &) const
 Implementation of constraint computation. More...
 
virtual bool compare_constraints_impl (const constraint_vector &, const constraint_vector &) const
 Implementation of constraint vector comparison. More...
 

Objective function and fitness handling.

Methods used to calculate and compare fitnesses.

fitness_vector objfun (const decision_vector &) const
 Return fitness of pagmo::decision_vector. More...
 
void objfun (fitness_vector &, const decision_vector &) const
 Write fitness of pagmo::decision_vector into pagmo::fitness_vector. More...
 
bool compare_fitness (const fitness_vector &, const fitness_vector &) const
 Compare fitness vectors. More...
 
void reset_caches () const
 Reset internal caches. More...
 
const std::vector< constraint_vector > & get_best_c (void) const
 Get the best known constraint vector. More...
 
const std::vector< decision_vector > & get_best_x (void) const
 Get the best known decision vector. More...
 
const std::vector< fitness_vector > & get_best_f (void) const
 Get the best known fitness vector. More...
 
void set_best_x (const std::vector< decision_vector > &)
 Sets the best known decision vectors. More...
 
virtual bool compare_fitness_impl (const fitness_vector &, const fitness_vector &) const
 Implementation of fitness vectors comparison. More...
 
virtual void objfun_impl (fitness_vector &f, const decision_vector &x) const =0
 Objective function implementation. More...
 

Detailed Description

Base problem class.

Introduction

This class represents a box-bounded, multiobjective, mixed-integer, constrained optimisation problem defined by:

All dimensions are invariant in the life cycle of a problem object.

The bounds of the problem are allowed to vary over the whole range of double-precision values for continuous optimisation, while for combinatorial optimisation the bounds must be in the [-32767,32767] range (corresponding to the INT_MIN and INT_MAX constants defined in the C++ standard "climits" header file). All bounds setting functions will make sure that the following conditions are respected:

If the first condition is not met, an error will be raised. If the second condition is not met, the bounds will be set to the extremes of the allowed range and/or rounded to the nearest integer as necessary. After that, an error will be generated in order to alert the user.

The constraint tolerance vector contains the tolerances for each constraints. This allows to implement constraints of type:

Note that if a single value is given to the problem constructor instead of a constraint tolerance vector, then a constraint tolerance vector of size the number of constraints filled with the given value is created.

All problems implemented in PaGMO must derive from this base class and implement the following pure virtual methods:

Additionally, the following virtual protected methods can be reimplemented in derived classes:

Please note that while a problem is intended to provide methods for ranking decision and constraint vectors, such methods are not to be used mandatorily by an algorithm: each algorithm can decide to use its own ranking schemes during an optimisation. The ranking methods provided by the problem are always used instead during the migration of decision vectors from one island to the other.

Caching

A caching mechanism is implemented to make sure the objective function is never evaluated twice on the very same chromosome

Serialization

The problem classes are serialized for the purpose of transmitting their corresponding objects over a distributed environment, as being part of the population class. Serializing a derived problem requires that the needed serialization libraries be declared in the header of the derived class. Virtually all the derived problem classes need to have the following declared in their header files:

        friend class boost::serialization::access;
        template<class Archive>

Each derived class must implement implicitly, in its header file, the serialize method, which must contain the pointer to the base class like:

        ar & boost::serialization::base_object<base>(*this);

and the rest of the attributes simply as archive members:

        ar & attribute_name;

In order to be able to identify the derived problem class when deserializing an object declared as a base_pointer, the derived problem class needs to be registered. In the case where your derived problem class has a default constructor, this is done by registering the class in the "pagmo/src/problems.h", in the REGISTER_PROBLEM_SERIALIZATIONS() routine, by adding:

ar.template register_type<problem::derived_problem>();

In the case where the derived problem does not have a default constructor, the serialization functions "load_construct_data" and "save_construct_data" need to be overriden. This done by invoking the non-default constructor in-place (in the load_construct_data) to initilize the memory (Examples can be found in the implemented problems or in the Boost Serialization libraray unde "Non-default constructor" section).W Notes:

Author
Francesco Biscani (blues.nosp@m.carn.nosp@m.i@gma.nosp@m.il.c.nosp@m.om)

Definition at line 148 of file problem/base.h.

Constructor & Destructor Documentation

pagmo::problem::base::base ( int  n,
int  ni = 0,
int  nf = 1,
int  nc = 0,
int  nic = 0,
const double &  c_tol = 0 
)

Constructor from global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance.

n and nf must be positive, ni must be in the [0,n] range, nc and nic must be positive and nic must be in the [0,nc] range. Lower and upper bounds are set to 0 and 1 respectively. Constraints tolerance must be positive.

Parameters
[in]nglobal dimension of the problem.
[in]nidimension of the combinatorial part of the problem.
[in]nfdimension of the fitness vector of the problem.
[in]ncglobal number of constraints.
[in]nicnumber of inequality constraints.
[in]c_tolconstraints tolerance. Fills the tolerance vector of size nc with c_tol.

Definition at line 65 of file problem/base.cpp.

pagmo::problem::base::base ( int  n,
int  ni,
int  nf,
int  nc,
int  nic,
const std::vector< double > &  c_tol 
)

Constructor from global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance.

n and nf must be positive, ni must be in the [0,n] range, nc and nic must be positive and nic must be in the [0,nc] range. Lower and upper bounds are set to 0 and 1 respectively. Constraints tolerance for equalities constraints must be positive.

Parameters
[in]nglobal dimension of the problem.
[in]nidimension of the combinatorial part of the problem.
[in]nfdimension of the fitness vector of the problem.
[in]ncglobal number of constraints.
[in]nicnumber of inequality constraints.
[in]c_tolconstraints tolerance vector.

Definition at line 111 of file problem/base.cpp.

pagmo::problem::base::base ( const double &  l_value,
const double &  u_value,
int  n,
int  ni = 0,
int  nf = 1,
int  nc = 0,
int  nic = 0,
const double &  c_tol = 0 
)

Constructor from values for lower and upper bounds, global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance.

l_value must not be greater than u_value, n and nf must be positive, ni must be in the [0,n] range, nc and nic must be positive and nic must be in the [0,nc] range. Lower and upper bounds are set to l_value and u_value respectively. Constraints tolerance must be positive.

Parameters
[in]l_valuevalue for all lower bounds.
[in]u_valuevalue for all upper bounds.
[in]nglobal dimension of the problem.
[in]nidimension of the combinatorial part of the problem.
[in]nfdimension of the fitness vector of the problem.
[in]ncglobal number of constraints.
[in]nicnumber of inequality constraints.
[in]c_tolconstraints tolerance. Fills the tolerance vector of size nc with c_tol.

Definition at line 164 of file problem/base.cpp.

pagmo::problem::base::base ( const decision_vector lb,
const decision_vector ub,
int  ni = 0,
int  nf = 1,
int  nc = 0,
int  nic = 0,
const double &  c_tol = 0 
)

Constructor from upper/lower bounds, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance.

Will fail if ni is negative or greater than lb.size(), if nf is not positive, if the sizes of the lower/upper bounds are zero or not identical, if any lower bound is greater than the corresponding upper bound. nc and nic must be positive and nic must be in the [0,nc] range. Constraints tolerance must be positive.

Parameters
[in]lblower bounds for the problem.
[in]ubupper bounds for the problem.
[in]nidimension of the combinatorial part of the problem.
[in]nfdimension of the fitness vector of the problem.
[in]ncglobal number of constraints.
[in]nicnumber of inequality constraints.
[in]c_tolconstraints tolerance. Fills the tolerance vector of size nc with c_tol.

Definition at line 215 of file problem/base.cpp.

template<std::size_t N>
pagmo::problem::base::base ( const double(&)  v1[N],
const double(&)  v2[N],
int  ni = 0,
int  nf = 1,
int  nc = 0,
int  nic = 0,
const double &  c_tol = 0 
)
inline

Constructor from raw arrays, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance.

Lower and upper bounds are initialised with the content of two arrays of size N. Construction will fail if at least one lower bound is greater than the corresponding upper bound, if N is zero, if integer dimension is either negative or greater than the global dimension, if fitness dimension is not positive, if constraints dimensions are negative, if inequality constraints dimension is greater than global constraints dimension, or if constraints tolerance is negative.

Parameters
[in]v1lower bounds for the problem.
[in]v2upper bounds for the problem.
[in]nidimension of the combinatorial part of the problem.
[in]nfdimension of the fitness vector of the problem.
[in]ncglobal number of constraints.
[in]nicnumber of inequality constraints.
[in]c_tolconstraints tolerance. Fills the tolerance vector of size nc with c_tol.

Definition at line 186 of file problem/base.h.

template<class Iterator1 , class Iterator2 >
pagmo::problem::base::base ( Iterator1  start1,
Iterator1  end1,
Iterator2  start2,
Iterator2  end2,
int  ni = 0,
int  nf = 1,
int  nc = 0,
int  nic = 0,
const double &  c_tol = 0 
)
inline

Constructor from iterators, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance.

Lower bounds are initialised with the content in the range [start1,end1[, upper bounds with the content in the range [start2,end2[. Construction will fail if the ranges have different or null sizes, if at least one lower bound is greater than the corresponding upper bound, if integer dimension is either negative or greater than the global dimension, if fitness dimension is not positive, if constraints dimensions are negative, if inequality constraints dimension is greater than global constraints dimension or if constraints tolerance is negative.

Parameters
[in]start1iterator to the beginning of the lower bounds sequence.
[in]end1iterator to the end of the lower bounds sequence.
[in]start2iterator to the beginning of the upper bounds sequence.
[in]end2iterator to the end of the upper bounds sequence.
[in]nidimension of the combinatorial part of the problem.
[in]nfdimension of the fitness vector of the problem.
[in]ncglobal number of constraints.
[in]nicnumber of inequality constraints.
[in]c_tolconstraints tolerance. Fills the tolerance vector of size nc with c_tol..

Definition at line 235 of file problem/base.h.

pagmo::problem::base::~base ( )
virtual

Trivial destructor.

No side effects.

Definition at line 249 of file problem/base.cpp.

Member Function Documentation

virtual base_ptr pagmo::problem::base::clone ( ) const
pure virtual

Clone method.

Provided that the derived problem implements properly the copy constructor, virtually all implementations of this method will look like this:

return base_ptr(new derived_problem(*this));
               @return problem::base_ptr to a copy of this.

Implemented in pagmo::problem::zdt, pagmo::problem::spheres, pagmo::problem::spheres_q, pagmo::problem::con2mo, pagmo::problem::dtlz, pagmo::problem::tandem, pagmo::problem::inventory, pagmo::problem::decompose, pagmo::problem::branin, pagmo::problem::mga_1dsm_alpha, pagmo::problem::noisy, pagmo::problem::mga_1dsm_tof, pagmo::problem::laplace, pagmo::problem::tsp_ds, pagmo::problem::mga_target_event, pagmo::problem::pol, pagmo::problem::antibodies_problem, pagmo::problem::death_penalty, pagmo::problem::tsp_cs, pagmo::problem::bukin, pagmo::problem::robust, pagmo::problem::mga_incipit_cstrs, pagmo::problem::con2uncon, pagmo::problem::mga_part, pagmo::problem::snopt_toyprob, pagmo::problem::golomb_ruler, pagmo::problem::gtoc_2, pagmo::problem::levy5, pagmo::problem::cassini_1, pagmo::problem::himmelblau, pagmo::util::racing::metrics_algos::standard, pagmo::problem::base_dtlz, pagmo::problem::cec2013, pagmo::problem::mga_incipit, pagmo::problem::cec2009, pagmo::problem::dejong, pagmo::problem::gtoc5_launch, pagmo::problem::messenger, pagmo::problem::schwefel, pagmo::problem::tsp, pagmo::problem::fon, pagmo::problem::griewank, pagmo::problem::gtoc5_flyby, pagmo::problem::gtoc_1, pagmo::problem::kur, pagmo::problem::messenger_full, pagmo::problem::michalewicz, pagmo::problem::rastrigin, pagmo::problem::rosenbrock, pagmo::problem::sagas, pagmo::problem::sch, pagmo::problem::ackley, pagmo::problem::rosetta, pagmo::problem::tsp_vrplc, pagmo::problem::lennard_jones, pagmo::problem::rotated, pagmo::problem::sample_return, pagmo::problem::cassini_2, pagmo::problem::cec2006, pagmo::problem::identity, pagmo::problem::luksan_vlcek_3, pagmo::problem::shifted, pagmo::problem::string_match, pagmo::problem::earth_planet, pagmo::problem::luksan_vlcek_1, pagmo::problem::luksan_vlcek_2, pagmo::problem::pressure_vessel, pagmo::problem::gtoc5_rendezvous, pagmo::problem::gtoc5_self_flyby, pagmo::problem::lavor_maculan, pagmo::problem::normalized, pagmo::problem::scaled, pagmo::problem::tens_comp_string, and pagmo::problem::welded_beam.

bool pagmo::problem::base::compare_constraints ( const constraint_vector c1,
const constraint_vector c2 
) const

Compare constraint vectors.

This function will perform safety checks on c1 and c2 and will then call compare_constraints_impl().

Parameters
[in]c1first pagmo::constraint_vector to compare.
[in]c2second pagmo::constraint_vector to compare.
Returns
true if c1 is a better constraint vector than c2, false otherwise.

Definition at line 1005 of file problem/base.cpp.

bool pagmo::problem::base::compare_constraints_impl ( const constraint_vector c1,
const constraint_vector c2 
) const
protectedvirtual

Implementation of constraint vector comparison.

Return true if c1 is a strictly better constraint vector than c2, false otherwise. Default implementation will return true under the following conditions, tested in order:

  • c1 satisfies more constraints than c2,
  • c1 and c2 satisfy the same number of constraints and the L2 norm of the constraint mismatches for c1 is smaller than for c2.

Otherwise, false will be returned.

Parameters
[in]c1first pagmo::constraint_vector to compare.
[in]c2second pagmo::constraint_vector to compare.
Returns
true if c1 is a better constraint vector than c2, false otherwise.

Reimplemented in pagmo::problem::base_meta.

Definition at line 1027 of file problem/base.cpp.

bool pagmo::problem::base::compare_fc ( const fitness_vector f1,
const constraint_vector c1,
const fitness_vector f2,
const constraint_vector c2 
) const

Simultaneous fitness-constraint comparison.

This function will perform sanity checks on the input arguments and will then call compare_fc_impl() if the constraint dimensions is not null, compare_fitness_impl() otherwise.

Parameters
[in]f1first pagmo::fitness_vector.
[in]c1first pagmo::constraint_vector.
[in]f2second pagmo::fitness_vector.
[in]c2second pagmo::constraint_vector.
Returns
result of compare_fc_impl() or compare_fitness_impl().

Definition at line 787 of file problem/base.cpp.

bool pagmo::problem::base::compare_fc_impl ( const fitness_vector f1,
const constraint_vector c1,
const fitness_vector f2,
const constraint_vector c2 
) const
protectedvirtual

Implementation of simultaneous fitness-constraint comparison.

This function combines the information of two fitness/constraint vector pairs in order to establish which of the two pairs if strictly better than the other. Return value will be true if the first pair is strictly better than the second pair, false otherwise.

Default implementation will return true if one of these conditions, tested in this order, holds:

  • c1 is feasible, c2 is not;
  • both c1 and c2 are not feasible and compare_constraints_impl(c1,c2) returns true;
  • both c1 and c2 are feasible and compare_fitness_impl(f1,f2) returns true.

Otherwise, false will be returned.

Parameters
[in]f1first pagmo::fitness_vector.
[in]c1first pagmo::constraint_vector.
[in]f2second pagmo::fitness_vector.
[in]c2second pagmo::constraint_vector.
Returns
true if first fitness/constraint vector pair is strictly better than the second one, false otherwise.

Reimplemented in pagmo::problem::base_meta.

Definition at line 821 of file problem/base.cpp.

bool pagmo::problem::base::compare_fitness ( const fitness_vector v_f1,
const fitness_vector v_f2 
) const

Compare fitness vectors.

Will perform sanity checks on v_f1 and v_f2 and then will call base::compare_fitness_impl().

Parameters
[in]v_f1first fitness vector.
[in]v_f2second fitness vector.
Returns
compare_fitness_impl(v_f1,v_f2);

Definition at line 619 of file problem/base.cpp.

bool pagmo::problem::base::compare_fitness_impl ( const fitness_vector v_f1,
const fitness_vector v_f2 
) const
protectedvirtual

Implementation of fitness vectors comparison.

Return true if v_f1 Pareto dominate v_f2, false otherwise. This default implementation will assume minimisation for each one of the v_f components I.e., each pair of corresponding elements in v_f1 and v_f2 is compared: if all elements in v_f1 are less or equal to the corresponding element in v_f2, true will be returned. Otherwise, false will be returned.

Parameters
[in]v_f1first fitness vector.
[in]v_f2second fitness vector.
Returns
true if v_f1 is dominating v_f2, false otherwise.

Reimplemented in pagmo::problem::antibodies_problem, and pagmo::problem::base_meta.

Definition at line 639 of file problem/base.cpp.

bool pagmo::problem::base::compare_x ( const decision_vector x1,
const decision_vector x2 
) const

Compare decision vectors.

This functions returns true if x1 is a better decision_vector than x2, false otherwise. This function will compute the fitness vectors and constraint vectors associated to x1 and x2 via objfun() and compute_constraints(), and will feed them to compare_fc(), whose result will be returned.

Parameters
[in]x1first pagmo::decision_vector.
[in]x2second pagmo::decision_vector.
Returns
true if x1 is better than x2, false otherwise.

Definition at line 759 of file problem/base.cpp.

constraint_vector pagmo::problem::base::compute_constraints ( const decision_vector x) const

Compute constraints and return constraint vector.

Equivalent to:

constraint_vector c(get_c_dimension());
compute_constraints(c,x);
return c;
Parameters
[in]xpagmo::decision_vector whose constraints will be computed.
Returns
x's constraint vector.

Definition at line 932 of file problem/base.cpp.

void pagmo::problem::base::compute_constraints ( constraint_vector c,
const decision_vector x 
) const

Compute constraints and write them into contraint vector.

This function will perform sanity checks on c and x and will then call compute_constraints_impl().

The implementation internally uses a caching mechanism, so that recently-computed quantities are remembered and re-used when appropriate.

Parameters
[out]cpagmo::constraint_vector into which the constraints will be written.
[in]xpagmo::decision_vector whose constraints will be computed.

Definition at line 874 of file problem/base.cpp.

void pagmo::problem::base::compute_constraints_impl ( constraint_vector c,
const decision_vector x 
) const
protectedvirtual

Implementation of constraint computation.

This functions is intended to write to c the constraint vector of input decision vector x. The first get_c_dimension() - get_ic_dimension() elements of c will hold the equality constraints: if a constraint is satisfied, the corresponding value in the vector will be zero. The remaining elements of the vector will hold the inequality constraints: if a constraint is satisfied, the corresponding value in the vector will be non-positive.

Default implementation will fill c with zeroes.

Parameters
[out]cpagmo::constraint_vector into which the constraints will be written.
[in]xpagmo::decision_vector whose constraints will be computed.

Reimplemented in pagmo::problem::noisy, pagmo::problem::robust, pagmo::problem::mga_incipit_cstrs, pagmo::problem::gtoc_2, pagmo::problem::snopt_toyprob, pagmo::problem::golomb_ruler, pagmo::problem::gtoc5_launch, pagmo::problem::rotated, pagmo::problem::cec2009, pagmo::problem::gtoc5_flyby, pagmo::problem::shifted, pagmo::problem::scaled, pagmo::problem::cec2006, pagmo::problem::normalized, pagmo::problem::luksan_vlcek_3, pagmo::problem::gtoc5_rendezvous, pagmo::problem::gtoc5_self_flyby, pagmo::problem::pressure_vessel, pagmo::problem::earth_planet, pagmo::problem::luksan_vlcek_1, pagmo::problem::luksan_vlcek_2, pagmo::problem::tens_comp_string, and pagmo::problem::welded_beam.

Definition at line 859 of file problem/base.cpp.

bool pagmo::problem::base::equality_operator_extra ( const base p) const
protectedvirtual

Extra requirements for equality.

Additional problem-specific equality testing. Default implementation returns true.

Parameters
[in]pproblem::base to which this will be compared.
Returns
true if p satisfies the additional equality testing, false otherwise.

Reimplemented in pagmo::problem::golomb_ruler.

Definition at line 1077 of file problem/base.cpp.

void pagmo::problem::base::estimate_sparsity ( const decision_vector x0,
int &  lenG,
std::vector< int > &  iGfun,
std::vector< int > &  jGvar 
) const
protected

Heuristics to estimate the sparsity pattern of the problem.

An alternative to reimplementing the base::set_pattern() method, one could let pagmo estimate the sparsity structure of a given problem. The numerical procedure starts from a point $ \mathbf x_0 $ provided by the user and perturbs $ x_j $ locally as to detect a change in $ F_i $ in which case sets (i,j) as a non zero element. You should use this procedure with caution, it is always better to manually code the sparsity pattern in set_pattern(). The procedure costs function evaluations and is not guaranteed to give a correct result if not locally around the provided point. Some constraint may be independent of $ x_j $ near $ x_{0_j}$ but not globally, for such a discontinuous problem estimate_pattern would provide a false gradient information The function intended use is in the reimplementation of set_sparsity, thuse its protected attribute

Definition at line 1237 of file problem/base.cpp.

void pagmo::problem::base::estimate_sparsity ( int &  lenG,
std::vector< int > &  iGfun,
std::vector< int > &  jGvar 
) const
protected

Heuristics to estimate the sparsity pattern of the problem.

An alternative to reimplementing the base::set_pattern() method, one can let pagmo estimate the sparsity structure of a given problem. This numerical procedure starts from a random point $ \mathbf x_0 $ provided by the user and perturbs $ x_j $ globally within the bounds as to detect a change in $ F_i $ in which case sets(i,j) as a non zero element. You should use this procedure with caution, it is always better to manually code the sparsity pattern in set_pattern(). The procedure costs function evaluations and is not guaranteed to give a correct result. The function intended use is in the reimplementation of set_sparsity, thuse its protected attribute

Definition at line 1283 of file problem/base.cpp.

bool pagmo::problem::base::feasibility_c ( const constraint_vector c) const

Test feasibility of constraint vector.

This method will return true if all constraints are satisfied, false otherwise.

Parameters
[in]cpagmo::constraint_vector to be tested.
Returns
true if c satisfies the constraints, false otherwise.

Definition at line 982 of file problem/base.cpp.

bool pagmo::problem::base::feasibility_x ( const decision_vector x) const

Test feasibility of decision vector.

This method will compute the constraint vector associated to x and test it with feasibility_c().

Parameters
[in]xpagmo::decision_vector whose feasibility will be tested.
Returns
true if x satisfies the constraints, false otherwise.

Definition at line 947 of file problem/base.cpp.

const std::vector< constraint_vector > & pagmo::problem::base::get_best_c ( void  ) const

Get the best known constraint vector.

Returns
the best known constraint vector for the problem.

Definition at line 1357 of file problem/base.cpp.

const std::vector< fitness_vector > & pagmo::problem::base::get_best_f ( void  ) const

Get the best known fitness vector.

Returns
the best known fitness vector for the problem.

Definition at line 1377 of file problem/base.cpp.

const std::vector< decision_vector > & pagmo::problem::base::get_best_x ( void  ) const

Get the best known decision vector.

Returns
the best known decision vector for the problem.

Definition at line 1367 of file problem/base.cpp.

base::c_size_type pagmo::problem::base::get_c_dimension ( ) const

Return global constraints dimension.

Returns
global constraints dimension of the problem.

Definition at line 492 of file problem/base.cpp.

const std::vector< double > & pagmo::problem::base::get_c_tol ( ) const

Return constraints tolerance.

Returns
tolerance used in constraints analysis.

Definition at line 510 of file problem/base.cpp.

unsigned int pagmo::problem::base::get_cevals ( ) const

Return number of constraints function evaluations.

Returns
number of constraints function evaluations.

Definition at line 455 of file problem/base.cpp.

double pagmo::problem::base::get_diameter ( ) const

Get the diameter of the problem.

Calculate and return the space diagonal of the hyperrectangle defined by the bounds of the problem.

Returns
the diameter of the problem.

Definition at line 521 of file problem/base.cpp.

base::size_type pagmo::problem::base::get_dimension ( ) const

Return global dimension.

Returns
global dimension of the problem.

Definition at line 465 of file problem/base.cpp.

base::f_size_type pagmo::problem::base::get_f_dimension ( ) const

Return fitness dimension.

Returns
fitness dimension of the problem.

Definition at line 483 of file problem/base.cpp.

unsigned int pagmo::problem::base::get_fevals ( ) const

Return number of function evaluations.

Returns
number of function evaluations.

Definition at line 446 of file problem/base.cpp.

base::size_type pagmo::problem::base::get_i_dimension ( ) const

Return integer dimension.

Returns
dimension of the combinatorial part of the problem.

Definition at line 474 of file problem/base.cpp.

base::c_size_type pagmo::problem::base::get_ic_dimension ( ) const

Return inequality constraints dimension.

Returns
inequality constraints dimension of the problem.

Definition at line 501 of file problem/base.cpp.

const decision_vector & pagmo::problem::base::get_lb ( ) const

Lower bounds getter.

Returns
const reference to the lower bounds vector.

Definition at line 266 of file problem/base.cpp.

std::string pagmo::problem::base::get_name ( ) const
virtual

Get problem's name.

Default implementation will return the problem's mangled C++ name.

Returns
name of the problem.

Reimplemented in pagmo::problem::zdt, pagmo::problem::spheres, pagmo::problem::tandem, pagmo::problem::tsp_ds, pagmo::problem::con2mo, pagmo::problem::dtlz, pagmo::problem::inventory, pagmo::problem::decompose, pagmo::problem::mga_1dsm_alpha, pagmo::problem::tsp_cs, pagmo::problem::branin, pagmo::problem::noisy, pagmo::problem::mga_1dsm_tof, pagmo::problem::laplace, pagmo::problem::mga_target_event, pagmo::problem::pol, pagmo::problem::antibodies_problem, pagmo::problem::death_penalty, pagmo::problem::bukin, pagmo::problem::mga_incipit_cstrs, pagmo::problem::robust, pagmo::problem::mga_part, pagmo::problem::tsp, pagmo::problem::con2uncon, pagmo::problem::gtoc_2, pagmo::problem::snopt_toyprob, pagmo::problem::tsp_vrplc, pagmo::problem::golomb_ruler, pagmo::problem::levy5, pagmo::problem::cassini_1, pagmo::problem::himmelblau, pagmo::problem::mga_incipit, pagmo::problem::cec2013, pagmo::problem::cec2009, pagmo::problem::dejong, pagmo::problem::gtoc5_launch, pagmo::problem::messenger, pagmo::problem::messenger_full, pagmo::problem::schwefel, pagmo::problem::fon, pagmo::problem::griewank, pagmo::problem::gtoc5_flyby, pagmo::problem::gtoc_1, pagmo::problem::kur, pagmo::problem::michalewicz, pagmo::problem::rastrigin, pagmo::problem::rosenbrock, pagmo::problem::sagas, pagmo::problem::sample_return, pagmo::problem::sch, pagmo::problem::ackley, pagmo::problem::rosetta, pagmo::problem::cassini_2, pagmo::problem::lennard_jones, pagmo::problem::rotated, pagmo::problem::cec2006, pagmo::problem::identity, pagmo::problem::luksan_vlcek_3, pagmo::problem::shifted, pagmo::problem::string_match, pagmo::problem::earth_planet, pagmo::problem::luksan_vlcek_1, pagmo::problem::luksan_vlcek_2, pagmo::problem::pressure_vessel, pagmo::problem::gtoc5_rendezvous, pagmo::problem::gtoc5_self_flyby, pagmo::problem::lavor_maculan, pagmo::problem::normalized, pagmo::problem::scaled, pagmo::problem::tens_comp_string, and pagmo::problem::welded_beam.

Definition at line 257 of file problem/base.cpp.

const decision_vector & pagmo::problem::base::get_ub ( ) const

Upper bounds getter.

Returns
const reference to the upper bounds vector.

Definition at line 275 of file problem/base.cpp.

std::string pagmo::problem::base::human_readable ( ) const

Return human readable representation of the problem.

Will return a formatted string containing:

  • problem's name from get_name(),
  • dimensions,
  • lower and upper bounds.

The output of human_readable_extra() will be appended at the end of the string.

Returns
std::string containing a human-readable representation of the problem.

Definition at line 665 of file problem/base.cpp.

std::string pagmo::problem::base::human_readable_extra ( ) const
virtual
bool pagmo::problem::base::is_compatible ( const base p) const

Compatibility operator.

The concept of compatibility is used within the archipelago class: all islands must contain mutually-compatible problems. The rationale behind this method is that migration between islands is allowed only if the problems are compatible. Compatibility differs from equality in the sense that two problems might describe logically the same problem with different parameters. E.g., the optimisation of a neurocontroller driving a rover in related but different environments (different gravity, different terrain, etc.). When migration occurs between islands whose problem are not equal (i.e., identical), the incoming decision vector will be re-evaluated before being compared to the existing population.

The following conditions will be tested, in order:

  • problems are of the same type,
  • problems have the same global, integer and constraints dimension.

If any of the conditions above is false, then the return value will also be false. Otherwise return value will be true.

Parameters
[in]pproblem::base to which this will be compared.
Returns
true if this is compatible with p, false otherwise.

Definition at line 734 of file problem/base.cpp.

fitness_vector pagmo::problem::base::objfun ( const decision_vector x) const

Return fitness of pagmo::decision_vector.

Equivalent to:

fitness_vector f(get_f_dimension());
objfun(f,x);
return f;
Parameters
[in]xdecision vector whose fitness will be calculated.
Returns
fitness vector of x.
Exceptions
value_errorif the chromosome dimension does not match with the problem dimension

Definition at line 544 of file problem/base.cpp.

void pagmo::problem::base::objfun ( fitness_vector f,
const decision_vector x 
) const

Write fitness of pagmo::decision_vector into pagmo::fitness_vector.

Will call objfun_impl() internally. The implementation internally uses a caching mechanism, so that recently-computed quantities are remembered and re-used when appropriate.

Parameters
[out]ffitness vector to which x's fitness will be written.
[in]xdecision vector whose fitness will be calculated.
Exceptions
value_errorif f's and/or x's dimensions are different from the corresponding dimensions of the problem.

Definition at line 564 of file problem/base.cpp.

virtual void pagmo::problem::base::objfun_impl ( fitness_vector f,
const decision_vector x 
) const
protectedpure virtual

Objective function implementation.

Takes a pagmo::decision_vector x as input and writes its pagmo::fitness_vector to f. This function is not to be called directly, it is invoked by objfun() after a series of safety checks is performed on x and f.

Parameters
[out]ffitness vector into which x's fitness will be written.
[in]xdecision vector whose fitness will be calculated.

Implemented in pagmo::problem::zdt, pagmo::problem::spheres, pagmo::problem::spheres_q, pagmo::problem::con2mo, pagmo::problem::decompose, pagmo::problem::tandem, pagmo::problem::dtlz, pagmo::problem::inventory, pagmo::problem::mga_1dsm_alpha, pagmo::problem::noisy, pagmo::problem::mga_1dsm_tof, pagmo::problem::branin, pagmo::problem::mga_part, pagmo::problem::laplace, pagmo::problem::antibodies_problem, pagmo::problem::mga_target_event, pagmo::problem::cec2013, pagmo::problem::robust, pagmo::problem::death_penalty, pagmo::problem::mga_incipit_cstrs, pagmo::problem::pol, pagmo::problem::bukin, pagmo::problem::con2uncon, pagmo::problem::mga_incipit, pagmo::problem::gtoc_2, pagmo::problem::snopt_toyprob, pagmo::problem::golomb_ruler, pagmo::problem::levy5, pagmo::problem::cassini_1, pagmo::problem::gtoc5_launch, pagmo::problem::himmelblau, pagmo::problem::rotated, pagmo::problem::cec2009, pagmo::problem::gtoc5_flyby, pagmo::problem::shifted, pagmo::problem::dejong, pagmo::problem::messenger, pagmo::problem::messenger_full, pagmo::problem::schwefel, pagmo::util::racing::metrics_algos::standard, pagmo::problem::fon, pagmo::problem::griewank, pagmo::problem::gtoc_1, pagmo::problem::kur, pagmo::problem::michalewicz, pagmo::problem::rastrigin, pagmo::problem::rosenbrock, pagmo::problem::sagas, pagmo::problem::sample_return, pagmo::problem::sch, pagmo::problem::ackley, pagmo::problem::rosetta, pagmo::problem::scaled, pagmo::problem::cassini_2, pagmo::problem::cec2006, pagmo::problem::lennard_jones, pagmo::problem::normalized, pagmo::problem::identity, pagmo::problem::luksan_vlcek_3, pagmo::problem::string_match, pagmo::problem::gtoc5_rendezvous, pagmo::problem::gtoc5_self_flyby, pagmo::problem::pressure_vessel, pagmo::problem::earth_planet, pagmo::problem::luksan_vlcek_1, pagmo::problem::luksan_vlcek_2, pagmo::problem::lavor_maculan, pagmo::problem::tens_comp_string, and pagmo::problem::welded_beam.

bool pagmo::problem::base::operator!= ( const base p) const

Inequality operator.

Equivalent to the negation of equality operator.

Parameters
[in]pproblem::base to which this will be compared.
Returns
!(*this == p).

Definition at line 1091 of file problem/base.cpp.

bool pagmo::problem::base::operator== ( const base p) const

Equality operator.

The following conditions will be tested, in order:

If any of the conditions above is false, then the return value will also be false. Otherwise return value will be true.

Parameters
[in]pproblem::base to which this will be compared.
Returns
true if this is equal to p, false otherwise.

Definition at line 708 of file problem/base.cpp.

void pagmo::problem::base::post_evolution ( population pop) const
virtual

Post-evolution hook.

This method will be called by the island objects after every optimisation run, and can be used to alter the island's population after evolution took place. Default implementation will do nothing.

Parameters
[in,out]poppagmo::population belonging to the island calling this method.

Definition at line 1401 of file problem/base.cpp.

void pagmo::problem::base::pre_evolution ( population pop) const
virtual

Pre-evolution hook.

This method will be called by the island objects before every optimisation run, and can be used to alter the island's population before evolution takes place. Default implementation will do nothing.

Parameters
[in,out]poppagmo::population belonging to the island calling this method.

Definition at line 1389 of file problem/base.cpp.

void pagmo::problem::base::reset_caches ( ) const

Reset internal caches.

This method will reset the internal caches used when (re)evaluating decision vectors for fitnesses and/or constraints. It should be called whenever a modification to the internal state of the problem makes the cached values invalid (e.g., changing the seed in a stochastic optimization problem might change the way decision vectors are evaluated, thus rendering invalid previously-calculated values).

Definition at line 1413 of file problem/base.cpp.

void pagmo::problem::base::set_best_x ( const std::vector< decision_vector > &  best_x)

Sets the best known decision vectors.

This method is used to set the best know decision vectors members.

Parameters
[in]best_xbest known pagmo::decision_vector for the problem

Definition at line 1329 of file problem/base.cpp.

void pagmo::problem::base::set_bounds ( const decision_vector lb,
const decision_vector ub 
)

Bounds setter from pagmo::decision_vector.

Set lower/upper bounds to lb/ub. Will fail if lb and ub sizes do not match, if their sizes are different from the global size of the problem or if at least one lower bound is greater than the corresponding upper bound.

Parameters
[in]lblower bounds.
[in]ubupper bounds.

Definition at line 288 of file problem/base.cpp.

template<class Iterator1 , class Iterator2 >
void pagmo::problem::base::set_bounds ( Iterator1  start1,
Iterator1  end1,
Iterator2  start2,
Iterator2  end2 
)
inline

Bounds setter from iterators.

Set lower and upper bounds to the content of the ranges [start1,end1[ and [start2,end2[. Will fail if ranges sizes do not match, if ranges sizes are different from the global size of the problem or if at least one lower bound is greater than the corresponding upper bound.

Parameters
[in]start1iterator to the beginning of the lower bounds sequence.
[in]end1iterator to the end of the lower bounds sequence.
[in]start2iterator to the beginning of the upper bounds sequence.
[in]end2iterator to the end of the upper bounds sequence.

Definition at line 284 of file problem/base.h.

template<std::size_t N>
void pagmo::problem::base::set_bounds ( const double(&)  v1[N],
const double(&)  v2[N] 
)
inline

Bounds setter from raw arrays.

Set lower and upper bounds to the content of the raw arrays v1 and v2. Will fail if N is different from the global size of the problem or if at least one lower bound is greater than the corresponding upper bound.

Parameters
[in]v1lower bounds for the problem.
[in]v2upper bounds for the problem.

Definition at line 308 of file problem/base.h.

void pagmo::problem::base::set_bounds ( const double &  l_value,
const double &  u_value 
)

Set bounds to specified values.

Set all lower bounds to l_value and all upper bounds to u_value. Will fail if l_value > u_value.

Parameters
[in]l_valuevalue for all lower bounds.
[in]u_valuevalue for all upper bounds.

Definition at line 307 of file problem/base.cpp.

void pagmo::problem::base::set_bounds ( int  n,
const double &  l_value,
const double &  u_value 
)

Set bounds to specified values.

Set i-th lower bound to l_value and i-th upper bound to u_value. Will fail if l_value > u_value.

Parameters
[in]nindex of the lower bound to be set.
[in]l_valuevalue for lower bounds.
[in]u_valuevalue for upper bounds.

Definition at line 325 of file problem/base.cpp.

void pagmo::problem::base::set_lb ( const decision_vector lb)

Set lower bounds from pagmo::decision_vector.

Will fail if lb's size is different from the global size or if at least one lower bound is greater than the corresponding upper bound.

Parameters
[in]lblower bounds.

Definition at line 342 of file problem/base.cpp.

void pagmo::problem::base::set_lb ( int  n,
const double &  value 
)

Set specific lower bound to value.

Will fail if n overflows global dimension or if value is greater than the corresponding upper bound.

Parameters
[in]nindex of the lower bound to be set.
[in]valuevalue the specified lower bound will be set to.

Definition at line 360 of file problem/base.cpp.

void pagmo::problem::base::set_lb ( const double &  value)

Set all lower bounds to value.

Will fail if value is greater than at least one upper bound.

Parameters
[in]valuevalue to which the lower bounds will be set.

Definition at line 377 of file problem/base.cpp.

template<class Iterator >
void pagmo::problem::base::set_lb ( Iterator  start,
Iterator  end 
)
inline

Lower bounds setter from iterators.

Will fail if the iterator distance is different from global problem dimension or if at least one lower bound is greater than the corresponding upper bound.

Parameters
[in]startiterator to the beginning of the lower bounds sequence.
[in]enditerator to the end of the lower bounds sequence.

Definition at line 333 of file problem/base.h.

template<std::size_t N>
void pagmo::problem::base::set_lb ( const double(&)  v[N])
inline

Lower bounds setter from raw array.

Will fail if N is different from global problem dimension or if at least one lower bound is greater than the corresponding upper bound.

Parameters
[in]vlower bounds array.

Definition at line 351 of file problem/base.h.

void pagmo::problem::base::set_sparsity ( int &  lenG,
std::vector< int > &  iGfun,
std::vector< int > &  jGvar 
) const
virtual

Sets the sparsity pattern of the gradient.

Some solvers can make use of the sparsity of the gradient matrix $ \mathbf G $. This is a matrix defined as $ \mathbf G_{ij} = \frac{\partial F_i}{\partial x_j}$ where $ \mathbf F = [fit_1,\ldots,fit_{nfit}, ceq_1,\ldots,ceq_{neq}, cineq_1,\ldots, cineq_{nineq}] $ and $ \mathbf x $ is the decision vector. Such a pattern is there to define the non zero entries of $ \mathbf G $ so that when evaluating numerical derivatives these are the only entries considered.

This function might be used by specific solvers in order to speed-up the computation of numerical derivatives. Please refer to the solver-specific documentation in order to see if and how this method is used.

The reimplementation may call estimate_sparsity() to obtain a numerical estimate for the sparsity pattern (CAUTION: this is not guaranteed to be always correct).

The matrix $ \mathbf G $ needs to be represented as a sparse matrix so that if $ G_{ij} \neq 0 $ iGfun[l] = i, jGvar[l] = j.

Reimplemented in pagmo::problem::tandem, pagmo::problem::snopt_toyprob, pagmo::problem::gtoc5_launch, pagmo::problem::gtoc5_flyby, pagmo::problem::messenger, pagmo::problem::messenger_full, pagmo::problem::sagas, pagmo::problem::sample_return, pagmo::problem::rosetta, pagmo::problem::cassini_2, pagmo::problem::luksan_vlcek_3, pagmo::problem::gtoc5_rendezvous, pagmo::problem::gtoc5_self_flyby, pagmo::problem::earth_planet, pagmo::problem::luksan_vlcek_1, and pagmo::problem::luksan_vlcek_2.

Definition at line 1217 of file problem/base.cpp.

void pagmo::problem::base::set_ub ( const decision_vector ub)

Set upper bounds from pagmo::decision_vector.

Will fail if ub's size is different from the global size or if at least one upper bound is less than the corresponding lower bound.

Parameters
[in]ubupper bounds.

Definition at line 395 of file problem/base.cpp.

void pagmo::problem::base::set_ub ( int  n,
const double &  value 
)

Set specific upper bound to value.

Will fail if n overflows global dimension or if value is less than the corresponding lower bound.

Parameters
[in]nindex of the upper bound to be set.
[in]valuevalue the specified upper bound will be set to.

Definition at line 413 of file problem/base.cpp.

void pagmo::problem::base::set_ub ( const double &  value)

Set all upper bounds to value.

Will fail if value is less than at least one lower bound.

Parameters
[in]valuevalue to which the upper bounds will be set.

Definition at line 430 of file problem/base.cpp.

template<class Iterator >
void pagmo::problem::base::set_ub ( Iterator  start,
Iterator  end 
)
inline

Upper bounds setter from iterators.

Will fail if the iterator distance is different from global problem dimension or if at least one upper bound is less than the corresponding lower bound.

Parameters
[in]startiterator to the beginning of the upper bounds sequence.
[in]enditerator to the end of the upper bounds sequence.

Definition at line 373 of file problem/base.h.

template<std::size_t N>
void pagmo::problem::base::set_ub ( const double(&)  v[N])
inline

Upper bounds setter from raw array.

Will fail if N is different from global problem dimension or if at least one upper bound is less than the corresponding lower bound.

Parameters
[in]vupper bounds array.

Definition at line 391 of file problem/base.h.

bool pagmo::problem::base::test_constraint ( const constraint_vector c,
const c_size_type i 
) const

Test i-th constraint of c (using tolerance information).

This method will return true if the i-th constraint is satisfied, false otherwise.

Parameters
[in]cpagmo::constraint_vector to be tested.
[in]ipagmo::constraint_vector index.
Returns
true if the i-th constraint is satisfied (up to the numeric tolerance m_c_tol[i]), false otherwise.

Definition at line 963 of file problem/base.cpp.

bool pagmo::problem::base::verify_x ( const decision_vector x) const

Verify compatibility of decision vector x with problem.

Will return false if any of these conditions, checked in this order, holds:

  • x's dimension is different from get_dimension(),
  • at least one value of x is outside the bounds of the problem,
  • at least one element of the integer part of x is not an integer.

Otherwise, true will be returned.

Parameters
[in]xpagmo::decision_vector to be tested.
Returns
true if x is compatible with the problem, false otherwise.

Definition at line 1109 of file problem/base.cpp.


The documentation for this class was generated from the following files: