All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
roboptim::SolverCallback< S > Class Template Referenceabstract

Solver per-iteration callback wrapper. More...

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

Inheritance diagram for roboptim::SolverCallback< S >:
roboptim::callback::Multiplexer< S > roboptim::callback::Wrapper< S > roboptim::OptimizationLogger< T >

Public Types

typedef S solver_t
 Solver type. More...
 
typedef solver_t::problem_t problem_t
 Solver problem type. More...
 
typedef solver_t::callback_t callback_t
 Per-iteration callback type. More...
 
typedef solver_t::solverState_t solverState_t
 State of the solver. More...
 

Public Member Functions

 SolverCallback (const std::string &name="unnamed callback")
 Solver callback constructor. More...
 
virtual ~SolverCallback ()
 Destructor. More...
 
const std::string & name () const
 Return the name of the callback. More...
 
callback_t callback ()
 Callback function. More...
 
void operator() (const problem_t &pb, solverState_t &state)
 Evaluate the callback. More...
 
virtual std::ostream & print (std::ostream &o) const
 Display the callback on the specified output stream. More...
 

Protected Member Functions

virtual void perIterationCallback (const problem_t &pb, solverState_t &state)
 Wrapper around the callback function that catch exceptions. More...
 
virtual void perIterationCallbackUnsafe (const problem_t &pb, solverState_t &state)=0
 The actual callback function. More...
 

Detailed Description

template<typename S>
class roboptim::SolverCallback< S >

Solver per-iteration callback wrapper.

Template Parameters
Ssolver type.

Member Typedef Documentation

template<typename S>
typedef solver_t::callback_t roboptim::SolverCallback< S >::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 S>
typedef solver_t::problem_t roboptim::SolverCallback< S >::problem_t

Solver problem type.

template<typename S>
typedef S roboptim::SolverCallback< S >::solver_t

Solver type.

template<typename S>
typedef solver_t::solverState_t roboptim::SolverCallback< S >::solverState_t

State of the solver.

Constructor & Destructor Documentation

template<typename S >
roboptim::SolverCallback< S >::SolverCallback ( const std::string &  name = "unnamed callback")

Solver callback constructor.

Parameters
namename of the callback.
template<typename S >
roboptim::SolverCallback< S >::~SolverCallback ( )
virtual

Destructor.

Member Function Documentation

template<typename S >
SolverCallback< S >::callback_t roboptim::SolverCallback< S >::callback ( )

Callback function.

References roboptim::bind().

template<typename S >
const std::string & roboptim::SolverCallback< S >::name ( ) const

Return the name of the callback.

Returns
name of the callback.
template<typename S >
void roboptim::SolverCallback< S >::operator() ( const problem_t pb,
solverState_t state 
)

Evaluate the callback.

template<typename S >
void roboptim::SolverCallback< S >::perIterationCallback ( const problem_t pb,
solverState_t state 
)
protectedvirtual

Wrapper around the callback function that catch exceptions.

Parameters
pboptimization problem.
statestate of the solver after an iteration.

Reimplemented in roboptim::OptimizationLogger< T >.

template<typename S>
virtual void roboptim::SolverCallback< S >::perIterationCallbackUnsafe ( const problem_t pb,
solverState_t state 
)
protectedpure virtual

The actual callback function.

The function may throw.

Parameters
pboptimization problem.
statestate of the solver after an iteration.
template<typename S >
std::ostream & roboptim::SolverCallback< S >::print ( std::ostream &  o) const
virtual

Display the callback on the specified output stream.

Parameters
ooutput stream used for display.
Returns
output stream.

Reimplemented in roboptim::OptimizationLogger< T >, and roboptim::callback::Multiplexer< S >.