All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
roboptim::Solver< F, C > Class Template Reference
Optimization problems

Solver for a specific problem class. More...

`#include <roboptim/core/solver.hh>`

Inheritance diagram for roboptim::Solver< F, C >:

## Public Types

typedef Problem< F, C > | problem_t
| Solver problem type. More...
typedef std::map< std::string, Parameter > | parameters_t
| Map of parameters. More...
Public Types inherited from roboptim::GenericSolver
enum | solutions { SOLVER_NO_SOLUTION, SOLVER_VALUE, SOLVER_VALUE_WARNINGS, SOLVER_ERROR }
| Define the kind of solution which has been found. More...
typedef Function::vector_t | vector_t
| Vector type imported from function class. More...
typedef boost::variant < NoSolution, Result, ResultWithWarnings, SolverError > | result_t
| Result type. More...

## Public Member Functions

| Solver (const problem_t &problem) throw ()
| Instantiate a solver from a problem. More...
template<typename F_ , typename C_ >
| Solver (const Problem< F_, C_ > &problem) throw ()
| Instantiate a solver from a problem in a different problem class. More...
virtual | ~Solver () throw ()
const problem_t & | problem () const throw ()
| Retrieve the problem. More...
virtual std::ostream & | print (std::ostream &) const throw ()
| Display the solver on the specified output stream. More...
Parameters
const parameters_t & | parameters () const throw ()
parameters_t & | parameters () throw ()
template<typename T >
const T & | getParameter (const std::string &key) const
Public Member Functions inherited from roboptim::GenericSolver
void | reset () throw ()
| Force to restart the optimization. More...
virtual void | solve ()=0 throw ()
| Solve the problem. More...
const result_t & | minimum () throw ()
| Returns the function minimum This solves the problem automatically, if it has not yet been solved. More...
solutions | minimumType () throw ()
| Determine real minimum type. More...
template<typename T >
const T & | getMinimum () throw (boost::bad_get)
| Get real result. More...
| GenericSolver () throw ()
| GenericSolver (const GenericSolver &) throw ()
virtual | ~GenericSolver () throw ()

## Protected Attributes

const problem_t | problem_
| Problem that will be solved. More...
parameters_t | parameters_
| Solver parameters (run-time configuration). More...
Protected Attributes inherited from roboptim::GenericSolver
result_t | result_
| /brief Optimization result. More...

## Static Protected Attributes

static log4cxx::LoggerPtr | logger
| Pointer to function logger (see log4cxx documentation). More...
Static Protected Attributes inherited from roboptim::GenericSolver
static log4cxx::LoggerPtr | logger
| Pointer to function logger (see log4cxx documentation). More...

## Detailed Description

### template<typename F, typename C = F>
class roboptim::Solver< F, C >

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

  F | cost function type
  C | constraints functions type

Precondition
  F is a subtype of Function

## Member Typedef Documentation

template<typename F, typename C = F>

typedef std::map<std::string, Parameter> roboptim::Solver< F, C >::parameters_t

Map of parameters.

template<typename F, typename C = F>

typedef Problem<F, C> roboptim::Solver< F, C >::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.

## Constructor & Destructor Documentation

template<typename F , typename C >

roboptim::Solver< F, C >::Solver | ( | const problem_t & | problem | ) |
throw | ( |
| ) |  |

explicit

Instantiate a solver from a problem.

Parameters

  problem | problem that should be solved

template<typename F , typename C >
template<typename F_ , typename C_ >

roboptim::Solver< F, C >::Solver | ( | const Problem< F_, C_ > & | problem | ) |
throw | ( |
| ) |  |

explicit

Instantiate a solver from a problem in a different problem class.

This constructor is called when the problem cost function or/and constraints type does not match solver's types.

This is only possible if the problem provides too much information compared to the solver requirements: if the problem contains twice derivable function and the solver requires only derivable function, it will work however the opposite will fail. Problem compatibility is known at compile-time, so the failure will be at compile-time.

Template Parameters

  F_ | original cost function type
  C_ | original constraints functions type

Parameters

  problem | problem that should be solved

template<typename F , typename C >

roboptim::Solver< F, C >::~Solver | ( |  | ) |
throw | ( |
| ) |  |

virtual

## Member Function Documentation

template<typename F , typename C >
template<typename T >

const T & roboptim::Solver< F, C >::getParameter | ( | const std::string & | key | ) | const

template<typename F , typename C >

const Solver< F, C >::parameters_t & roboptim::Solver< F, C >::parameters | ( |  | ) | const
throw | ( |
| ) |  |

template<typename F , typename C >

Solver< F, C >::parameters_t & roboptim::Solver< F, C >::parameters | ( |  | ) |
throw | ( |
| ) |  |

template<typename F , typename C >

std::ostream & roboptim::Solver< F, C >::print | ( | std::ostream & | o | ) | const
throw | ( |
| ) |  |

virtual

Display the solver on the specified output stream.

Parameters

  o | output stream used for display

Returns
  output stream

Reimplemented from roboptim::GenericSolver.

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

template<typename F , typename C >

const Solver< F, C >::problem_t & roboptim::Solver< F, C >::problem | ( |  | ) | const
throw | ( |
| ) |  |

Retrieve the problem.

Returns
  problem this solver is solving

## Member Data Documentation

template<typename F, typename C = F>

log4cxx::LoggerPtr roboptim::Solver< F, C >::logger

static protected

Pointer to function logger (see log4cxx documentation).

template<typename F, typename C = F>

parameters_t roboptim::Solver< F, C >::parameters_

protected

Solver parameters (run-time configuration).

template<typename F, typename C = F>

const problem_t roboptim::Solver< F, C >::problem_

protected

Problem that will be solved.