go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elastix::QuasiNewtonLBFGS< TElastix > Class Template Reference

#include <elxQuasiNewtonLBFGS.h>

Detailed Description

template<class TElastix>
class elastix::QuasiNewtonLBFGS< TElastix >

An optimizer based on the itk::QuasiNewtonLBFGSOptimizer.

The QuasiNewtonLBFGS class is a wrap around the QuasiNewtonLBFGSOptimizer. It uses the itk::MoreThuenteLineSearchOptimizer. Please read the documentation of these classes to find out more about it.

This optimizer supports the NewSamplesEveryIteration option. It requests new samples for the computation of each search direction (not during the line search). Actually this makes no sense for a QuasiNewton optimizer. So, think twice before using the NewSamplesEveryIteration option.

The parameters used in this class are:

Parameters

Optimizer: Select this optimizer as follows:
(Optimizer "QuasiNewtonLBFGS")

GenerateLineSearchIterations: Whether line search iteration should be counted as elastix-iterations.
example: (GenerateLineSearchIterations "true")
Can only be specified for all resolutions at once.
Default value: "false".

MaximumNumberOfIterations: The maximum number of iterations in each resolution.
example: (MaximumNumberOfIterations 100 100 50)
Default value: 100.

MaximumNumberOfLineSearchIterations: The maximum number of line search iterations in each resolution.
example: (MaximumNumberOfLineSearchIterations 10 10 5)
Default value: 20.

StepLength: Set the length of the initial step tried by the itk::MoreThuenteLineSearchOptimizer.
example: (StepLength 2.0 1.0 0.5)
Default value: 1.0.

LineSearchValueTolerance: Determine the Wolfe conditions that the itk::MoreThuenteLineSearchOptimizer tries to satisfy.
example: (LineSearchValueTolerance 0.0001 0.0001 0.0001)
Default value: 0.0001.

LineSearchGradientTolerance: Determine the Wolfe conditions that the itk::MoreThuenteLineSearchOptimizer tries to satisfy.
example: (LineSearchGradientTolerance 0.9 0.9 0.9)
Default value: 0.9.

GradientMagnitudeTolerance: Stopping criterion. See the documentation of the itk::QuasiNewtonLBFGSOptimizer for more information.
example: (GradientMagnitudeTolerance 0.001 0.0001 0.000001)
Default value: 0.000001.

LBFGSUpdateAccuracy: The "memory" of the optimizer. This determines how many past iterations are used to construct the Hessian approximation. The higher, the more memory is used, but the better the Hessian approximation. If set to zero, The QuasiNewtonLBFGS equals a gradient descent method with line search.
example: (LBFGSUpdateAccuracy 5 10 20)
Default value: 5.

StopIfWolfeNotSatisfied: Whether to stop the optimisation if in one iteration the Wolfe conditions can not be satisfied by the itk::MoreThuenteLineSearchOptimizer.
In general it is wise to do so.
example: (StopIfWolfeNotSatisfied "true" "false")
Default value: "true".

Definition at line 88 of file elxQuasiNewtonLBFGS.h.

Inheritance diagram for elastix::QuasiNewtonLBFGS< TElastix >:

Public Types

using ConstPointer = itk::SmartPointer<const Self>
 
using EventPassThroughPointer = typename EventPassThroughType::Pointer
 
using EventPassThroughType = itk::ReceptorMemberCommand<Self>
 
using ITKBaseType = typename Superclass2::ITKBaseType
 
using LineOptimizerPointer = LineOptimizerType::Pointer
 
using LineOptimizerType = itk::MoreThuenteLineSearchOptimizer
 
using Pointer = itk::SmartPointer<Self>
 
using Self = QuasiNewtonLBFGS
 
enum class  StopConditionType
 
using Superclass1 = QuasiNewtonLBFGSOptimizer
 
using Superclass2 = OptimizerBase<TElastix>
 
- Public Types inherited from itk::QuasiNewtonLBFGSOptimizer
using ConstPointer = SmartPointer<const Self>
 
using DiagonalMatrixType = Array<double>
 
