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

#include <elxConjugateGradientFRPR.h>

Detailed Description

template<typename TElastix>
class elastix::ConjugateGradientFRPR< TElastix >

The ConjugateGradientFRPR class.

This component is based on the itkFRPROptimizer. This is a Fletcher-Reeves conjugate gradient optimizer, in combination with an exact (dBrent) line search, based on the description in Numerical Recipes in C++

This optimizer support the NewSamplesEveryIteration option. It requests new samples upon every derivative evaluation, but actually this makes no sense for a conjugate gradient optimizer. So, think twice before using it.

Note
It prints out no stop conditions, since the itk superclass does not generate them.
It considers line search iterations as elastix iterations.
Parameters

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

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

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

StepLength: Set the length of the initial step tried by the line seach, used to bracket the minimum.
example: (StepLength 2.0 1.0 0.5)
Default value: 1.0.

ValueTolerance: Convergence is declared if:

\‍[ 2.0 * | f_2 - f_1 | \le  ValueTolerance * ( | f_1 | + | f_2 | ) \‍]

example: (ValueTolerance 0.001 0.00001 0.000001)
Default value: 0.00001.

Parameters
LineSearchStepTolerance: Convergence of the line search is declared if:

\‍[ | x - x_m | \le tol * |x| - ( b - a ) / 2, \‍]

where:
$x$ = current mininum of the gain
$a, b$ = current brackets around the minimum
$x_m = (a+b)/2 $
example: (LineSearchStepTolerance 0.001 0.00001 0.000001)
Default value: 0.00001.

Definition at line 74 of file elxConjugateGradientFRPR.h.

Inheritance diagram for elastix::ConjugateGradientFRPR< TElastix >:

Public Types

using ConstPointer = itk::SmartPointer<const Self>
using DerivativeType = SingleValuedNonLinearOptimizer::DerivativeType
using ITKBaseType = typename Superclass2::ITKBaseType
using Pointer = itk::SmartPointer<Self>
using Self = ConjugateGradientFRPR
using Superclass1 = itk::FRPROptimizer
using Superclass2 = OptimizerBase<TElastix>
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 ("ConjugateGradientFRPR")
virtual const doubleGetCurrentDerivativeMagnitude ()
virtual const doubleGetCurrentSearchDirectionMagnitude ()
virtual const doubleGetCurrentStepLength ()
virtual bool GetLineBracketing () const
virtual bool GetLineOptimizing () const
 ITK_DISALLOW_COPY_AND_MOVE (ConjugateGradientFRPR)
 itkOverrideGetNameOfClassMacro (ConjugateGradientFRPR)
void SetInitialPosition (const ParametersType &param) override
Public Member Functions inherited from elastix::OptimizerBase< TElastix >
void AfterRegistrationBase () override
void BeforeEachResolutionBase () override
ITKBaseTypeGetAsITKBaseType ()
const ITKBaseTypeGetAsITKBaseType () const
 ITK_DISALLOW_COPY_AND_MOVE (OptimizerBase)
 itkOverrideGetNameOfClassMacro (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)
itk::Statistics::MersenneTwisterRandomVariateGenerator & GetRandomVariateGenerator ()
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)
 itkVirtualGetNameOfClassMacro (BaseComponent)
void SetComponentLabel (const char *label, unsigned int idx)

Static Public Member Functions

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

void BracketedLineOptimize (double ax, double bx, double cx, double fa, double fb, double fc, double *extX, double *extVal, ParametersType &tempCoord) override
 ConjugateGradientFRPR ()
void GetValueAndDerivative (ParametersType &p, double *val, ParametersType *xi) override
void LineBracket (double *ax, double *bx, double *cx, double *fa, double *fb, double *fc, ParametersType &tempCoord) override
void LineOptimize (ParametersType *p, ParametersType &xi, double *val, ParametersType &tempCoord) override
virtual void SetLineBracketing (bool _arg)
virtual void SetLineOptimizing (bool _arg)
 ~ConjugateGradientFRPR () 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

double m_CurrentDerivativeMagnitude
double m_CurrentSearchDirectionMagnitude
double m_CurrentStepLength
Protected Attributes inherited from elastix::BaseComponentSE< TElastix >
Configuration::ConstPointer m_Configuration {}
itk::WeakPointer< TElastix > m_Elastix {}
RegistrationTypem_Registration {}

Private Member Functions

const char * DeterminePhase () const

Private Attributes

 elxOverrideGetSelfMacro
bool m_LineBracketing
bool m_LineOptimizing

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<typename TElastix>
using elastix::ConjugateGradientFRPR< TElastix >::ConstPointer = itk::SmartPointer<const Self>

Definition at line 86 of file elxConjugateGradientFRPR.h.

◆ DerivativeType

