All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
roboptim::Solver< T > Class Template Reference

Solver for a specific problem class. More...

#include <roboptim/core/solver.hh>

Inheritance diagram for roboptim::Solver< T >:
roboptim::GenericSolver roboptim::GenericDummySolver< T > roboptim::GenericDummySolverLastState< T >

Public Types

typedef Problem< T > problem_t
 Solver problem type. More...
 
typedef GenericFunction< T >
::vector_t 
vector_t
 Import vector type from cost function. More...
 
typedef std::map< std::string,
Parameter
parameters_t
 Map of parameters. More...
 
typedef SolverState< problem_tsolverState_t
 State of the solver. More...
 
typedef boost::function< void(const
problem_t &problem,
solverState_t &state)> 
callback_t
 Per-iteration callback type. More...
 
- Public Types inherited from roboptim::GenericSolver
enum  solutions {
  SOLVER_NO_SOLUTION,
  SOLVER_VALUE,
  SOLVER_ERROR,
  SOLVER_VALUE_WARNINGS
}
 Define the kind of solution which has been found. More...
 

Public Member Functions

 Solver (const problem_t &problem)
 Instantiate a solver from a problem. More...
 
virtual ~Solver ()
 
const problem_tproblem () const
 Retrieve the problem. More...
 
virtual void setIterationCallback (callback_t)
 Set the per-iteration callback. More...
 
virtual std::ostream & print (std::ostream &) const
 Display the solver on the specified output stream. More...
 
Parameters
const parameters_tparameters () const
 
parameters_tparameters ()
 
template<typename U >
const U & getParameter (const std::string &key) const
 
Plugin name
const std::string & pluginName () const
 
std::string & pluginName ()
 
- Public Member Functions inherited from roboptim::GenericSolver
void reset ()
 Force to restart the optimization. More...
 
virtual void solve ()=0
 Solve the problem. More...
 
const result_tminimum ()
 Returns the function minimum. More...
 
solutions minimumType ()
 Determine real minimum type. More...
 
template<typename T >
const T & getMinimum ()
 Get real result. More...
 
 GenericSolver ()
 
 GenericSolver (const GenericSolver &)
 
virtual ~GenericSolver ()
 

Protected Attributes

const problem_t problem_
 Problem that will be solved. More...
 
parameters_t parameters_
 Solver parameters (run-time configuration). More...
 
std::string plugin_name_
 Plugin name. More...
 
- Protected Attributes inherited from roboptim::GenericSolver
result_t result_
 Optimization result. More...
 

Additional Inherited Members

- Public Attributes inherited from roboptim::GenericSolver
ROBOPTIM_ALLOW_DEPRECATED_ON
typedef boost::variant
< NoSolution, Result,
SolverError,
ResultWithWarnings
result_t
 Result type. More...
 

Detailed Description

template<typename T>
class roboptim::Solver< T >

Solver for a specific problem class.

This class is parametrized by two types: the cost function type and the constraints type.

Solver classes are immutable, the problem can not be changed after the class instantiation.

Template Parameters
Tmatrix type

Member Typedef Documentation

template<typename T>
typedef boost::function<void (const problem_t& problem, solverState_t& state)> roboptim::Solver< T >::callback_t

Per-iteration callback type.

Callback parameters:

  • problem is a (constant) reference to the problem
  • state is the current state of the optimization solver. It can be modified by the callback, and updated values can be used by the solver to determine what to do next.
template<typename T>
typedef std::map<std::string, Parameter> roboptim::Solver< T >::parameters_t

Map of parameters.

template<typename T>
typedef Problem<T> roboptim::Solver< T >::problem_t

Solver problem type.

The solver can solve problems of this type. If another kind of problem is given, a conversion will be required.

template<typename T>
typedef SolverState<problem_t> roboptim::Solver< T >::solverState_t

State of the solver.

template<typename T>
typedef GenericFunction<T>::vector_t roboptim::Solver< T >::vector_t

Import vector type from cost function.

Constructor & Destructor Documentation

template<typename T >
roboptim::Solver< T >::Solver ( const problem_t problem)
explicit

Instantiate a solver from a problem.

Parameters
problemproblem that should be solved
template<typename T >
roboptim::Solver< T >::~Solver ( )
virtual

Member Function Documentation

template<typename T >
template<typename U >
const U & roboptim::Solver< T >::getParameter ( const std::string &  key) const
template<typename T >
const Solver< T >::parameters_t & roboptim::Solver< T >::parameters ( ) const
template<typename T >
Solver< T >::parameters_t & roboptim::Solver< T >::parameters ( )
template<typename T >
const std::string & roboptim::Solver< T >::pluginName ( ) const
template<typename T >
std::string & roboptim::Solver< T >::pluginName ( )
template<typename T >
std::ostream & roboptim::Solver< T >::print ( std::ostream &  o) const
virtual

Display the solver on the specified output stream.

Parameters
ooutput stream used for display
Returns
output stream

Reimplemented from roboptim::GenericSolver.

References roboptim::decindent(), roboptim::iendl(), roboptim::incindent(), and result_.

template<typename T >
const Solver< T >::problem_t & roboptim::Solver< T >::problem ( ) const

Retrieve the problem.

Returns
problem this solver is solving
template<typename T>
virtual void roboptim::Solver< T >::setIterationCallback ( callback_t  )
inlinevirtual

Set the per-iteration callback.

The per-iteration callback is a callback called each time one iteration of the optimization process is finished.

Not all the solvers support such a callback so this method may throw a std::runtime_error to let you know this feature is unsupported.

Exceptions
std::runtime_error

Reimplemented in roboptim::GenericDummySolverLastState< T >.

Member Data Documentation

template<typename T>
parameters_t roboptim::Solver< T >::parameters_
protected

Solver parameters (run-time configuration).

Referenced by roboptim::GenericDummySolver< T >::GenericDummySolver().

template<typename T>
std::string roboptim::Solver< T >::plugin_name_
protected

Plugin name.

template<typename T>
const problem_t roboptim::Solver< T >::problem_
protected

Problem that will be solved.