using LineSearchOptimizerPointer = LineSearchOptimizerType::Pointer
 
using LineSearchOptimizerType = LineSearchOptimizer
 
using Pointer = SmartPointer<Self>
 
using RhoType = Array<double>
 
using ScaledCostFunctionType
 
using ScalesType
 
using Self = QuasiNewtonLBFGSOptimizer
 
enum class  StopConditionType {
  MetricError , LineSearchError , MaximumNumberOfIterations , InvalidDiagonalMatrix ,
  GradientMagnitudeTolerance , ZeroStep , Unknown
}
 
using SType = std::vector<ParametersType>
 
using Superclass = ScaledSingleValuedNonLinearOptimizer
 
using YType = std::vector<DerivativeType>
 
- Public Types inherited from itk::ScaledSingleValuedNonLinearOptimizer
using ConstPointer = SmartPointer<const Self>
 
using Pointer = SmartPointer<Self>
 
using ScaledCostFunctionPointer = ScaledCostFunctionType::Pointer
 
using ScaledCostFunctionType = ScaledSingleValuedCostFunction
 
using ScalesType = NonLinearOptimizer::ScalesType
 
using Self = ScaledSingleValuedNonLinearOptimizer
 
using Superclass = SingleValuedNonLinearOptimizer
 
- Public Types inherited from elastix::OptimizerBase< TElastix >
using ElastixType
 
using ITKBaseType = itk::Optimizer
 
using ParametersType = typename ITKBaseType::ParametersType
 
using RegistrationType
 
using Self = OptimizerBase
 
using Superclass = BaseComponentSE<TElastix>
 
- Public Types inherited from elastix::BaseComponentSE< TElastix >
using ElastixType = TElastix
 
using RegistrationType = typename ElastixType::RegistrationBaseType
 
using Self = BaseComponentSE
 
using Superclass = BaseComponent
 

Public Member Functions

void AfterEachIteration () override
 
void AfterEachResolution () override
 
void AfterRegistration () override
 
void BeforeEachResolution () override
 
void BeforeRegistration () override
 
 elxClassNameMacro ("QuasiNewtonLBFGS")
 
virtual const char * GetClassName () const
 
virtual bool GetStartLineSearch () const
 
 ITK_DISALLOW_COPY_AND_MOVE (QuasiNewtonLBFGS)
 
void StartOptimization () override
 
- Public Member Functions inherited from itk::QuasiNewtonLBFGSOptimizer
virtual const DerivativeType & GetCurrentGradient ()
 
virtual unsigned long GetCurrentIteration () const
 
virtual double GetCurrentStepLength () const
 
virtual MeasureType GetCurrentValue () const
 
virtual double GetGradientMagnitudeTolerance () const
 
virtual bool GetInLineSearch () const
 
virtual unsigned long GetMaximumNumberOfIterations () const
 
virtual unsigned int GetMemory () const
 
virtual const StopConditionTypeGetStopCondition ()
 
 ITK_DISALLOW_COPY_AND_MOVE (QuasiNewtonLBFGSOptimizer)
 
 itkGetModifiableObjectMacro (LineSearchOptimizer, LineSearchOptimizerType)
 
virtual void ResumeOptimization ()
 
virtual void SetGradientMagnitudeTolerance (double _arg)
 
virtual void SetLineSearchOptimizer (LineSearchOptimizerType *_arg)
 
virtual void SetMaximumNumberOfIterations (unsigned long _arg)
 
virtual void SetMemory (unsigned int _arg)
 
void StartOptimization () override
 
virtual void StopOptimization ()
 
- Public Member Functions inherited from itk::ScaledSingleValuedNonLinearOptimizer
const ParametersType & GetCurrentPosition () const override
 
virtual bool GetMaximize () const
 
virtual const ScaledCostFunctionTypeGetScaledCostFunction ()
 
virtual const ParametersType & GetScaledCurrentPosition ()
 
bool GetUseScales () const
 
virtual void InitializeScales ()
 
 ITK_DISALLOW_COPY_AND_MOVE (ScaledSingleValuedNonLinearOptimizer)
 
virtual void MaximizeOff ()
 
virtual void MaximizeOn ()
 
void SetCostFunction (CostFunctionType *costFunction) override
 
virtual void SetMaximize (bool _arg)
 
virtual void SetUseScales (bool arg)
 
- Public Member Functions inherited from elastix::OptimizerBase< TElastix >
void AfterRegistrationBase () override
 
void BeforeEachResolutionBase () override
 
ITKBaseTypeGetAsITKBaseType ()
 
const ITKBaseTypeGetAsITKBaseType () const
 
 ITK_DISALLOW_COPY_AND_MOVE (OptimizerBase)
 
virtual void SetCurrentPositionPublic (const ParametersType &param)
 
virtual void SetSinusScales (double amplitude, double frequency, unsigned long numberOfParameters)
 
- Public Member Functions inherited from elastix::BaseComponentSE< TElastix >
void AddTargetCellToIterationInfo (const char *const name)
 
const ConfigurationGetConfiguration () const
 
ElastixTypeGetElastix () const
 
auto & GetIterationInfoAt (const char *const name)
 
RegistrationTypeGetRegistration () const
 
 ITK_DISALLOW_COPY_AND_MOVE (BaseComponentSE)
 
void RemoveTargetCellFromIterationInfo (const char *const name)
 
void SetConfiguration (const Configuration *_arg)
 
void SetElastix (ElastixType *_arg)
 
- Public Member Functions inherited from elastix::BaseComponent
virtual void AfterEachIterationBase ()
 
virtual void AfterEachResolutionBase ()
 
virtual int BeforeAll ()
 
virtual int BeforeAllBase ()
 
virtual void BeforeRegistrationBase ()
 
virtual const char * elxGetClassName () const
 
const char * GetComponentLabel () const
 
 ITK_DISALLOW_COPY_AND_MOVE (BaseComponent)
 
 itkTypeMacroNoParent (BaseComponent)
 
void SetComponentLabel (const char *label, unsigned int idx)
 

Static Public Member Functions

static Pointer New ()
 
- Static Public Member Functions inherited from itk::QuasiNewtonLBFGSOptimizer
static Pointer New ()
 
- Static Public Member Functions inherited from itk::ScaledSingleValuedNonLinearOptimizer
static Pointer New ()
 
- Static Public Member Functions inherited from elastix::BaseComponent
template<typename TBaseComponent >
static auto AsITKBaseType (TBaseComponent *const baseComponent) -> decltype(baseComponent->GetAsITKBaseType())
 
static void InitializeElastixExecutable ()
 
static bool IsElastixLibrary ()
 

Protected Member Functions

virtual std::string DeterminePhase () const
 
virtual std::string GetLineSearchStopCondition () const
 
void LineSearch (const ParametersType searchDir, double &step, ParametersType &x, MeasureType &f, DerivativeType &g) override
 
 QuasiNewtonLBFGS ()
 
bool TestConvergence (bool firstLineSearchDone) override
 
 ~QuasiNewtonLBFGS () override=default
 
- Protected Member Functions inherited from itk::QuasiNewtonLBFGSOptimizer
virtual void ComputeDiagonalMatrix (DiagonalMatrixType &diag_H0)
 
virtual void ComputeSearchDirection (const DerivativeType &gradient, ParametersType &searchDir)
 
virtual void LineSearch (const ParametersType searchDir, double &step, ParametersType &x, MeasureType &f, DerivativeType &g)
 
void PrintSelf (std::ostream &, Indent) const override
 
 QuasiNewtonLBFGSOptimizer ()
 
virtual void SetInLineSearch (bool _arg)
 
virtual void StoreCurrentPoint (const ParametersType &step, const DerivativeType &grad_dif)
 
 ~QuasiNewtonLBFGSOptimizer () override=default
 
- Protected Member Functions inherited from itk::ScaledSingleValuedNonLinearOptimizer
virtual void GetScaledDerivative (const ParametersType &parameters, DerivativeType &derivative) const
 
virtual MeasureType GetScaledValue (const ParametersType &parameters) const
 
