All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
roboptim::GenericSolver Class Referenceabstract

Abstract interface satisfied by all solvers. More...

#include <roboptim/core/generic-solver.hh>

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

Public Types

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

void reset ()
 Force to restart the optimization. More...
 
virtual void solve ()=0
 Solve the problem. More...
 
const result_tminimum ()
 Returns the function minimum. More...
 
virtual std::ostream & print (std::ostream &) const
 Display the solver on the specified output stream. More...
 
solutions minimumType ()
 Determine real minimum type. More...
 
template<typename T >
const T & getMinimum ()
 Get real result. More...
 
Constructors and destructors.
 GenericSolver ()
 
 GenericSolver (const GenericSolver &)
 
virtual ~GenericSolver ()
 

Public Attributes

ROBOPTIM_ALLOW_DEPRECATED_ON
typedef boost::variant
< NoSolution, Result,
SolverError,
ResultWithWarnings
result_t
 Result type. More...
 

Protected Attributes

result_t result_
 Optimization result. More...
 

Detailed Description

Abstract interface satisfied by all solvers.

Member Enumeration Documentation

Define the kind of solution which has been found.

Enumerator
SOLVER_NO_SOLUTION 

Solution has yet to be found.

SOLVER_VALUE 

Solution has been found.

SOLVER_ERROR 

The solver failed to find a solution.

SOLVER_VALUE_WARNINGS 

Solution has been found but some problems happened.

Constructor & Destructor Documentation

roboptim::GenericSolver::GenericSolver ( )
explicit
roboptim::GenericSolver::GenericSolver ( const GenericSolver solver)
explicit
roboptim::GenericSolver::~GenericSolver ( )
virtual

Member Function Documentation

template<typename T >
const T& roboptim::GenericSolver::getMinimum ( )
inline

Get real result.

Optimization results is wrapped in a Boost.Variant class, this method has to be used to retrieve the real result type.

Returns
real result
Exceptions
boost::bad_getif a wrong type is used.
const GenericSolver::result_t & roboptim::GenericSolver::minimum ( )

Returns the function minimum.

This solves the problem automatically, if it has not yet been solved.

See Also
minimumType()
getMinimum()

References result_, solve(), and SOLVER_NO_SOLUTION.

solutions roboptim::GenericSolver::minimumType ( )
inline

Determine real minimum type.

Returns
value representing result type
std::ostream & roboptim::GenericSolver::print ( std::ostream &  o) const
virtual

Display the solver on the specified output stream.

Parameters
ooutput stream used for display
Returns
output stream

Reimplemented in roboptim::Solver< T >, and roboptim::Solver< EigenMatrixDense >.

Referenced by roboptim::operator<<().

void roboptim::GenericSolver::reset ( )

Force to restart the optimization.

Reset the internal mechanism to force the solution to be re-computed next time getMinimum() is called.

References result_.

virtual void roboptim::GenericSolver::solve ( )
pure virtual

Solve the problem.

Called automatically by getMinimum() if required.

Implemented in roboptim::GenericDummySolverLastState< T >, roboptim::GenericDummySolver< T >, and roboptim::DummySolverTd.

Referenced by minimum().

Member Data Documentation

result_t roboptim::GenericSolver::result_
protected

Optimization result.

Referenced by minimum(), reset(), and roboptim::DummySolverTd::solve().

ROBOPTIM_ALLOW_DEPRECATED_ON typedef boost::variant<NoSolution, Result, SolverError, ResultWithWarnings> roboptim::GenericSolver::result_t

Result type.

Uses a Boost.Variant to represent the different possible results:

  • no solution (problem not yet solved),
  • result (problem has been solved successfully, possibly with warnings),
  • solver error (optimization has failed). Note: the usage of ResultWithWarnings is deprecated. Use Result directly.