![]() |
Chemical Data Processing Library Python API - Version 1.4.0
|
Fletcher's implementation of the BFGS method. More...
Inheritance diagram for CDPL.Math.FVectorBFGSMinimizer:Classes | |
| class | Status |
| Status bitmask reported by minimize() and getStatus(). More... | |
Public Member Functions | |
| None | __init__ (FloatFVectorFunctor func, object grad_func) |
Constructs the BFGSMinimizer instance with the given objective and gradient functions. More... | |
| int | getObjectID () |
| Returns the numeric identifier (ID) of the wrapped C++ class instance. More... | |
| float | getGradientNorm () |
| Returns the L2 norm of the gradient at the end of the most recent iterate() call. More... | |
| float | getFunctionDelta () |
| Returns the magnitude of the function-value decrease produced by the most recent iterate() call. More... | |
| float | getFunctionValue () |
| Returns the function value at the end of the most recent iterate() call. More... | |
| int | getNumIterations () |
| Returns the number of iterations performed by the most recent minimize() or iterate() loop. More... | |
| Status | getStatus () |
| Returns the current status of the minimizer. More... | |
| Status | minimize (FVector x, FVector g, int max_iter, float g_norm, float delta_f, bool do_setup=True) |
| Runs the BFGS minimization loop on x. More... | |
| float | setup (FVector x, FVector g, float step_size=0.001, float tol=0.15) |
| Initializes the minimizer state for a subsequent iterate() / minimize() loop. More... | |
| tuple | iterate (float f, FVector x, FVector 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... | |
Properties | |
| objectID = property(getObjectID) | |
| gradientNorm = property(getGradientNorm) | |
| functionDelta = property(getFunctionDelta) | |
| functionValue = property(getFunctionValue) | |
| numIterations = property(getNumIterations) | |
| status = property(getStatus) | |
Fletcher's implementation of the BFGS method.
The implementation has been taken from the GNU Scientific Library.
| None CDPL.Math.FVectorBFGSMinimizer.__init__ | ( | FloatFVectorFunctor | func, |
| object | grad_func | ||
| ) |
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). |
| int CDPL.Math.FVectorBFGSMinimizer.getObjectID | ( | ) |
Returns the numeric identifier (ID) of the wrapped C++ class instance.
Different Python FVectorBFGSMinimizer instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two FVectorBFGSMinimizer instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().
| float CDPL.Math.FVectorBFGSMinimizer.getGradientNorm | ( | ) |
Returns the L2 norm of the gradient at the end of the most recent iterate() call.
| float CDPL.Math.FVectorBFGSMinimizer.getFunctionDelta | ( | ) |
Returns the magnitude of the function-value decrease produced by the most recent iterate() call.
| float CDPL.Math.FVectorBFGSMinimizer.getFunctionValue | ( | ) |
Returns the function value at the end of the most recent iterate() call.
| int CDPL.Math.FVectorBFGSMinimizer.getNumIterations | ( | ) |
Returns the number of iterations performed by the most recent minimize() or iterate() loop.
| Status CDPL.Math.FVectorBFGSMinimizer.getStatus | ( | ) |
Returns the current status of the minimizer.
| Status CDPL.Math.FVectorBFGSMinimizer.minimize | ( | FVector | x, |
| FVector | g, | ||
| int | max_iter, | ||
| float | g_norm, | ||
| float | delta_f, | ||
| bool | do_setup = True |
||
| ) |
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. |
| float CDPL.Math.FVectorBFGSMinimizer.setup | ( | FVector | x, |
| FVector | g, | ||
| float | step_size = 0.001, |
||
| float | tol = 0.15 |
||
| ) |
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. |
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). |