virtual void GetScaledValueAndDerivative (const ParametersType &parameters, MeasureType &value, DerivativeType &derivative) const
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
 ScaledSingleValuedNonLinearOptimizer ()
 
void SetCurrentPosition (const ParametersType &param) override
 
virtual void SetScaledCurrentPosition (const ParametersType &parameters)
 
 ~ScaledSingleValuedNonLinearOptimizer () override=default
 
- Protected Member Functions inherited from elastix::OptimizerBase< TElastix >
virtual bool GetNewSamplesEveryIteration () const
 
 OptimizerBase ()=default
 
virtual void SelectNewSamples ()
 
 ~OptimizerBase () override=default
 
- Protected Member Functions inherited from elastix::BaseComponentSE< TElastix >
 BaseComponentSE ()=default
 
 ~BaseComponentSE () override=default
 
- Protected Member Functions inherited from elastix::BaseComponent
 BaseComponent ()=default
 
virtual ~BaseComponent ()=default
 

Protected Attributes

LineOptimizerPointer m_LineOptimizer
 
- Protected Attributes inherited from itk::QuasiNewtonLBFGSOptimizer
unsigned int m_Bound { 0 }
 
DerivativeType m_CurrentGradient {}
 
unsigned long m_CurrentIteration { 0 }
 
double m_CurrentStepLength { 0.0 }
 
MeasureType m_CurrentValue { 0.0 }
 
bool m_InLineSearch { false }
 
unsigned int m_Point { 0 }
 
unsigned int m_PreviousPoint { 0 }
 
RhoType m_Rho {}
 
SType m_S {}
 
bool m_Stop { false }
 
StopConditionType m_StopCondition { StopConditionType::Unknown }
 
YType m_Y {}
 
- Protected Attributes inherited from itk::ScaledSingleValuedNonLinearOptimizer
ScaledCostFunctionPointer m_ScaledCostFunction {}
 
ParametersType m_ScaledCurrentPosition {}
 
- Protected Attributes inherited from elastix::BaseComponentSE< TElastix >
Configuration::ConstPointer m_Configuration {}
 
itk::WeakPointer< TElastix > m_Elastix {}
 
RegistrationTypem_Registration {}
 

Private Member Functions

void InvokeIterationEvent (const itk::EventObject &event)
 

Private Attributes

 elxOverrideGetSelfMacro
 
EventPassThroughPointer m_EventPasser
 
bool m_GenerateLineSearchIterations
 
double m_SearchDirectionMagnitude
 
bool m_StartLineSearch
 
bool m_StopIfWolfeNotSatisfied
 
bool m_WolfeIsStopCondition
 

Additional Inherited Members

- Protected Types inherited from elastix::OptimizerBase< TElastix >
using SettingsVectorType = typename std::vector<SettingsType>
 
- Static Protected Member Functions inherited from elastix::OptimizerBase< TElastix >
static void PrintSettingsVector (const SettingsVectorType &settings)
 

Member Typedef Documentation

◆ ConstPointer

template<class TElastix >
using elastix::QuasiNewtonLBFGS< TElastix >::ConstPointer = itk::SmartPointer<const Self>

Definition at line 100 of file elxQuasiNewtonLBFGS.h.

◆ EventPassThroughPointer

template<class TElastix >
using elastix::QuasiNewtonLBFGS< TElastix >::EventPassThroughPointer = typename EventPassThroughType::Pointer

Definition at line 131 of file elxQuasiNewtonLBFGS.h.

◆ EventPassThroughType

template<class TElastix >
using elastix::QuasiNewtonLBFGS< TElastix >::EventPassThroughType = itk::ReceptorMemberCommand<Self>

Definition at line 130 of file elxQuasiNewtonLBFGS.h.

◆ ITKBaseType

template<class TElastix >
using elastix::QuasiNewtonLBFGS< TElastix >::ITKBaseType = typename Superclass2::ITKBaseType

Definition at line 125 of file elxQuasiNewtonLBFGS.h.

◆ LineOptimizerPointer

template<class TElastix >
using elastix::QuasiNewtonLBFGS< TElastix >::LineOptimizerPointer = LineOptimizerType::Pointer

