roboptim::OptimizationLogger< S > Class Template Reference

Log the optimization process (values, Jacobians, time taken etc.). More...

#include <roboptim/core/optimization-logger.hh>

Inheritance diagram for roboptim::OptimizationLogger< S >:
roboptim::SolverCallback< S >

List of all members.

Public Types

typedef SolverCallback< S > parent_t
typedef S solver_t
 Solver type.
typedef solver_t::problem_t problem_t
 Solver problem type.
typedef
solver_t::problem_t::value_type 
value_type
typedef
solver_t::problem_t::size_type 
size_type
typedef
solver_t::problem_t::vector_t 
vector_t
typedef solver_t::solverState_t solverState_t
 State of the solver.
typedef solver_t::callback_t callback_t
 Per-iteration callback type.
typedef
solver_t::problem_t::function_t::traits_t 
traits_t
typedef
solver_t::problem_t::function_t 
function_t
typedef function_t::matrix_t jacobian_t
typedef
function_t::const_argument_ref 
const_argument_ref
typedef
GenericDifferentiableFunction
< traits_t
differentiableFunction_t

Public Member Functions

 OptimizationLogger (solver_t &solver, const boost::filesystem::path &path, bool selfRegister=true)
 Constructor.
virtual ~OptimizationLogger ()
 Destructor.
void append (const std::string &text)
 Append extra information to the log file.
OptimizationLogger< S > & operator<< (const std::string &text)
 Append extra information to the log file.
template<typename U >
OptimizationLogger< S > & operator<< (const U &u)
 Append extra information to the log file.
const boost::filesystem::path & logPath () const
 Return the path of the log directory.
virtual std::ostream & print (std::ostream &o) const
 Display the logger on the specified output stream.

Protected Member Functions

void perIterationCallback (const problem_t &pb, solverState_t &state)
 Wrapper around the callback function that catch exceptions.
virtual void perIterationCallbackUnsafe (const typename solver_t::problem_t &pb, typename solver_t::solverState_t &state)
const boost::filesystem::path & path () const
 Return the path of the log directory.
boost::filesystem::path & path ()
 Return the path of the log directory.
const solver_tsolver () const
 Return the solver associated with the logger.
solver_tsolver ()
 Return the solver associated with the logger.
unsigned callbackCallId () const
 Return the callback iteration index.

Detailed Description

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

Log the optimization process (values, Jacobians, time taken etc.).

Template Parameters:
Ssolver type.

Member Typedef Documentation

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

template<typename S>
typedef function_t::const_argument_ref roboptim::OptimizationLogger< S >::const_argument_ref
template<typename S>
typedef function_t::matrix_t roboptim::OptimizationLogger< S >::jacobian_t
template<typename S>
typedef SolverCallback<S> roboptim::OptimizationLogger< S >::parent_t
template<typename S>
typedef solver_t::problem_t roboptim::OptimizationLogger< S >::problem_t

Solver problem type.

Reimplemented from roboptim::SolverCallback< S >.

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

Solver type.

Reimplemented from roboptim::SolverCallback< S >.

State of the solver.

Reimplemented from roboptim::SolverCallback< S >.

template<typename S>
typedef solver_t::problem_t::function_t::traits_t roboptim::OptimizationLogger< S >::traits_t

Constructor & Destructor Documentation

template<typename T >
roboptim::OptimizationLogger< T >::OptimizationLogger ( solver_t solver,
const boost::filesystem::path &  path,
bool  selfRegister = true 
) [explicit]

Constructor.

Parameters:
solversolver that will be logged.
pathpath to the log directory.
selfRegisterwhether the logger will register itself as a callback with the solver. Set this to false if you use it with a multiplexer.

References roboptim::iendl().

template<typename T >
roboptim::OptimizationLogger< T >::~OptimizationLogger ( ) [virtual]

Destructor.

CSV files are written in this destructor.

References roboptim::iendl(), and x_.


Member Function Documentation

template<typename T >
void roboptim::OptimizationLogger< T >::append ( const std::string &  text)

Append extra information to the log file.

Parameters:
texttext to append.

References roboptim::iendl().

template<typename T >
unsigned roboptim::OptimizationLogger< T >::callbackCallId ( ) const [protected]

Return the callback iteration index.

Returns:
callback iteration index.
template<typename T >
const boost::filesystem::path & roboptim::OptimizationLogger< T >::logPath ( ) const

Return the path of the log directory.

Note:
Seeing that the non-const version of path () needs to be protected, we need to rename this function to make it public, since overload resolution takes place before accessibility checks.
Returns:
path of the log directory.
template<typename T >
OptimizationLogger< T > & roboptim::OptimizationLogger< T >::operator<< ( const std::string &  text)

Append extra information to the log file.

Parameters:
texttext to append.
template<typename T >
template<typename U >
OptimizationLogger< T > & roboptim::OptimizationLogger< T >::operator<< ( const U &  u)

Append extra information to the log file.

Parameters:
uobject to print.
template<typename T >
const boost::filesystem::path & roboptim::OptimizationLogger< T >::path ( ) const [protected]

Return the path of the log directory.

Note:
This function should not be made public since the non-const version is protected.
Returns:
path of the log directory.
template<typename T >
boost::filesystem::path & roboptim::OptimizationLogger< T >::path ( ) [protected]

Return the path of the log directory.

This method is protected since streams would need to be updated, and files that were already written moved to the new location.

Returns:
path of the log directory.
template<typename T >
void roboptim::OptimizationLogger< T >::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 from roboptim::SolverCallback< S >.

template<typename T >
void roboptim::OptimizationLogger< T >::perIterationCallbackUnsafe ( const typename solver_t::problem_t pb,
typename solver_t::solverState_t state 
) [protected, virtual]
template<typename T >
std::ostream & roboptim::OptimizationLogger< T >::print ( std::ostream &  o) const [virtual]

Display the logger on the specified output stream.

Parameters:
ooutput stream used for display.
Returns:
output stream.

Reimplemented from roboptim::SolverCallback< S >.

References roboptim::decindent(), roboptim::iendl(), and roboptim::incindent().

template<typename T >
const OptimizationLogger< T >::solver_t & roboptim::OptimizationLogger< T >::solver ( ) const [protected]

Return the solver associated with the logger.

Returns:
solver associated with the logger.
template<typename T >
OptimizationLogger< T >::solver_t & roboptim::OptimizationLogger< T >::solver ( ) [protected]

Return the solver associated with the logger.

Returns:
solver associated with the logger.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines