roboptim::OptimizationLogger< T > Class Template Reference

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

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

Public Types

typedef T solver_t
 
typedef solver_t::problem_t problem_t
 
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
 
typedef solver_t::callback_t callback_t
 
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_tdifferentiableFunction_t
 

Public Member Functions

 OptimizationLogger (solver_t &solver, const boost::filesystem::path &path, bool selfRegister=true)
 Constructor. More...
 
virtual ~OptimizationLogger ()
 Destructor. More...
 
void append (const std::string &text)
 Append extra information to the log file. More...
 
callback_t callback ()
 Return the callback function. More...
 
const boost::filesystem::path & logPath () const
 Return the path of the log directory. More...
 
template<typename U >
boost::disable_if< boost::is_same< U, boost::mpl::vector<> > >::type process_constraints (const typename solver_t::problem_t &pb, const typename solver_t::solverState_t &state, const boost::filesystem::path &iterationPath, const_argument_ref x, value_type &cstrViol)
 
template<typename U >
boost::enable_if< boost::is_same< U, boost::mpl::vector<> > >::type process_constraints (const typename solver_t::problem_t &, const typename solver_t::solverState_t &, const boost::filesystem::path &, const_argument_ref, value_type &)
 

Protected Member Functions

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

Detailed Description

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

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

Template Parameters
Tsolver type.

Member Typedef Documentation

template<typename T>
typedef solver_t::callback_t roboptim::OptimizationLogger< T >::callback_t
template<typename T>
typedef function_t::const_argument_ref roboptim::OptimizationLogger< T >::const_argument_ref
template<typename T>
typedef solver_t::problem_t::function_t roboptim::OptimizationLogger< T >::function_t
template<typename T>
typedef function_t::matrix_t roboptim::OptimizationLogger< T >::jacobian_t
template<typename T>
typedef solver_t::problem_t roboptim::OptimizationLogger< T >::problem_t
template<typename T>
typedef solver_t::problem_t::size_type roboptim::OptimizationLogger< T >::size_type
template<typename T>
typedef T roboptim::OptimizationLogger< T >::solver_t
template<typename T>
typedef solver_t::solverState_t roboptim::OptimizationLogger< T >::solverState_t
template<typename T>
typedef solver_t::problem_t::function_t::traits_t roboptim::OptimizationLogger< T >::traits_t
template<typename T>
typedef solver_t::problem_t::value_type roboptim::OptimizationLogger< T >::value_type

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(), and ROBOPTIM_CORE_VERSION.

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 >
OptimizationLogger< T >::callback_t roboptim::OptimizationLogger< T >::callback ( )

Return the callback function.

This can be used with a callback multiplexer.

Returns
callback function.

References roboptim::bind().

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 >
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,
const solverState_t state 
)
protected
template<typename T >
void roboptim::OptimizationLogger< T >::perIterationCallbackUnsafe ( const typename solver_t::problem_t pb,
const typename solver_t::solverState_t state 
)
protectedvirtual
template<typename T>
template<typename U >
boost::disable_if<boost::is_same<U, boost::mpl::vector<> > >::type roboptim::OptimizationLogger< T >::process_constraints ( const typename solver_t::problem_t pb,
const typename solver_t::solverState_t state,
const boost::filesystem::path &  iterationPath,
const_argument_ref  x,
value_type cstrViol 
)
template<typename T>
template<typename U >
boost::enable_if<boost::is_same<U, boost::mpl::vector<> > >::type roboptim::OptimizationLogger< T >::process_constraints ( const typename solver_t::problem_t ,
const typename solver_t::solverState_t ,
const boost::filesystem::path &  ,
const_argument_ref  ,
value_type  
)
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.