Optimization problem. More...
#include <roboptim/core/problem.hh>
Public Types | |
typedef F | function_t |
Function type. | |
typedef boost::make_variant_over < typename detail::add_shared_ptr< CLIST > ::type >::type | constraint_t |
Constraint's type. | |
typedef function_t::value_type | value_type |
typedef std::vector< constraint_t > | constraints_t |
Constraints are represented as a vector of constraints. | |
typedef boost::optional < Function::vector_t > | startingPoint_t |
Optional vector defines a starting point. | |
typedef Function::interval_t | interval_t |
typedef Function::intervals_t | intervals_t |
typedef std::vector< value_type > | scales_t |
Scale vector. |
Public Member Functions | |
std::ostream & | print (std::ostream &o) const throw () |
Display the problem on the specified output stream. | |
Constructors and destructors. | |
Problem (const function_t &) throw () | |
Problem (const Problem< F, CLIST > &) throw () | |
Copy constructor. | |
template<typename F_ , typename CLIST_ > | |
Problem (const Problem< F_, CLIST_ > &) throw () | |
Copy constructor (convert from another class of problem). | |
~Problem () throw () | |
Cost function. | |
const function_t & | function () const throw () |
Retrieve cost function. | |
intervals_t & | argumentBounds () throw () |
Retrieve arguments bounds. Arguments bounds define in which interval each argument is valid. | |
const intervals_t & | argumentBounds () const throw () |
Retrieve arguments bounds. Arguments bounds define in which interval each argument is valid. | |
scales_t & | argumentScales () throw () |
Retrieve arguments scales. Arguments scales define which scale is applied for each argument. | |
const scales_t & | argumentScales () const throw () |
Retrieve arguments scales. Arguments scales define which scale is applied for each argument. | |
Constraints. | |
const constraints_t & | constraints () const throw () |
Retrieve constraints. | |
template<typename C > | |
void | addConstraint (boost::shared_ptr< C > constraint, interval_t interval, value_type scale=1.) throw (std::runtime_error) |
Add a constraint to the problem. | |
const intervals_t & | bounds () const throw () |
Retrieve constraints bounds. | |
const scales_t & | scales () const throw () |
Retrieve constraints scales. | |
Starting point (initial guess). | |
startingPoint_t & | startingPoint () throw () |
Set the initial guess. | |
const startingPoint_t & | startingPoint () const throw () |
Get the initial guess. |
Friends | |
class | Problem |
Optimization problem.
An optimization problem is defined as: - a cost function ( \form#11) - one or more constraints functions, ( \form#8) associated with an interval and a scale, - a set of intervals and scales for arguments. . The goal of the optimization process is finding a point which minimizes the cost function and which respects the constraints (i.e. the result of some functions is inside of specific interval). To use the class, one has to instantiate a problem with a reference to a cost function. Then, constraints can be added through the addConstraint method: a reference to a function and an interval is needed. The cost function is immutable. Constraints are stored as a Boost.Variant of smart pointers (i.e. more precisely using a boost::shared_ptr) representing all the different possibles constraint types. It is recommended to add a constraint using the following syntax: @code
problem.addConstraint<C> (boost::make_shared<MyFunction> (...), ...); where C is the constraint type and MyFunction the function type.
Unlike other classes which just copy functions, pointers are used here in order to allow sub-classes of constraints to be inserted in the problem. For instance, a twice derivable function can be inserted in a problem which expects a derivable function.
F | function type |
CLIST | type list satisfying MPL's sequence concept |
typedef boost::make_variant_over<typename detail::add_shared_ptr<CLIST>::type>::type roboptim::Problem< F, CLIST >::constraint_t |
Constraint's type.
Generate a Boost.Variant of shared pointers tyle from the static constraints types list. For instance, if one instantiates @code
Problem<QuadraticFunction, vector<LinearFunction, QuadraticFunction> > then this type will be set to:
The meta-algorithm which add shared pointers is implemented in detail::add_shared_pointer.
typedef std::vector<constraint_t> roboptim::Problem< F, CLIST >::constraints_t |
Constraints are represented as a vector of constraints.
typedef F roboptim::Problem< F, CLIST >::function_t |
typedef Function::interval_t roboptim::Problem< F, CLIST >::interval_t |
typedef Function::intervals_t roboptim::Problem< F, CLIST >::intervals_t |
typedef std::vector<value_type> roboptim::Problem< F, CLIST >::scales_t |
Scale vector.
typedef boost::optional<Function::vector_t> roboptim::Problem< F, CLIST >::startingPoint_t |
Optional vector defines a starting point.
typedef function_t::value_type roboptim::Problem< F, CLIST >::value_type |
|
explicit |
References roboptim::Function::makeInfiniteInterval().
|
explicit |
Copy constructor.
|
explicit |
Copy constructor (convert from another class of problem).
roboptim::Problem< F, CLIST >::~Problem | ( | ) | throw () |
void roboptim::Problem< F, CLIST >::addConstraint | ( | boost::shared_ptr< C > | constraint, |
interval_t | interval, | ||
value_type | scale = 1. |
||
) | throw (std::runtime_error) |
Add a constraint to the problem.
constraint | the constraint that will be added |
interval | interval in which the constraint is satisfied |
scale | constraint scale |
C | constraint type (has to be in CLIST) |
Problem< F, CLIST >::intervals_t & roboptim::Problem< F, CLIST >::argumentBounds | ( | ) | throw () |
Retrieve arguments bounds. Arguments bounds define in which interval each argument is valid.
const Problem< F, CLIST >::intervals_t & roboptim::Problem< F, CLIST >::argumentBounds | ( | ) | const throw () |
Retrieve arguments bounds. Arguments bounds define in which interval each argument is valid.
Problem< F, CLIST >::scales_t & roboptim::Problem< F, CLIST >::argumentScales | ( | ) | throw () |
Retrieve arguments scales. Arguments scales define which scale is applied for each argument.
const Problem< F, CLIST >::scales_t & roboptim::Problem< F, CLIST >::argumentScales | ( | ) | const throw () |
Retrieve arguments scales. Arguments scales define which scale is applied for each argument.
const Problem< F, CLIST >::intervals_t & roboptim::Problem< F, CLIST >::bounds | ( | ) | const throw () |
Retrieve constraints bounds.
const Problem< F, CLIST >::constraints_t & roboptim::Problem< F, CLIST >::constraints | ( | ) | const throw () |
Retrieve constraints.
const Problem< F, CLIST >::function_t & roboptim::Problem< F, CLIST >::function | ( | ) | const throw () |
Retrieve cost function.
std::ostream & roboptim::Problem< F, CLIST >::print | ( | std::ostream & | o | ) | const throw () |
Display the problem on the specified output stream.
o | output stream used for display |
References roboptim::decindent(), roboptim::iendl(), roboptim::incendl(), and roboptim::Function::infinity().
const Problem< F, CLIST >::scales_t & roboptim::Problem< F, CLIST >::scales | ( | ) | const throw () |
Retrieve constraints scales.
Problem< F, CLIST >::startingPoint_t & roboptim::Problem< F, CLIST >::startingPoint | ( | ) | throw () |
Set the initial guess.
const Problem< F, CLIST >::startingPoint_t & roboptim::Problem< F, CLIST >::startingPoint | ( | ) | const throw () |
Get the initial guess.
|
friend |