template<typename TElastix>
using elastix::ConjugateGradientFRPR< TElastix >::DerivativeType = SingleValuedNonLinearOptimizer::DerivativeType

Definition at line 103 of file elxConjugateGradientFRPR.h.

◆ ITKBaseType

template<typename TElastix>
using elastix::ConjugateGradientFRPR< TElastix >::ITKBaseType = typename Superclass2::ITKBaseType

Definition at line 108 of file elxConjugateGradientFRPR.h.

◆ Pointer

template<typename TElastix>
using elastix::ConjugateGradientFRPR< TElastix >::Pointer = itk::SmartPointer<Self>

Definition at line 85 of file elxConjugateGradientFRPR.h.

◆ Self

template<typename TElastix>
using elastix::ConjugateGradientFRPR< TElastix >::Self = ConjugateGradientFRPR

Standard ITK.

Definition at line 82 of file elxConjugateGradientFRPR.h.

◆ Superclass1

template<typename TElastix>
using elastix::ConjugateGradientFRPR< TElastix >::Superclass1 = itk::FRPROptimizer

Definition at line 83 of file elxConjugateGradientFRPR.h.

◆ Superclass2

template<typename TElastix>
using elastix::ConjugateGradientFRPR< TElastix >::Superclass2 = OptimizerBase<TElastix>

Definition at line 84 of file elxConjugateGradientFRPR.h.

Constructor & Destructor Documentation

◆ ConjugateGradientFRPR()

template<typename TElastix>
elastix::ConjugateGradientFRPR< TElastix >::ConjugateGradientFRPR ( )
protected

◆ ~ConjugateGradientFRPR()

template<typename TElastix>
elastix::ConjugateGradientFRPR< TElastix >::~ConjugateGradientFRPR ( )
overrideprotecteddefault

Member Function Documentation

◆ AfterEachIteration()

template<typename TElastix>
void elastix::ConjugateGradientFRPR< TElastix >::AfterEachIteration ( )
overridevirtual

Reimplemented from elastix::BaseComponent.

◆ AfterEachResolution()

template<typename TElastix>
void elastix::ConjugateGradientFRPR< TElastix >::AfterEachResolution ( )
overridevirtual

Reimplemented from elastix::BaseComponent.

◆ AfterRegistration()

template<typename TElastix>
void elastix::ConjugateGradientFRPR< TElastix >::AfterRegistration ( )
overridevirtual

Reimplemented from elastix::BaseComponent.

◆ BeforeEachResolution()

template<typename TElastix>
void elastix::ConjugateGradientFRPR< TElastix >::BeforeEachResolution ( )
overridevirtual

Reimplemented from elastix::BaseComponent.

◆ BeforeRegistration()

template<typename TElastix>
void elastix::ConjugateGradientFRPR< TElastix >::BeforeRegistration ( )
overridevirtual

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

Reimplemented from elastix::BaseComponent.

◆ BracketedLineOptimize()

template<typename TElastix>
void elastix::ConjugateGradientFRPR< TElastix >::BracketedLineOptimize ( double ax,
double bx,
double cx,
double fa,
double fb,
double fc,
double * extX,
double * extVal,
ParametersType & tempCoord )
overrideprotected

Given a bracketing triple of points and their function values, returns a bounded extreme. These values are in parameter space, along the current line and wrt the current origin set via SetLine. Optimization terminates based on MaximumIteration, StepTolerance, or ValueTolerance. Implemented as Brent line optimers from NRC.

This implementation sets the LineOptimizing flag to 'true', calls the the superclass's implementation, stores extX as the current step length, and sets the LineOptimizing flag to 'false' again.

◆ DeterminePhase()

template<typename TElastix>
const char * elastix::ConjugateGradientFRPR< TElastix >::DeterminePhase ( ) const
private

◆ elxClassNameMacro()

template<typename TElastix>
elastix::ConjugateGradientFRPR< TElastix >::elxClassNameMacro ( "ConjugateGradientFRPR< TElastix >" )

Name of this class.

◆ GetCurrentDerivativeMagnitude()

template<typename TElastix>
virtual const double & elastix::ConjugateGradientFRPR< TElastix >::GetCurrentDerivativeMagnitude ( )
virtual

Return the magnitude of the cached derivative

◆ GetCurrentSearchDirectionMagnitude()

template<typename TElastix>
virtual const double & elastix::ConjugateGradientFRPR< TElastix >::GetCurrentSearchDirectionMagnitude ( )
virtual

Get the magnitude of the line search direction

◆ GetCurrentStepLength()

template<typename TElastix>
virtual const double & elastix::ConjugateGradientFRPR< TElastix >::GetCurrentStepLength ( )
virtual

Get the current gain

◆ GetLineBracketing()

template<typename TElastix>
virtual bool elastix::ConjugateGradientFRPR< TElastix >::GetLineBracketing ( ) const
virtual

◆ GetLineOptimizing()

template<typename TElastix>
virtual bool elastix::ConjugateGradientFRPR< TElastix >::GetLineOptimizing ( ) const
virtual

Check if the optimizer is currently Bracketing the minimum, or is optimizing along a line

◆ GetValueAndDerivative()

template<typename TElastix>
void elastix::ConjugateGradientFRPR< TElastix >::GetValueAndDerivative ( ParametersType & p,
double * val,
ParametersType * xi )
overrideprotected

Get the value of the n-dimensional cost function at this scalar step distance along the current line direction from the current line origin. Line origin and distances are set via SetLine.

This implementation calls the Superclass' implementation and caches the computed derivative's magnitude. Besides, it invokes the SelectNewSamples method.

◆ ITK_DISALLOW_COPY_AND_MOVE()

template<typename TElastix>
elastix::ConjugateGradientFRPR< TElastix >::ITK_DISALLOW_COPY_AND_MOVE ( ConjugateGradientFRPR< TElastix > )

◆ itkOverrideGetNameOfClassMacro()

template<typename TElastix>
elastix::ConjugateGradientFRPR< TElastix >::itkOverrideGetNameOfClassMacro ( ConjugateGradientFRPR< TElastix > )

Run-time type information (and related methods).

◆ LineBracket()

template<typename TElastix>
void elastix::ConjugateGradientFRPR< TElastix >::LineBracket ( double * ax,
double * bx,
double * cx,
double * fa,
double * fb,
double * fc,
ParametersType & tempCoord )
overrideprotected

The LineBracket routine from NRC. Uses current origin and line direction (from SetLine) to find a triple of points (ax, bx, cx) that bracket the extreme "near" the origin. Search first considers the point StepLength distance from ax. IMPORTANT: The value of ax and the value of the function at ax (i.e., fa), must both be provided to this function.

This implementation sets the LineBracketing flag to 'true', calls the superclass' implementation, stores bx as the current step length, invokes an iteration event, and sets the LineBracketing flag to 'false'

◆ LineOptimize()

template<typename TElastix>
void elastix::ConjugateGradientFRPR< TElastix >::LineOptimize ( ParametersType * p,
ParametersType & xi,
double * val,
ParametersType & tempCoord )
overrideprotected

store the line search direction's (xi) magnitude and call the superclass' implementation.

◆ New()

template<typename TElastix>
Pointer elastix::ConjugateGradientFRPR< TElastix >::New ( )
static

Method for creation through the object factory.

◆ SetInitialPosition()

template<typename TElastix>
void elastix::ConjugateGradientFRPR< TElastix >::SetInitialPosition ( const ParametersType & param)
override

Override the SetInitialPosition.

◆ SetLineBracketing()

template<typename TElastix>
virtual void elastix::ConjugateGradientFRPR< TElastix >::SetLineBracketing ( bool _arg)
protectedvirtual

◆ SetLineOptimizing()

template<typename TElastix>
virtual void elastix::ConjugateGradientFRPR< TElastix >::SetLineOptimizing ( bool _arg)
protectedvirtual

Set if the optimizer is currently bracketing the minimum, or is optimizing along a line

Member Data Documentation

◆ elxOverrideGetSelfMacro

template<typename TElastix>
elastix::ConjugateGradientFRPR< TElastix >::elxOverrideGetSelfMacro
private

Definition at line 215 of file elxConjugateGradientFRPR.h.

◆ m_CurrentDerivativeMagnitude

template<typename TElastix>
double elastix::ConjugateGradientFRPR< TElastix >::m_CurrentDerivativeMagnitude
protected

To store the latest computed derivative's magnitude

Definition at line 150 of file elxConjugateGradientFRPR.h.

◆ m_CurrentSearchDirectionMagnitude

template<typename TElastix>
double elastix::ConjugateGradientFRPR< TElastix >::m_CurrentSearchDirectionMagnitude
protected

Variable to store the line search direction magnitude

Definition at line 153 of file elxConjugateGradientFRPR.h.

◆ m_CurrentStepLength

template<typename TElastix>
double elastix::ConjugateGradientFRPR< TElastix >::m_CurrentStepLength
protected

the current gain

Definition at line 156 of file elxConjugateGradientFRPR.h.

◆ m_LineBracketing

template<typename TElastix>
bool elastix::ConjugateGradientFRPR< TElastix >::m_LineBracketing
private

Definition at line 218 of file elxConjugateGradientFRPR.h.

◆ m_LineOptimizing

template<typename TElastix>
bool elastix::ConjugateGradientFRPR< TElastix >::m_LineOptimizing
private

Definition at line 217 of file elxConjugateGradientFRPR.h.



Generated on 26-02-2026 for elastix by doxygen 1.16.1 (669aeeefca743c148e2d935b3d3c69535c7491e6) elastix logo