roboptim::SolverCallback< S > Class Template Reference

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< S >

List of all members.

Public Types

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

Public Member Functions

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

Protected Member Functions

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

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.

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


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 
) [protected, virtual]

Wrapper around the callback function that catch exceptions.

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

Reimplemented in roboptim::OptimizationLogger< S >.

template<typename S>
virtual void roboptim::SolverCallback< S >::perIterationCallbackUnsafe ( const problem_t pb,
solverState_t state 
) [protected, pure 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< S >, and roboptim::callback::Multiplexer< S >.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines