LSLOpt  1.0
Public Member Functions | List of all members
LSLOpt::DebugProblem< Problem, Scalar, ErrorHandler > Struct Template Reference

Debug wrapper for any problem. More...

#include <DebugProblem.hpp>

Inheritance diagram for LSLOpt::DebugProblem< Problem, Scalar, ErrorHandler >:

Public Member Functions

template<typename ... Args>
 DebugProblem (ErrorHandler &error_handler, Args &&... args)
 Construct a new debug problem. More...
 
void setDerivativeEpsilon (const Scalar &derivative_epsilon=1e-6)
 Set the epsilon value for numerical derivative calculation. More...
 
void setCompareEpsilon (const Scalar &compare_epsilon=1e-3)
 Set the epsilon value for comparison of analytical and numerical derivative. More...
 
const Scalar & getDerivativeEpsilon () const
 Get the epsilon value for numerical derivative calculation.
 
const Scalar & getCompareEpsilon () const
 Get the epsilon value for comparison of analytical and numerical derivative.
 
Implementation::problem_traits< Problem, Scalar >::gradient_type gradient (const Vector< Scalar > &x)
 Calculate and check the gradient. More...
 

Detailed Description

template<typename Problem, typename Scalar, typename ErrorHandler>
struct LSLOpt::DebugProblem< Problem, Scalar, ErrorHandler >

Debug wrapper for any problem.

This wrapper class compares the provided gradient function to the numerically determined gradient by finite differences.

Warning
This makes the optimization slow and is not intended for production use.

Constructor & Destructor Documentation

◆ DebugProblem()

template<typename Problem , typename Scalar , typename ErrorHandler >
template<typename ... Args>
LSLOpt::DebugProblem< Problem, Scalar, ErrorHandler >::DebugProblem ( ErrorHandler &  error_handler,
Args &&...  args 
)
inline

Construct a new debug problem.

Parameters
error_handlerFunctor that is called in case of errors.
argsArguments are passed through to the constructor call of the problem.
Note
The epsilon values may have to be adapted for your problem.

Member Function Documentation

◆ gradient()

template<typename Problem , typename Scalar , typename ErrorHandler >
Implementation::problem_traits<Problem, Scalar>::gradient_type LSLOpt::DebugProblem< Problem, Scalar, ErrorHandler >::gradient ( const Vector< Scalar > &  x)
inline

Calculate and check the gradient.

Parameters
xPoint where to evaluate the function.
Returns
Gradient at x.

This function checks the calculated gradient against the numerically determined gradient using the finite difference method.

If the deviation is too large, the error functor is called.

◆ setCompareEpsilon()

template<typename Problem , typename Scalar , typename ErrorHandler >
void LSLOpt::DebugProblem< Problem, Scalar, ErrorHandler >::setCompareEpsilon ( const Scalar &  compare_epsilon = 1e-3)
inline

Set the epsilon value for comparison of analytical and numerical derivative.

Parameters
compare_epsilonEpsilon for comparison of analytical and numerical derivative.
Note
Meaningful values depend on the problem at hand!

◆ setDerivativeEpsilon()

template<typename Problem , typename Scalar , typename ErrorHandler >
void LSLOpt::DebugProblem< Problem, Scalar, ErrorHandler >::setDerivativeEpsilon ( const Scalar &  derivative_epsilon = 1e-6)
inline

Set the epsilon value for numerical derivative calculation.

Parameters
derivative_epsilonEpsilon for numerical derivative calculation.
Note
Meaningful values depend on the problem at hand!

The documentation for this struct was generated from the following file: