LBFGS optimizer with optional boxing.
More...
#include <Lbfgs.h>
|
using | MatrixType = Eigen::Matrix< FloatType, Eigen::Dynamic, Eigen::Dynamic > |
|
using | VectorType = Eigen::Matrix< FloatType, Eigen::Dynamic, 1 > |
|
|
template<typename UpdateFunction , typename Checker , typename Observer = Detail::DoNothingObserver> |
OptimizationReturnType | minimize (Eigen::Ref< VectorType > parameters, UpdateFunction &&function, Checker &&check, Observer &&observer=Observer{}) |
| Find parameters to minimize an objective function. More...
|
|
template<typename UpdateFunction , typename Checker , typename Observer = Detail::DoNothingObserver> |
OptimizationReturnType | maximize (Eigen::Ref< VectorType > parameters, UpdateFunction &&function, Checker &&check, Observer &&observer=Observer{}) |
| Find parameters to maximize an objective function. More...
|
|
template<typename UpdateFunction , typename Checker , typename Observer = Detail::DoNothingObserver> |
OptimizationReturnType | minimize (Eigen::Ref< VectorType > parameters, const Box &box, UpdateFunction &&function, Checker &&check, Observer &&observer=Observer{}) |
| Find parameters to minimize an objective function within bounds. More...
|
|
template<typename UpdateFunction , typename Checker , typename Observer = Detail::DoNothingObserver> |
OptimizationReturnType | maximize (Eigen::Ref< VectorType > parameters, const Box &box, UpdateFunction &&function, Checker &&check, Observer &&observer=Observer{}) |
| Find parameters to maximize an objective function within bounds. More...
|
|
|
static constexpr bool | isPowerOfTwo (unsigned x) |
|
|
FloatType | c1 = 0.0001 |
| 1st parameter for the Wolfe conditions.
|
|
FloatType | c2 = 0.9 |
| 2nd parameter for the Wolfe conditions. More...
|
|
FloatType | stepLength = 1.0 |
| The initial step length used in the L-BFGS. More...
|
|
|
template<typename UpdateFunction , typename Observer , typename... Boxes> |
unsigned | adjustStepAlongDirection (UpdateFunction &&function, Observer &&observer, StepValues &step, const VectorType &direction, const Boxes &...boxes) |
| Adjusts stepLength member and ensures the proposed parameter adjustment lowers the function value. More...
|
|
template<typename UpdateFunction , typename Checker , typename Observer , typename... Boxes> |
OptimizationReturnType | minimizeBase (Eigen::Ref< VectorType > parameters, UpdateFunction &&function, Checker &&check, Observer &&observer, Boxes &&...boxes) |
|
template<typename FloatType = double, unsigned ringBufferSize = 16>
class Scine::Molassembler::Temple::Lbfgs< FloatType, ringBufferSize >
LBFGS optimizer with optional boxing.
- Template Parameters
-
FloatType | Type to represent floating point numbers |
ringBufferSize | Number of gradients to use in Hessian approximation, this is akin to memory |
template<typename FloatType = double, unsigned ringBufferSize = 16>
template<typename UpdateFunction , typename Observer , typename... Boxes>
unsigned Scine::Molassembler::Temple::Lbfgs< FloatType, ringBufferSize >::adjustStepAlongDirection |
( |
UpdateFunction && |
function, |
|
|
Observer && |
observer, |
|
|
StepValues & |
step, |
|
|
const VectorType & |
direction, |
|
|
const Boxes &... |
boxes |
|
) |
| |
|
inlineprivate |
Adjusts stepLength
member and ensures the proposed parameter adjustment lowers the function value.
The chosen direction and step length may overshoot or undershoot, and the function value might increase. We try to adapt the step length in order to ensure the function value decreases and step length is more or less optimal.
- Parameters
-
function | Objective function generating value and gradients from parameters |
observer | Observer called with parameter updates |
step | Suggested step in parameters, values and gradients |
direction | Suggested step direction |
boxes | Boxes (if present) |
- Returns
- Number of function evaluations made in adjusting the step
template<typename FloatType = double, unsigned ringBufferSize = 16>
template<typename UpdateFunction , typename Checker , typename Observer = Detail::DoNothingObserver>
Find parameters to maximize an objective function.
- Template Parameters
-
UpdateFunction | A callable object taking arguments (const VectorType&, double&, Ref<VectorType>). Any return values are ignored. |
Checker | An object implementing one methods:
- shouldContinue: (const unsigned iterations, const StepValues& step) -> bool
|
Observer | An observer callable object taking parameters. Return values are ignored. |
- Parameters
-
parameters | The initial parameters to optimize. Resulting optimization parameters are written to this argument. |
function | The objective function to optimize. |
check | The Checker instance |
observer | The Observer instance |
- Returns
- The number of calls to
function
made during optimization
template<typename FloatType = double, unsigned ringBufferSize = 16>
template<typename UpdateFunction , typename Checker , typename Observer = Detail::DoNothingObserver>
Find parameters to maximize an objective function within bounds.
- Template Parameters
-
UpdateFunction | A callable object taking arguments (const VectorType&, double&, Ref<VectorType>). Any return values are ignored. |
Checker | An object implementing one methods:
- shouldContinue: (const unsigned iterations, const StepValues& step) -> bool
|
Observer | An observer callable object taking parameters. Return values are ignored. |
- Parameters
-
parameters | The initial parameters to optimize. Resulting optimization parameters are written to this argument. |
box | Bounds on the parameters |
function | The objective function to optimize. |
check | The Checker instance |
observer | The Observer instance |
- Returns
- The number of calls to
function
made during optimization
template<typename FloatType = double, unsigned ringBufferSize = 16>
template<typename UpdateFunction , typename Checker , typename Observer = Detail::DoNothingObserver>
Find parameters to minimize an objective function.
- Template Parameters
-
UpdateFunction | A callable object taking arguments (const VectorType&, double&, Ref<VectorType>). Any return values are ignored. |
Checker | An object implementing one methods:
- shouldContinue: (const unsigned iterations, const StepValues& step) -> bool
|
Observer | An observer callable object taking parameters. Return values are ignored. |
- Parameters
-
parameters | The initial parameters to optimize. Resulting optimization parameters are written to this argument. |
function | The objective function to optimize. |
check | The Checker instance |
observer | The Observer instance |
- Returns
- A
OptimizationReturnType
instance
template<typename FloatType = double, unsigned ringBufferSize = 16>
template<typename UpdateFunction , typename Checker , typename Observer = Detail::DoNothingObserver>
Find parameters to minimize an objective function within bounds.
- Template Parameters
-
UpdateFunction | A callable object taking arguments (const VectorType&, double&, Ref<VectorType>). Any return values are ignored. |
Checker | An object implementing one methods:
- shouldContinue: (const unsigned iterations, const StepValues& step) -> bool
|
Observer | An observer callable object taking parameters. Return values are ignored. |
- Parameters
-
parameters | The initial parameters to optimize. Resulting optimization parameters are written to this argument. |
box | Bounds on the parameters |
function | The objective function to optimize. |
check | The Checker instance |
observer | The Observer instance |
- Note
- Gradients passed to
check
do not contain bounded components
- Returns
- The number of calls to
function
made during optimization
template<typename FloatType = double, unsigned ringBufferSize = 16>
2nd parameter for the Wolfe conditions.
A value as low as 0.1 can be used.
template<typename FloatType = double, unsigned ringBufferSize = 16>
The initial step length used in the L-BFGS.
Note: the first step is a gradient descent with 0.1 times the steplength.
The documentation for this class was generated from the following file:
- Molassembler/Temple/Optimization/Lbfgs.h