Debug wrapper for any problem.
More...
#include <DebugProblem.hpp>
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.
◆ DebugProblem()
template<typename Problem , typename Scalar , typename ErrorHandler >
template<typename ... Args>
Construct a new debug problem.
- Parameters
-
| error_handler | Functor that is called in case of errors. |
| args | Arguments are passed through to the constructor call of the problem. |
- Note
- The epsilon values may have to be adapted for your problem.
◆ gradient()
template<typename Problem , typename Scalar , typename ErrorHandler >
Calculate and check the gradient.
- Parameters
-
| x | Point 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_epsilon | Epsilon 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_epsilon | Epsilon for numerical derivative calculation. |
- Note
- Meaningful values depend on the problem at hand!
The documentation for this struct was generated from the following file: