roboptim::GenericSolver Class Referenceabstract
Optimization solvers

Abstract interface satisfied by all solvers. More...

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

Inheritance diagram for roboptim::GenericSolver:

## Public Types

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

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...
virtual std::ostream & | print (std::ostream &) const throw ()
| Display the solver on the specified output stream. More...
solutions | minimumType () throw ()
| Determine real minimum type. More...
template<typename T >
const T & | getMinimum () throw (boost::bad_get)
| Get real result. More...
Constructors and destructors.
| GenericSolver () throw ()
| GenericSolver (const GenericSolver &) throw ()
virtual | ~GenericSolver () throw ()

## Protected Attributes

result_t | result_
| /brief Optimization result. More...

## Static Protected Attributes

static log4cxx::LoggerPtr | logger
| Pointer to function logger (see log4cxx documentation). More...

## Detailed Description

Abstract interface satisfied by all solvers.

## Member Typedef Documentation

typedef boost::variant<NoSolution, Result, ResultWithWarnings, SolverError> 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),
- result and warnings (problem solved but some errors happened),
- solver error (optimization has failed).

typedef Function::vector_t roboptim::GenericSolver::vector_t

Vector type imported from function class.

## Constructor & Destructor Documentation

roboptim::GenericSolver::GenericSolver | ( |  | ) |
throw | ( |
| ) |  |

explicit

roboptim::GenericSolver::GenericSolver | ( | const GenericSolver & | solver | ) |
throw | ( |
| ) |  |

explicit

roboptim::GenericSolver::~GenericSolver | ( |  | ) |
throw | ( |
| ) |  |

virtual

## Member Function Documentation

template<typename T >

const T& roboptim::GenericSolver::getMinimum | ( |  | ) |
throw | ( | boost::bad_get
| ) |  |

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

const GenericSolver::result_t & roboptim::GenericSolver::minimum | ( |  | ) |
throw | ( |
| ) |  |

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 | ( |  | ) |
throw | ( |
| ) |  |

inline

Determine real minimum type.

Returns
  value representing result type

std::ostream & roboptim::GenericSolver::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 in roboptim::Solver< F, C >, and roboptim::Solver< Function, boost::mpl::vector< Function > >.

Referenced by roboptim::operator<<().

void roboptim::GenericSolver::reset | ( |  | ) |
throw | ( |
| ) |  |

Force to restart the optimization.

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

References logger, and result_.

virtual void roboptim::GenericSolver::solve | ( |  | ) |
throw | ( |
| ) |  |

pure virtual

Solve the problem.

Called automatically by getMinimum if required.

Implemented in roboptim::DummySolverLastState, and roboptim::DummySolver.

Referenced by minimum().

## Member Data Documentation

log4cxx::LoggerPtr roboptim::GenericSolver::logger

static protected

Pointer to function logger (see log4cxx documentation).

Referenced by reset().

result_t roboptim::GenericSolver::result_

protected

/brief Optimization result.

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