![]() |
Chemical Data Processing Library C++ API - Version 1.4.0
|
Fletcher's implementation of the BFGS method. More...
#include <BFGSMinimizer.hpp>
Inheritance diagram for CDPL::Math::BFGSMinimizer< VA, VT, FVT >:Public Types | |
| enum | Status { SUCCESS = 0 , NO_PROGRESS = 1 , ITER_LIMIT_REACHED = 2 , GNORM_REACHED = 4 , DELTAF_REACHED = 8 } |
| Status bitmask reported by minimize() and getStatus(). Multiple flags may be combined. More... | |
| typedef VA | VariableArrayType |
| The type of the variable array passed to the minimizer. More... | |
| typedef VT | ValueType |
| The scalar value type of VariableArrayType. More... | |
| typedef FVT | FunctionValueType |
| The scalar return type of the objective and gradient functions. More... | |
| typedef std::function< FVT(const VA &, VA &)> | GradientFunction |
| Type of the gradient function (computes the objective value and writes the gradient into the second argument). More... | |
| typedef std::function< FVT(const VA &)> | ObjectiveFunction |
| Type of the objective function. More... | |
Public Member Functions | |
| BFGSMinimizer (const ObjectiveFunction &func, const GradientFunction &grad_func) | |
Constructs the BFGSMinimizer instance with the given objective and gradient functions. More... | |
| ValueType | getGradientNorm () const |
| Returns the L2 norm of the gradient at the end of the most recent iterate() call. More... | |
| ValueType | getFunctionDelta () const |
| Returns the magnitude of the function-value decrease produced by the most recent iterate() call. More... | |
| ValueType | getFunctionValue () const |
| Returns the function value at the end of the most recent iterate() call. More... | |
| std::size_t | getNumIterations () const |
| Returns the number of iterations performed by the most recent minimize() or iterate() loop. More... | |
| Status | getStatus () const |
| Returns the current status of the minimizer. More... | |
| Status | minimize (VariableArrayType &x, VariableArrayType &g, std::size_t max_iter, const ValueType &g_norm, const ValueType &delta_f, bool do_setup=true) |
| Runs the BFGS minimization loop on x. More... | |
| ValueType | setup (const VariableArrayType &x, VariableArrayType &g, const ValueType &step_size=0.001, const ValueType &tol=0.15) |
| Initializes the minimizer state for a subsequent iterate() / minimize() loop. More... | |
| Status | iterate (ValueType &f, VariableArrayType &x, VariableArrayType &g) |
| Performs a single BFGS iteration: line search along the current search direction, BFGS update of the inverse Hessian approximation, and selection of the new search direction. More... | |
Fletcher's implementation of the BFGS method.
The implementation has been taken from the GNU Scientific Library.
| typedef VA CDPL::Math::BFGSMinimizer< VA, VT, FVT >::VariableArrayType |
The type of the variable array passed to the minimizer.
| typedef VT CDPL::Math::BFGSMinimizer< VA, VT, FVT >::ValueType |
The scalar value type of VariableArrayType.
| typedef FVT CDPL::Math::BFGSMinimizer< VA, VT, FVT >::FunctionValueType |
The scalar return type of the objective and gradient functions.
| typedef std::function<FVT(const VA&, VA&)> CDPL::Math::BFGSMinimizer< VA, VT, FVT >::GradientFunction |
Type of the gradient function (computes the objective value and writes the gradient into the second argument).
| typedef std::function<FVT(const VA&)> CDPL::Math::BFGSMinimizer< VA, VT, FVT >::ObjectiveFunction |
Type of the objective function.
| enum CDPL::Math::BFGSMinimizer::Status |
Status bitmask reported by minimize() and getStatus(). Multiple flags may be combined.
|
inline |
Constructs the BFGSMinimizer instance with the given objective and gradient functions.
| func | The objective function. |
| grad_func | The gradient function (also computes the objective value). |
|
inline |
Returns the L2 norm of the gradient at the end of the most recent iterate() call.
|
inline |
Returns the magnitude of the function-value decrease produced by the most recent iterate() call.
|
inline |
Returns the function value at the end of the most recent iterate() call.
|
inline |
Returns the number of iterations performed by the most recent minimize() or iterate() loop.
|
inline |
Returns the current status of the minimizer.
|
inline |
Runs the BFGS minimization loop on x.
| x | The variable vector to be minimized (modified in place). |
| g | The gradient vector (modified in place). |
| max_iter | The maximum number of iterations (0 means unlimited). |
| g_norm | The gradient-norm threshold below which the minimization is stopped (negative values disable this stop condition). |
| delta_f | The function-value-delta threshold below which the minimization is stopped (negative values disable this stop condition). |
| do_setup | If true, setup() is invoked at the start to initialize the minimizer. |
|
inline |
Initializes the minimizer state for a subsequent iterate() / minimize() loop.
| x | The starting variable vector. |
| g | The gradient vector (filled with the gradient at x). |
| step_size | The initial step-size guess. |
| tol | The line-search tolerance. |
|
inline |
Performs a single BFGS iteration: line search along the current search direction, BFGS update of the inverse Hessian approximation, and selection of the new search direction.
| f | The current function value (updated in place). |
| x | The current variable vector (updated in place). |
| g | The current gradient vector (updated in place). |