go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
itk::GenericConjugateGradientOptimizer Class Reference

#include <itkGenericConjugateGradientOptimizer.h>

Detailed Description

A set of conjugate gradient algorithms.

The steplength is determined at each iteration by means of a line search routine. The itk::MoreThuenteLineSearchOptimizer works well.

Definition at line 40 of file itkGenericConjugateGradientOptimizer.h.

Inheritance diagram for itk::GenericConjugateGradientOptimizer:
Inheritance graph
[legend]

Public Types

typedef std::map< BetaDefinitionType, ComputeBetaFunctionTypeBetaDefinitionMapType
 
typedef std::string BetaDefinitionType
 
typedef double(Self::* ComputeBetaFunctionType) (const DerivativeType &, const DerivativeType &, const ParametersType &)
 
typedef SmartPointer< const SelfConstPointer
 
typedef Superclass::CostFunctionType CostFunctionType
 
typedef Superclass::DerivativeType DerivativeType
 
typedef LineSearchOptimizerType::Pointer LineSearchOptimizerPointer
 
typedef LineSearchOptimizer LineSearchOptimizerType
 
typedef Superclass::MeasureType MeasureType
 
typedef Superclass::ParametersType ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef Superclass::ScaledCostFunctionType ScaledCostFunctionType
 
typedef Superclass::ScalesType ScalesType
 
typedef GenericConjugateGradientOptimizer Self
 
enum  StopConditionType {
  MetricError, LineSearchError, MaximumNumberOfIterations, GradientMagnitudeTolerance,
  ValueTolerance, InfiniteBeta, Unknown
}
 
typedef ScaledSingleValuedNonLinearOptimizer Superclass
 
- Public Types inherited from itk::ScaledSingleValuedNonLinearOptimizer
typedef SmartPointer< const SelfConstPointer
 
typedef Superclass::CostFunctionType CostFunctionType
 
typedef Superclass::DerivativeType DerivativeType
 
typedef Superclass::MeasureType MeasureType
 
typedef Superclass::ParametersType ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef ScaledCostFunctionType::Pointer ScaledCostFunctionPointer
 
typedef ScaledSingleValuedCostFunction ScaledCostFunctionType
 
typedef NonLinearOptimizer::ScalesType ScalesType
 
typedef ScaledSingleValuedNonLinearOptimizer Self
 
typedef SingleValuedNonLinearOptimizer Superclass
 

Public Member Functions

virtual const BetaDefinitionTypeGetBetaDefinition ()
 
virtual const char * GetClassName () const
 
virtual const DerivativeTypeGetCurrentGradient ()
 
virtual unsigned long GetCurrentIteration () const
 
virtual double GetCurrentStepLength () const
 
virtual MeasureType GetCurrentValue () const
 
virtual double GetGradientMagnitudeTolerance () const
 
virtual bool GetInLineSearch () const
 
virtual LineSearchOptimizerTypeGetLineSearchOptimizer ()
 
virtual unsigned long GetMaximumNumberOfIterations () const
 
virtual unsigned long GetMaxNrOfItWithoutImprovement () const
 
virtual const StopConditionTypeGetStopCondition ()
 
virtual double GetValueTolerance () const
 
virtual void ResumeOptimization (void)
 
virtual void SetBetaDefinition (const BetaDefinitionType &arg)
 
virtual void SetGradientMagnitudeTolerance (double _arg)
 
virtual void SetLineSearchOptimizer (LineSearchOptimizerType *_arg)
 
virtual void SetMaximumNumberOfIterations (unsigned long _arg)
 
virtual void SetMaxNrOfItWithoutImprovement (unsigned long arg)
 
virtual void SetValueTolerance (double _arg)
 
virtual void StartOptimization (void)
 
virtual void StopOptimization (void)
 
- Public Member Functions inherited from itk::ScaledSingleValuedNonLinearOptimizer
virtual const ParametersTypeGetCurrentPosition (void) const
 
virtual bool GetMaximize () const
 
virtual const ScaledCostFunctionTypeGetScaledCostFunction ()
 
