roboptim::GenericDummySolverLastState< F > Class Template Reference

Dummy solver which always fails, but returns the last state of the solver. More...

#include <roboptim/core/plugin/dummy-laststate.hh>

Inheritance diagram for roboptim::GenericDummySolverLastState< F >:
roboptim::Solver< F, boost::mpl::vector< F > > roboptim::GenericSolver

Public Types

typedef Solver< F, boost::mpl::vector< F > > parent_t
 Define parent's type. More...
 
typedef parent_t::problem_t problem_t
 Problem type. More...
 
typedef parent_t::callback_t callback_t
 Callback function type. More...
 
typedef SolverState< problem_tsolverState_t
 Type of the state of the solver. More...
 
- Public Types inherited from roboptim::Solver< F, boost::mpl::vector< F > >
typedef Problem< F, boost::mpl::vector< F > > problem_t
 Solver problem type. More...
 
typedef F::vector_t vector_t
 Import vector type from cost function. More...
 
typedef std::map< std::string, Parameterparameters_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_VALUE_WARNINGS,
  SOLVER_ERROR
}
 Define the kind of solution which has been found. More...
 
typedef boost::variant< NoSolution, Result, ResultWithWarnings, SolverErrorresult_t
 Result type. More...
 

Public Member Functions

 GenericDummySolverLastState (const problem_t &problem)
 Build a solver from a problem. More...
 
virtual ~GenericDummySolverLastState ()
 
virtual void solve ()
 Implement the solve algorithm. More...
 
virtual void setIterationCallback (callback_t callback)
 Set the per-iteration callback. More...
 
const callback_tcallback () const
 
- Public Member Functions inherited from roboptim::Solver< F, boost::mpl::vector< F > >
 Solver (const problem_t &problem)
 Instantiate a solver from a problem. More...
 
 Solver (const Problem< F_, C_ > &problem)
 Instantiate a solver from a problem in a different problem class. More...
 
virtual ~Solver ()
 
const problem_tproblem () const
 Retrieve the problem. More...
 
virtual std::ostream & print (std::ostream &) const
 Display the solver on the specified output stream. More...
 
const parameters_tparameters () const
 
parameters_tparameters ()
 
const T & getParameter (const std::string &key) const
 
const std::string & pluginName () const
 
std::string & pluginName ()
 
- Public Member Functions inherited from roboptim::GenericSolver
void reset ()
 Force to restart the optimization. More...
 
const result_tminimum ()
 Returns the function minimum This solves the problem automatically, if it has not yet been solved. More...
 
solutions minimumType ()
 Determine real minimum type. More...
 
template<typename T >
const T & getMinimum ()
 Get real result. More...
 
 GenericSolver ()
 
 GenericSolver (const GenericSolver &)
 
virtual ~GenericSolver ()
 

Public Attributes

callback_t callback_
 Intermediate callback (called at each end of iteration). More...
 
solverState_t solverState_
 Current state of the solver (used by the callback function). More...
 

Additional Inherited Members

- Protected Attributes inherited from roboptim::Solver< F, boost::mpl::vector< F > >
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...
 
- Static Protected Attributes inherited from roboptim::Solver< F, boost::mpl::vector< F > >
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>
class roboptim::GenericDummySolverLastState< F >

Dummy solver which always fails, but returns the last state of the solver.

The SolverError generated contains a dummy state of the solver (x, constraints etc.). These values can be obtained thanks to SolverError::lastState.

This solver always fails but is always available as it does not rely on the plug-in mechanism.

It is also a good starting point for users that want to develop their own solver.

Member Typedef Documentation

Callback function type.

template<typename F >
typedef Solver<F, boost::mpl::vector<F> > roboptim::GenericDummySolverLastState< F >::parent_t

Define parent's type.

Type of the state of the solver.

Constructor & Destructor Documentation

template<typename F >
roboptim::GenericDummySolverLastState< F >::GenericDummySolverLastState ( const problem_t problem)
explicit

Build a solver from a problem.

Parameters
problemproblem that will be solved
template<typename F >
roboptim::GenericDummySolverLastState< F >::~GenericDummySolverLastState ( )
virtual

Member Function Documentation

template<typename F >
virtual void roboptim::GenericDummySolverLastState< F >::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 from roboptim::Solver< F, boost::mpl::vector< F > >.

References roboptim::GenericDummySolverLastState< F >::callback(), and roboptim::GenericDummySolverLastState< F >::callback_.

template<typename F >
void roboptim::GenericDummySolverLastState< F >::solve ( )
virtual

Implement the solve algorithm.

Implement the solve method as required by the GenericSolver class.

Implements roboptim::GenericSolver.

References roboptim::Result::constraints, roboptim::Result::lambda, result_, roboptim::Result::value, and roboptim::Result::x.

Member Data Documentation

template<typename F >
callback_t roboptim::GenericDummySolverLastState< F >::callback_

Intermediate callback (called at each end of iteration).

Referenced by roboptim::GenericDummySolverLastState< F >::callback(), and roboptim::GenericDummySolverLastState< F >::setIterationCallback().

template<typename F >
solverState_t roboptim::GenericDummySolverLastState< F >::solverState_

Current state of the solver (used by the callback function).