Definition at line 129 of file elxQuasiNewtonLBFGS.h.

◆ LineOptimizerType

template<class TElastix >
using elastix::QuasiNewtonLBFGS< TElastix >::LineOptimizerType = itk::MoreThuenteLineSearchOptimizer

Extra typedefs

Definition at line 128 of file elxQuasiNewtonLBFGS.h.

◆ Pointer

template<class TElastix >
using elastix::QuasiNewtonLBFGS< TElastix >::Pointer = itk::SmartPointer<Self>

Definition at line 99 of file elxQuasiNewtonLBFGS.h.

◆ Self

template<class TElastix >
using elastix::QuasiNewtonLBFGS< TElastix >::Self = QuasiNewtonLBFGS

Standard ITK.

Definition at line 96 of file elxQuasiNewtonLBFGS.h.

◆ Superclass1

template<class TElastix >
using elastix::QuasiNewtonLBFGS< TElastix >::Superclass1 = QuasiNewtonLBFGSOptimizer

Definition at line 97 of file elxQuasiNewtonLBFGS.h.

◆ Superclass2

template<class TElastix >
using elastix::QuasiNewtonLBFGS< TElastix >::Superclass2 = OptimizerBase<TElastix>

Definition at line 98 of file elxQuasiNewtonLBFGS.h.

Member Enumeration Documentation

◆ StopConditionType

template<class TElastix >
enum class itk::QuasiNewtonLBFGSOptimizer::StopConditionType
strong

Definition at line 86 of file itkQuasiNewtonLBFGSOptimizer.h.

Constructor & Destructor Documentation

◆ QuasiNewtonLBFGS()

template<class TElastix >
elastix::QuasiNewtonLBFGS< TElastix >::QuasiNewtonLBFGS ( )
protected

◆ ~QuasiNewtonLBFGS()

template<class TElastix >
elastix::QuasiNewtonLBFGS< TElastix >::~QuasiNewtonLBFGS ( )
overrideprotecteddefault

Member Function Documentation

◆ AfterEachIteration()

template<class TElastix >
void elastix::QuasiNewtonLBFGS< TElastix >::AfterEachIteration ( )
overridevirtual

Reimplemented from elastix::BaseComponent.

◆ AfterEachResolution()

template<class TElastix >
void elastix::QuasiNewtonLBFGS< TElastix >::AfterEachResolution ( )
overridevirtual

Reimplemented from elastix::BaseComponent.

◆ AfterRegistration()

template<class TElastix >
void elastix::QuasiNewtonLBFGS< TElastix >::AfterRegistration ( )
overridevirtual

Reimplemented from elastix::BaseComponent.

◆ BeforeEachResolution()

template<class TElastix >
void elastix::QuasiNewtonLBFGS< TElastix >::BeforeEachResolution ( )
overridevirtual

Reimplemented from elastix::BaseComponent.

◆ BeforeRegistration()

template<class TElastix >
void elastix::QuasiNewtonLBFGS< TElastix >::BeforeRegistration ( )
overridevirtual

Methods to set parameters and print output at different stages in the registration process.

Reimplemented from elastix::BaseComponent.

◆ DeterminePhase()

template<class TElastix >
virtual std::string elastix::QuasiNewtonLBFGS< TElastix >::DeterminePhase ( ) const
protectedvirtual

Generate a string, representing the phase of optimisation (line search, main)

◆ elxClassNameMacro()

template<class TElastix >
elastix::QuasiNewtonLBFGS< TElastix >::elxClassNameMacro ( "QuasiNewtonLBFGS< TElastix >" )

Name of this class. Use this name in the parameter file to select this specific optimizer.
example: (Optimizer "QuasiNewtonLBFGS")

◆ GetClassName()

template<class TElastix >
virtual const char * elastix::QuasiNewtonLBFGS< TElastix >::GetClassName ( ) const
virtual

Run-time type information (and related methods).

Reimplemented from itk::QuasiNewtonLBFGSOptimizer.

◆ GetLineSearchStopCondition()