virtual const ParametersTypeGetScaledCurrentPosition ()
 
bool GetUseScales (void) const
 
virtual void InitializeScales (void)
 
virtual void MaximizeOff ()
 
virtual void MaximizeOn ()
 
virtual void SetCostFunction (CostFunctionType *costFunction)
 
virtual void SetMaximize (bool _arg)
 
virtual void SetUseScales (bool arg)
 

Static Public Member Functions

static Pointer New ()
 
- Static Public Member Functions inherited from itk::ScaledSingleValuedNonLinearOptimizer
static Pointer New ()
 

Protected Member Functions

virtual void AddBetaDefinition (const BetaDefinitionType &name, ComputeBetaFunctionType function)
 
virtual double ComputeBeta (const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
 
double ComputeBetaDY (const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
 
double ComputeBetaDYHS (const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
 
double ComputeBetaFR (const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
 
double ComputeBetaHS (const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
 
double ComputeBetaPR (const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
 
double ComputeBetaSD (const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
 
virtual void ComputeSearchDirection (const DerivativeType &previousGradient, const DerivativeType &gradient, ParametersType &searchDir)
 
 GenericConjugateGradientOptimizer ()
 
virtual void LineSearch (const ParametersType searchDir, double &step, ParametersType &x, MeasureType &f, DerivativeType &g)
 
void PrintSelf (std::ostream &os, Indent indent) const
 
virtual void SetInLineSearch (bool _arg)
 
virtual bool TestConvergence (bool firstLineSearchDone)
 
virtual ~GenericConjugateGradientOptimizer ()
 
- 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
 
 ScaledSingleValuedNonLinearOptimizer ()
 
virtual void SetCurrentPosition (const ParametersType &param)
 
virtual void SetScaledCurrentPosition (const ParametersType &parameters)
 
virtual ~ScaledSingleValuedNonLinearOptimizer ()
 

Protected Attributes

BetaDefinitionType m_BetaDefinition
 
BetaDefinitionMapType m_BetaDefinitionMap
 
DerivativeType m_CurrentGradient
 
unsigned long m_CurrentIteration
 
double m_CurrentStepLength
 
MeasureType m_CurrentValue
 
bool m_InLineSearch
 
bool m_PreviousGradientAndSearchDirValid
 
bool m_Stop
 
StopConditionType m_StopCondition
 
bool m_UseDefaultMaxNrOfItWithoutImprovement
 
- Protected Attributes inherited from itk::ScaledSingleValuedNonLinearOptimizer
ScaledCostFunctionPointer m_ScaledCostFunction
 
ParametersType m_ScaledCurrentPosition
 

Private Member Functions

 GenericConjugateGradientOptimizer (const Self &)
 
void operator= (const Self &)
 

Private Attributes

double m_GradientMagnitudeTolerance
 
LineSearchOptimizerPointer m_LineSearchOptimizer
 
unsigned long m_MaximumNumberOfIterations
 
unsigned long m_MaxNrOfItWithoutImprovement
 
double m_ValueTolerance
 

Member Typedef Documentation

Definition at line 72 of file itkGenericConjugateGradientOptimizer.h.

Definition at line 70 of file itkGenericConjugateGradientOptimizer.h.

typedef double(Self::* itk::GenericConjugateGradientOptimizer::ComputeBetaFunctionType) (const DerivativeType &, const DerivativeType &, const ParametersType &)

Typedef for a function that computes $\beta$, given the previousGradient, the current gradient, and the previous search direction

Definition at line 67 of file itkGenericConjugateGradientOptimizer.h.

Definition at line 48 of file itkGenericConjugateGradientOptimizer.h.

typedef Superclass::CostFunctionType itk::GenericConjugateGradientOptimizer::CostFunctionType

Definition at line 56 of file itkGenericConjugateGradientOptimizer.h.

Definition at line 55 of file itkGenericConjugateGradientOptimizer.h.

Definition at line 62 of file itkGenericConjugateGradientOptimizer.h.

Definition at line 61 of file itkGenericConjugateGradientOptimizer.h.

Definition at line 58 of file itkGenericConjugateGradientOptimizer.h.

typedef Superclass::ParametersType itk::GenericConjugateGradientOptimizer::ParametersType

Definition at line 52 of file itkGenericConjugateGradientOptimizer.h.

Definition at line 47 of file itkGenericConjugateGradientOptimizer.h.

typedef Superclass::ScaledCostFunctionType itk::GenericConjugateGradientOptimizer::ScaledCostFunctionType

Definition at line 57 of file itkGenericConjugateGradientOptimizer.h.

Definition at line 59 of file itkGenericConjugateGradientOptimizer.h.

Definition at line 45 of file itkGenericConjugateGradientOptimizer.h.

Definition at line 46 of file itkGenericConjugateGradientOptimizer.h.

Member Enumeration Documentation

Enumerator
MetricError 
LineSearchError 
MaximumNumberOfIterations 
GradientMagnitudeTolerance 
ValueTolerance 
InfiniteBeta 
Unknown 

Definition at line 74 of file itkGenericConjugateGradientOptimizer.h.

Constructor & Destructor Documentation

itk::GenericConjugateGradientOptimizer::GenericConjugateGradientOptimizer ( )
protected
virtual itk::GenericConjugateGradientOptimizer::~GenericConjugateGradientOptimizer ( )
inlineprotectedvirtual

Definition at line 141 of file itkGenericConjugateGradientOptimizer.h.

itk::GenericConjugateGradientOptimizer::GenericConjugateGradientOptimizer ( const Self )
private

Member Function Documentation

virtual void itk::GenericConjugateGradientOptimizer::AddBetaDefinition ( const BetaDefinitionType name,
ComputeBetaFunctionType  function 
)
protectedvirtual

Function to add a new beta definition. The first argument should be a name via which a user can select this $\beta$ definition. The second argument is a pointer to a method that computes $\beta$. Called in the constructor of this class, and possibly by subclasses.

virtual double itk::GenericConjugateGradientOptimizer::ComputeBeta ( const DerivativeType previousGradient,
const DerivativeType gradient,
const ParametersType previousSearchDir 
)
protectedvirtual

Compute $\beta$ according to the user set $\beta$-definition

double itk::GenericConjugateGradientOptimizer::ComputeBetaDY ( const DerivativeType previousGradient,
const DerivativeType gradient,
const ParametersType previousSearchDir 
)
protected

"DaiYuan"

double itk::GenericConjugateGradientOptimizer::ComputeBetaDYHS ( const DerivativeType previousGradient,
const DerivativeType gradient,
const ParametersType previousSearchDir 
)
protected

"DaiYuanHestenesStiefel"

double itk::GenericConjugateGradientOptimizer::ComputeBetaFR ( const DerivativeType previousGradient,
const DerivativeType gradient,
const ParametersType previousSearchDir 
)
protected

"FletcherReeves"

double itk::GenericConjugateGradientOptimizer::ComputeBetaHS ( const DerivativeType previousGradient,
const DerivativeType gradient,
const ParametersType previousSearchDir 
)
protected

"HestenesStiefel"

double itk::GenericConjugateGradientOptimizer::ComputeBetaPR ( const DerivativeType previousGradient,
const DerivativeType gradient,
const ParametersType previousSearchDir 
)
protected

"PolakRibiere"

double itk::GenericConjugateGradientOptimizer::ComputeBetaSD ( const DerivativeType previousGradient,
const DerivativeType gradient,
const ParametersType previousSearchDir 
)
protected

Different definitions of $\beta$ "SteepestDescent: beta=0

virtual void itk::GenericConjugateGradientOptimizer::ComputeSearchDirection ( const DerivativeType previousGradient,
const DerivativeType gradient,
ParametersType searchDir 
)
protectedvirtual

Compute the search direction:

\[ d_{k} = - g_{k} + \beta_{k} d_{k-1} \]

In the first iteration the search direction is computed as:

\[ d_{0} = - g_{0} \]

On calling, searchDir should equal $d_{k-1}$. On return searchDir equals $d_{k}$.

virtual const BetaDefinitionType& itk::GenericConjugateGradientOptimizer::GetBetaDefinition ( )
virtual
virtual const char* itk::GenericConjugateGradientOptimizer::GetClassName ( ) const
virtual
virtual const DerivativeType& itk::GenericConjugateGradientOptimizer::GetCurrentGradient ( )
virtual
virtual unsigned long itk::GenericConjugateGradientOptimizer::GetCurrentIteration ( ) const
virtual

Get information about optimization process:

virtual double itk::GenericConjugateGradientOptimizer::GetCurrentStepLength ( ) const
virtual
virtual MeasureType itk::GenericConjugateGradientOptimizer::GetCurrentValue ( ) const
virtual
virtual double itk::GenericConjugateGradientOptimizer::GetGradientMagnitudeTolerance ( ) const
virtual

Setting: the mininum gradient magnitude. By default 1e-5.

The optimizer stops when: $ \|CurrentGradient\| < GradientMagnitudeTolerance * \max(1, \|CurrentPosition\| ) $

virtual bool itk::GenericConjugateGradientOptimizer::GetInLineSearch ( ) const
virtual
virtual LineSearchOptimizerType* itk::GenericConjugateGradientOptimizer::GetLineSearchOptimizer ( )
virtual
virtual unsigned long itk::GenericConjugateGradientOptimizer::GetMaximumNumberOfIterations ( ) const
virtual

Setting: the maximum number of iterations

virtual unsigned long itk::GenericConjugateGradientOptimizer::GetMaxNrOfItWithoutImprovement ( ) const
virtual
virtual const StopConditionType& itk::GenericConjugateGradientOptimizer::GetStopCondition ( )
virtual
virtual double itk::GenericConjugateGradientOptimizer::GetValueTolerance ( ) const
virtual

Setting: a stopping criterion, the value tolerance. By default 1e-5.

The optimizer stops when

\[ 2.0 * | f_k - f_{k-1} | \le ValueTolerance * ( |f_k| + |f_{k-1}| + 1e-20 ) \]

is satisfied MaxNrOfItWithoutImprovement times in a row.

virtual void itk::GenericConjugateGradientOptimizer::LineSearch ( const ParametersType  searchDir,
double step,
ParametersType x,
MeasureType f,
DerivativeType g 
)
protectedvirtual

Perform a line search along the search direction. On calling, $x, f$, and $g$ should contain the current position, the cost function value at this position, and the derivative. On return the step, $x$ (new position), $f$ (value at $x$), and $g$ (derivative at $x$) are updated.

Reimplemented in elastix::ConjugateGradient< TElastix >.

static Pointer itk::GenericConjugateGradientOptimizer::New ( )
static
void itk::GenericConjugateGradientOptimizer::operator= ( const Self )
private
void itk::GenericConjugateGradientOptimizer::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
protected
virtual void itk::GenericConjugateGradientOptimizer::ResumeOptimization ( void  )
virtual
virtual void itk::GenericConjugateGradientOptimizer::SetBetaDefinition ( const BetaDefinitionType arg)
virtual

Setting: the definition of $\beta$, by default "DaiYuanHestenesStiefel"

virtual void itk::GenericConjugateGradientOptimizer::SetGradientMagnitudeTolerance ( double  _arg)
virtual
virtual void itk::GenericConjugateGradientOptimizer::SetInLineSearch ( bool  _arg)
protectedvirtual
virtual void itk::GenericConjugateGradientOptimizer::SetLineSearchOptimizer ( LineSearchOptimizerType _arg)
virtual

Setting: the line search optimizer

virtual void itk::GenericConjugateGradientOptimizer::SetMaximumNumberOfIterations ( unsigned long  _arg)
virtual
virtual void itk::GenericConjugateGradientOptimizer::SetMaxNrOfItWithoutImprovement ( unsigned long  arg)
virtual

Setting: the maximum number of iterations in a row that satisfy the value tolerance criterion. By default (if never set) equal to the number of parameters.

virtual void itk::GenericConjugateGradientOptimizer::SetValueTolerance ( double  _arg)
virtual
virtual void itk::GenericConjugateGradientOptimizer::StartOptimization ( void  )
virtual
virtual void itk::GenericConjugateGradientOptimizer::StopOptimization ( void  )
virtual
virtual bool itk::GenericConjugateGradientOptimizer::TestConvergence ( bool  firstLineSearchDone)
protectedvirtual

Check if convergence has occured; The firstLineSearchDone bool allows the implementation of TestConvergence to decide to skip a few convergence checks when no line search has performed yet (so, before the actual optimisation begins)

Reimplemented in elastix::ConjugateGradient< TElastix >.

Field Documentation

BetaDefinitionType itk::GenericConjugateGradientOptimizer::m_BetaDefinition
protected

The name of the BetaDefinition

Definition at line 167 of file itkGenericConjugateGradientOptimizer.h.

BetaDefinitionMapType itk::GenericConjugateGradientOptimizer::m_BetaDefinitionMap
protected

A mapping that links the names of the BetaDefinitions to functions that compute $\beta$.

Definition at line 171 of file itkGenericConjugateGradientOptimizer.h.

DerivativeType itk::GenericConjugateGradientOptimizer::m_CurrentGradient
protected

Definition at line 145 of file itkGenericConjugateGradientOptimizer.h.

unsigned long itk::GenericConjugateGradientOptimizer::m_CurrentIteration
protected

Definition at line 147 of file itkGenericConjugateGradientOptimizer.h.

double itk::GenericConjugateGradientOptimizer::m_CurrentStepLength
protected

Definition at line 150 of file itkGenericConjugateGradientOptimizer.h.

MeasureType itk::GenericConjugateGradientOptimizer::m_CurrentValue
protected

Definition at line 146 of file itkGenericConjugateGradientOptimizer.h.

double itk::GenericConjugateGradientOptimizer::m_GradientMagnitudeTolerance
private

Definition at line 265 of file itkGenericConjugateGradientOptimizer.h.

bool itk::GenericConjugateGradientOptimizer::m_InLineSearch
protected

Is true when the LineSearchOptimizer has been started.

Definition at line 157 of file itkGenericConjugateGradientOptimizer.h.

LineSearchOptimizerPointer itk::GenericConjugateGradientOptimizer::m_LineSearchOptimizer
private

Definition at line 268 of file itkGenericConjugateGradientOptimizer.h.

unsigned long itk::GenericConjugateGradientOptimizer::m_MaximumNumberOfIterations
private

Definition at line 263 of file itkGenericConjugateGradientOptimizer.h.

unsigned long itk::GenericConjugateGradientOptimizer::m_MaxNrOfItWithoutImprovement
private

Definition at line 266 of file itkGenericConjugateGradientOptimizer.h.

bool itk::GenericConjugateGradientOptimizer::m_PreviousGradientAndSearchDirValid
protected

Flag that says if the previous gradient and search direction are known. Typically 'true' at the start of optimization, or when a stopped optimisation is resumed (in the latter case the previous gradient and search direction may of course still be valid, but to be safe it is assumed that they are not).

Definition at line 158 of file itkGenericConjugateGradientOptimizer.h.

bool itk::GenericConjugateGradientOptimizer::m_Stop
protected

Definition at line 149 of file itkGenericConjugateGradientOptimizer.h.

StopConditionType itk::GenericConjugateGradientOptimizer::m_StopCondition
protected

Definition at line 148 of file itkGenericConjugateGradientOptimizer.h.

bool itk::GenericConjugateGradientOptimizer::m_UseDefaultMaxNrOfItWithoutImprovement
protected

Flag that is true as long as the method SetMaxNrOfItWithoutImprovement is never called

Definition at line 154 of file itkGenericConjugateGradientOptimizer.h.

double itk::GenericConjugateGradientOptimizer::m_ValueTolerance
private

Definition at line 264 of file itkGenericConjugateGradientOptimizer.h.



Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo