#include <itkLBFGSOptimizerv4.h>
Wrap of the vnl_lbfgs algorithm for use in ITKv4 registration framework. The vnl_lbfgs is a wrapper for the NETLIB fortran code by Nocedal [1].
LBFGS is a quasi-Newton method. Quasi-Newton methods use an approximate estimate of the inverse Hessian \( (\nabla^2 f(x) )^{-1} \) to scale the gradient step:
\[x_{n+1} = x_n - s (\nabla^2 f(x_n) )^{-1} \nabla f(x) \]
with \( s \) the step size.
The inverse Hessian is approximated from the gradients of previous iteration and thus only the gradient of the objective function is required.
The step size \( s \) is determined through line search with the approach by More and Thuente [4]. This line search approach finds a step size such that
\[\| \nabla f(x + s (\nabla^2 f(x_n) )^{-1} \nabla f(x) ) \| \le \nu \| \nabla f(x) \| \]
The parameter \( \nu \) is set through SetLineSearchAccuracy() (default 0.9) The default step length, i.e. starting step length for the line search, is set through SetDefaultStepLength() (default 1.0).
The optimization stops when either the gradient satisfies the condition
\[\| \nabla f(x) \| \le \epsilon \max(1, \| X \|) \]
or a maximum number of function evaluations has been reached. The tolerance \(\epsilon\) is set through SetGradientConvergenceTolerance() (default 1e-5) and the maximum number of function evaluations is set through SetMaximumNumberOfFunctionEvaluations() (default 2000).
Note: The scaling of the optimization parameters, set through SetScales(), should be set or left at one. Otherwise the Hessian approximation as well as the line search will be disturbed and the optimizer is unlikely to find a minima.
For algorithmic details see NETLIB lbfgs, [82], [68] and [79].
Definition at line 73 of file itkLBFGSOptimizerv4.h.
Public Member Functions | |
virtual::itk::LightObject::Pointer | CreateAnother () const |
virtual double | GetDefaultStepLength () const |
virtual double | GetLineSearchAccuracy () const |
const char * | GetNameOfClass () const override |
void | SetDefaultStepLength (double f) |
void | SetLineSearchAccuracy (double f) |
void | SetMetric (MetricType *metric) override |
void | StartOptimization (bool doOnlyInitialization=false) override |
void | VerboseOff () |
void | VerboseOn () |
![]() | |
virtual double | GetGradientConvergenceTolerance () const |
virtual double | GetGradientConvergenceTolerance () const |
virtual unsigned int | GetMaximumNumberOfFunctionEvaluations () const |
virtual unsigned int | GetMaximumNumberOfFunctionEvaluations () const |
InternalOptimizerType * | GetOptimizer () |
InternalOptimizerType * | GetOptimizer () |
StopConditionReturnStringType | GetStopConditionDescription () const override |
StopConditionReturnStringType | GetStopConditionDescription () const override |
virtual bool | GetTrace () const |
virtual bool | GetTrace () const |
virtual void | SetGradientConvergenceTolerance (double f) |
virtual void | SetGradientConvergenceTolerance (double f) |
virtual void | SetMaximumNumberOfFunctionEvaluations (unsigned int n) |
virtual void | SetMaximumNumberOfFunctionEvaluations (unsigned int n) |
virtual void | SetTrace (bool flag) |
virtual void | SetTrace (bool flag) |
virtual void | TraceOff () |
virtual void | TraceOff () |
virtual void | TraceOn () |
virtual void | TraceOn () |
![]() | |
const char * | GetNameOfClass () const override |
void | StartOptimization (bool doOnlyInitialization=false) override |
virtual const DerivativeType & | GetCachedDerivative () const |
virtual const ParametersType & | GetCachedCurrentPosition () const |
![]() | |
virtual bool | CanUseScales () const |
virtual bool | CanUseScales () const |
virtual SizeValueType | GetCurrentIteration () const |
virtual SizeValueType | GetCurrentIteration () const |
virtual const MeasureType & | GetCurrentMetricValue () const |
virtual const MeasureType & | GetCurrentMetricValue () const |
virtual const ParametersType & | GetCurrentPosition () const |
virtual const ParametersType & | GetCurrentPosition () const |
virtual SizeValueType | GetNumberOfIterations () const |
virtual SizeValueType | GetNumberOfIterations () const |
virtual const ThreadIdType & | GetNumberOfWorkUnits () const |
virtual const ThreadIdType & | GetNumberOfWorkUnits () const |
virtual const ScalesType & | GetScales () const |
virtual const ScalesType & | GetScales () const |
virtual const bool & | GetScalesAreIdentity () const |
virtual const bool & | GetScalesAreIdentity () const |
bool | GetScalesInitialized () const |
bool | GetScalesInitialized () const |
virtual const MeasureType & | GetValue () const |
virtual const MeasureType & | GetValue () const |
virtual const ScalesType & | GetWeights () const |
virtual const ScalesType & | GetWeights () const |
virtual const bool & | GetWeightsAreIdentity () const |
virtual const bool & | GetWeightsAreIdentity () const |
virtual void | SetNumberOfIterations (SizeValueType _arg) |
virtual void | SetNumberOfIterations (SizeValueType _arg) |
virtual void | SetNumberOfWorkUnits (ThreadIdType number) |
virtual void | SetNumberOfWorkUnits (ThreadIdType number) |
virtual void | SetScalesEstimator (ScalesEstimatorType *_arg) |
virtual void | SetScalesEstimator (ScalesEstimatorType *_arg) |
virtual void | SetWeights (ScalesType _arg) |
virtual void | SetWeights (ScalesType _arg) |
virtual MetricType * | GetModifiableMetric () |
virtual const MetricType * | GetMetric () const |
virtual MetricType * | GetModifiableMetric () |
virtual const MetricType * | GetMetric () const |
virtual void | SetScales (const ScalesType &scales) |
virtual void | SetScales (const ScalesType &scales) |
virtual void | SetDoEstimateScales (bool _arg) |
virtual const bool & | GetDoEstimateScales () const |
virtual void | DoEstimateScalesOn () |
virtual void | DoEstimateScalesOff () |
virtual void | SetDoEstimateScales (bool _arg) |
virtual const bool & | GetDoEstimateScales () const |
virtual void | DoEstimateScalesOn () |
virtual void | DoEstimateScalesOff () |
![]() | |
unsigned long | AddObserver (const EventObject &event, Command *cmd) const |
unsigned long | AddObserver (const EventObject &event, std::function< void(const EventObject &)> function) const |
LightObject::Pointer | CreateAnother () const override |
virtual void | DebugOff () const |
virtual void | DebugOn () const |
Command * | GetCommand (unsigned long tag) |
bool | GetDebug () const |
MetaDataDictionary & | GetMetaDataDictionary () |
const MetaDataDictionary & | GetMetaDataDictionary () const |
virtual ModifiedTimeType | GetMTime () const |
virtual const TimeStamp & | GetTimeStamp () const |
bool | HasObserver (const EventObject &event) const |
void | InvokeEvent (const EventObject &) |
void | InvokeEvent (const EventObject &) const |
virtual void | Modified () const |
void | Register () const override |
void | RemoveAllObservers () |
void | RemoveObserver (unsigned long tag) const |
void | SetDebug (bool debugFlag) const |
void | SetReferenceCount (int) override |
void | UnRegister () const noexcept override |
void | SetMetaDataDictionary (const MetaDataDictionary &rhs) |
void | SetMetaDataDictionary (MetaDataDictionary &&rrhs) |
virtual void | SetObjectName (std::string _arg) |
virtual const std::string & | GetObjectName () const |
![]() | |
Pointer | Clone () const |
virtual void | Delete () |
virtual int | GetReferenceCount () const |
void | Print (std::ostream &os, Indent indent=0) const |
Static Public Member Functions | |
static Pointer | New () |
![]() | |
static bool | GetGlobalWarningDisplay () |
static void | GlobalWarningDisplayOff () |
static void | GlobalWarningDisplayOn () |
static Pointer | New () |
static void | SetGlobalWarningDisplay (bool val) |
![]() | |
static void | BreakOnError () |
static Pointer | New () |
Protected Types | |
using | InternalOptimizerType = vnl_lbfgs |
using | InternalParametersType = vnl_vector<double> |
![]() | |
using | CostFunctionAdaptorType |
using | InternalOptimizerAutoPointer |
![]() | |
using | CostFunctionAdaptorType = SingleValuedVnlCostFunctionAdaptorv4 |
Private Attributes | |
double | m_DefaultStepLength { 1.0 } |
double | m_LineSearchAccuracy { 0.9 } |
bool | m_Verbose { false } |
using itk::LBFGSOptimizerv4::ConstPointer = SmartPointer<const Self> |
Definition at line 82 of file itkLBFGSOptimizerv4.h.
|
protected |
Internal optimizer type.
Definition at line 137 of file itkLBFGSOptimizerv4.h.
|
protected |
InternalParameters type alias.
Definition at line 134 of file itkLBFGSOptimizerv4.h.
Definition at line 84 of file itkLBFGSOptimizerv4.h.
Definition at line 85 of file itkLBFGSOptimizerv4.h.
Definition at line 81 of file itkLBFGSOptimizerv4.h.
Definition at line 86 of file itkLBFGSOptimizerv4.h.
Standard "Self" type alias.
Definition at line 79 of file itkLBFGSOptimizerv4.h.
using itk::LBFGSOptimizerv4::Superclass = LBFGSOptimizerBasev4<vnl_lbfgs> |
Definition at line 80 of file itkLBFGSOptimizerv4.h.
|
protected |
Referenced by GetNameOfClass().
|
overrideprotected |
|
virtual |
Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.
Reimplemented from itk::LightObject.
|
virtual |
|
virtual |
|
overridevirtual |
Reimplemented from itk::LBFGSOptimizerBasev4< vnl_lbfgs >.
References LBFGSOptimizerv4().
|
static |
Method for creation through the object factory.
|
overrideprotectedvirtual |
Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.
Reimplemented from itk::LBFGSOptimizerBasev4< vnl_lbfgs >.
void itk::LBFGSOptimizerv4::SetDefaultStepLength | ( | double | f | ) |
Set/Get the default step size. This is a positive real number with a default value of 1.0 which determines the step size in the line search.
void itk::LBFGSOptimizerv4::SetLineSearchAccuracy | ( | double | f | ) |
Set/Get the line search accuracy. This is a positive real number with a default value of 0.9, which controls the accuracy of the line search. If the function and gradient evaluations are inexpensive with respect to the cost of the iterations it may be advantageous to set the value to a small value (say 0.1).
|
overridevirtual |
Plug in a Cost Function into the optimizer
Reimplemented from itk::LBFGSOptimizerBasev4< vnl_lbfgs >.
|
overridevirtual |
Start optimization with an initial value.
Reimplemented from itk::LBFGSOptimizerBasev4< vnl_lbfgs >.
void itk::LBFGSOptimizerv4::VerboseOff | ( | ) |
void itk::LBFGSOptimizerv4::VerboseOn | ( | ) |
|
private |
Definition at line 142 of file itkLBFGSOptimizerv4.h.
|
private |
Definition at line 141 of file itkLBFGSOptimizerv4.h.
|
private |
Definition at line 140 of file itkLBFGSOptimizerv4.h.