template<class TElastix >
virtual std::string elastix::QuasiNewtonLBFGS< TElastix >::GetLineSearchStopCondition ( ) const
protectedvirtual

Convert the line search stop condition to a string

◆ GetStartLineSearch()

template<class TElastix >
virtual bool elastix::QuasiNewtonLBFGS< TElastix >::GetStartLineSearch ( ) const
virtual

◆ InvokeIterationEvent()

template<class TElastix >
void elastix::QuasiNewtonLBFGS< TElastix >::InvokeIterationEvent ( const itk::EventObject & event)
private

◆ ITK_DISALLOW_COPY_AND_MOVE()

template<class TElastix >
elastix::QuasiNewtonLBFGS< TElastix >::ITK_DISALLOW_COPY_AND_MOVE ( QuasiNewtonLBFGS< TElastix > )

◆ LineSearch()

template<class TElastix >
void elastix::QuasiNewtonLBFGS< TElastix >::LineSearch ( const ParametersType searchDir,
double & step,
ParametersType & x,
MeasureType & f,
DerivativeType & g )
overrideprotected

Call the superclass' implementation. If an ExceptionObject is caught, because the line search optimizer tried a too big step, the exception is printed, but ignored further. The optimizer stops, but elastix just goes on to the next resolution.

◆ New()

template<class TElastix >
static Pointer elastix::QuasiNewtonLBFGS< TElastix >::New ( )
static

Method for creation through the object factory.

◆ StartOptimization()

template<class TElastix >
void elastix::QuasiNewtonLBFGS< TElastix >::StartOptimization ( )
override

Check if any scales are set, and set the UseScales flag on or off; after that call the superclass' implementation

◆ TestConvergence()

template<class TElastix >
bool elastix::QuasiNewtonLBFGS< TElastix >::TestConvergence ( bool firstLineSearchDone)
overrideprotectedvirtual

Reimplement the superclass. Calls the superclass' implementation and checks if the MoreThuente line search routine has stopped with Wolfe conditions satisfied.

Reimplemented from itk::QuasiNewtonLBFGSOptimizer.

Field Documentation

◆ elxOverrideGetSelfMacro

template<class TElastix >
elastix::QuasiNewtonLBFGS< TElastix >::elxOverrideGetSelfMacro
private

Definition at line 187 of file elxQuasiNewtonLBFGS.h.

◆ m_EventPasser

template<class TElastix >
EventPassThroughPointer elastix::QuasiNewtonLBFGS< TElastix >::m_EventPasser
private

Definition at line 192 of file elxQuasiNewtonLBFGS.h.

◆ m_GenerateLineSearchIterations

template<class TElastix >
bool elastix::QuasiNewtonLBFGS< TElastix >::m_GenerateLineSearchIterations
private

Definition at line 195 of file elxQuasiNewtonLBFGS.h.

◆ m_LineOptimizer

template<class TElastix >
LineOptimizerPointer elastix::QuasiNewtonLBFGS< TElastix >::m_LineOptimizer
protected

Definition at line 161 of file elxQuasiNewtonLBFGS.h.

◆ m_SearchDirectionMagnitude

template<class TElastix >
double elastix::QuasiNewtonLBFGS< TElastix >::m_SearchDirectionMagnitude
private

Definition at line 193 of file elxQuasiNewtonLBFGS.h.

◆ m_StartLineSearch

template<class TElastix >
bool elastix::QuasiNewtonLBFGS< TElastix >::m_StartLineSearch
private

Definition at line 194 of file elxQuasiNewtonLBFGS.h.

◆ m_StopIfWolfeNotSatisfied

template<class TElastix >
bool elastix::QuasiNewtonLBFGS< TElastix >::m_StopIfWolfeNotSatisfied
private

Definition at line 196 of file elxQuasiNewtonLBFGS.h.

◆ m_WolfeIsStopCondition

template<class TElastix >
bool elastix::QuasiNewtonLBFGS< TElastix >::m_WolfeIsStopCondition
private

Definition at line 197 of file elxQuasiNewtonLBFGS.h.



Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo