ITK  6.0.0
Insight Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members

#include <itkPowellOptimizer.h>

Detailed Description

Implements Powell optimization using Brent line search.

The code in this class was adapted from the Wikipedia and the netlib.org zeroin function.

https://www.netlib.org/go/zeroin.f https://en.wikipedia.org/wiki/Brent_method https://en.wikipedia.org/wiki/Golden_section_search

This optimizer needs a cost function. Partial derivatives of that function are not required.

For an N-dimensional parameter space, each iteration minimizes(maximizes) the function in N (initially orthogonal) directions. Typically only 2-5 iterations are required. If gradients are available, consider a conjugate gradient line search strategy.

The SetStepLength determines the initial distance to step in a line direction when bounding the minimum (using bracketing triple spaced using a golden search strategy).

The StepTolerance terminates optimization when the parameter values are known to be within this (scaled) distance of the local extreme.

The ValueTolerance terminates optimization when the cost function values at the current parameters and at the local extreme are likely (within a second order approximation) to be within this is tolerance.

Definition at line 62 of file itkPowellOptimizer.h.

+ Inheritance diagram for itk::PowellOptimizer:
+ Collaboration diagram for itk::PowellOptimizer:

Public Types

using ConstPointer = SmartPointer< const Self >
 
using CostFunctionPointer = CostFunctionType::Pointer
 
using CostFunctionType = SingleValuedCostFunction
 
using ParametersType = SingleValuedNonLinearOptimizer::ParametersType
 
using Pointer = SmartPointer< Self >
 
using Self = PowellOptimizer
 
using Superclass = SingleValuedNonLinearOptimizer
 
- Public Types inherited from itk::SingleValuedNonLinearOptimizer
using ConstPointer = SmartPointer< const Self >
 
using CostFunctionPointer = CostFunctionType::Pointer
 
using CostFunctionType = SingleValuedCostFunction
 
using DerivativeType = CostFunctionType::DerivativeType
 
using MeasureType = CostFunctionType::MeasureType
 
using ParametersType = Superclass::ParametersType
 
using Pointer = SmartPointer< Self >
 
using Self = SingleValuedNonLinearOptimizer
 
using Superclass = NonLinearOptimizer
 
- Public Types inherited from itk::NonLinearOptimizer
using ConstPointer = SmartPointer< const Self >
 
using ParametersType = Superclass::ParametersType
 
using Pointer = SmartPointer< Self >
 
using ScalesType = Superclass::ScalesType
 
using Self = NonLinearOptimizer
 
using Superclass = Optimizer
 
- Public Types inherited from itk::Optimizer
using ConstPointer = SmartPointer< const Self >
 
using ParametersType = OptimizerParameters< double >
 
using Pointer = SmartPointer< Self >
 
using ScalesType = Array< double >
 
using Self = Optimizer
 
using Superclass = Object
 
- Public Types inherited from itk::Object
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = Object
 
using Superclass = LightObject
 
- Public Types inherited from itk::LightObject
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = LightObject
 

Public Member Functions

virtual const bool & GetCatchGetValueException () const
 
virtual const unsigned int & GetCurrentIteration () const
 
virtual const unsigned int & GetCurrentLineIteration () const
 
virtual const double & GetMetricWorstPossibleValue () const
 
const char * GetNameOfClass () const override
 
std::string GetStopConditionDescription () const override
 
virtual void SetCatchGetValueException (bool _arg)
 
virtual void SetMetricWorstPossibleValue (double _arg)
 
void StartOptimization () override
 
void StopOptimization ()
 
virtual void SetMaximize (bool _arg)
 
virtual void MaximizeOn ()
 
virtual const bool & GetMaximize () const
 
virtual void SetMaximumIteration (unsigned int _arg)
 
virtual const unsigned int & GetMaximumIteration () const
 
virtual void SetMaximumLineIteration (unsigned int _arg)
 
virtual unsigned int GetMaximumLineIteration () const
 
virtual void SetStepLength (double _arg)
 
virtual const double & GetStepLength () const
 
virtual void SetStepTolerance (double _arg)
 
virtual const double & GetStepTolerance () const
 
virtual void SetValueTolerance (double _arg)
 
virtual const double & GetValueTolerance () const
 
virtual const MeasureTypeGetCurrentCost () const
 
MeasureType GetValue () const
 
- Public Member Functions inherited from itk::SingleValuedNonLinearOptimizer
virtual CostFunctionTypeGetModifiableCostFunction ()
 
const char * GetNameOfClass () const override
 
MeasureType GetValue (const ParametersType &parameters) const
 
virtual void SetCostFunction (CostFunctionType *costFunction)
 
const char * GetNameOfClass () const override
 
- Public Member Functions inherited from itk::Optimizer
virtual const ParametersTypeGetCurrentPosition () const
 
virtual const ParametersTypeGetInitialPosition () const
 
const char * GetNameOfClass () const override
 
virtual std::string GetStopConditionDescription () const
 
virtual void SetInitialPosition (const ParametersType &param)
 
void SetScales (const ScalesType &scales)
 
virtual void StartOptimization ()
 
virtual const ScalesTypeGetScales () const
 
virtual const ScalesTypeGetInverseScales () const
 
- Public Member Functions inherited from itk::Object
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
 
CommandGetCommand (unsigned long tag)
 
bool GetDebug () const
 
MetaDataDictionaryGetMetaDataDictionary ()
 
const MetaDataDictionaryGetMetaDataDictionary () const
 
virtual ModifiedTimeType GetMTime () const
 
const char * GetNameOfClass () const override
 
virtual const TimeStampGetTimeStamp () 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
 
- Public Member Functions inherited from itk::LightObject
Pointer Clone () const
 
virtual Pointer CreateAnother () const
 
virtual void Delete ()
 
virtual const char * GetNameOfClass () const
 
virtual int GetReferenceCount () const
 
void Print (std::ostream &os, Indent indent=0) const
 
virtual void Register () const
 
virtual void SetReferenceCount (int)
 
virtual void UnRegister () const noexcept
 

Static Public Member Functions

static Pointer New ()
 
- Static Public Member Functions inherited from itk::SingleValuedNonLinearOptimizer
static Pointer New ()
 
- Static Public Member Functions inherited from itk::NonLinearOptimizer
static Pointer New ()
 
- Static Public Member Functions inherited from itk::Optimizer
static Pointer New ()
 
- Static Public Member Functions inherited from itk::Object
static bool GetGlobalWarningDisplay ()
 
static void GlobalWarningDisplayOff ()
 
static void GlobalWarningDisplayOn ()
 
static Pointer New ()
 
static void SetGlobalWarningDisplay (bool val)
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 

Protected Member Functions

virtual void BracketedLineOptimize (double ax, double bx, double cx, double fa, double functionValueOfb, double fc, double *extX, double *extVal)
 
virtual void BracketedLineOptimize (double ax, double bx, double cx, double fa, double functionValueOfb, double fc, double *extX, double *extVal, ParametersType &tempCoord)
 
double GetLineValue (double x) const
 
double GetLineValue (double x, ParametersType &tempCoord) const
 
virtual unsigned int GetSpaceDimension ()
 
virtual bool GetStop ()
 
virtual void LineBracket (double *x1, double *x2, double *x3, double *f1, double *f2, double *f3)
 
virtual void LineBracket (double *x1, double *x2, double *x3, double *f1, double *f2, double *f3, ParametersType &tempCoord)
 
 PowellOptimizer ()
 
 PowellOptimizer (const PowellOptimizer &)
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
virtual void SetCurrentCost (double _arg)
 
virtual void SetCurrentIteration (unsigned int _arg)
 
void SetCurrentLinePoint (double x, double fx)
 
void SetLine (const ParametersType &origin, const vnl_vector< double > &direction)
 
void SetSpaceDimension (unsigned int dim)
 
virtual void SetStop (bool _arg)
 
void Shift (double *a, double *b, double *c, double d) const
 
void Swap (double *a, double *b) const
 
 ~PowellOptimizer () override
 
- Protected Member Functions inherited from itk::SingleValuedNonLinearOptimizer
void PrintSelf (std::ostream &os, Indent indent) const override
 
 SingleValuedNonLinearOptimizer ()
 
 ~SingleValuedNonLinearOptimizer () override=default
 
- Protected Member Functions inherited from itk::NonLinearOptimizer
 NonLinearOptimizer ()=default
 
 ~NonLinearOptimizer () override
 
- Protected Member Functions inherited from itk::Optimizer
 Optimizer ()
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
virtual void SetCurrentPosition (const ParametersType &param)
 
 ~Optimizer () override=default
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
virtual void SetTimeStamp (const TimeStamp &timeStamp)
 
 ~Object () override
 
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 
 LightObject ()
 
virtual void PrintHeader (std::ostream &os, Indent indent) const
 
virtual void PrintSelf (std::ostream &os, Indent indent) const
 
virtual void PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 

Private Attributes

bool m_CatchGetValueException {}
 
MeasureType m_CurrentCost {}
 
unsigned int m_CurrentIteration {}
 
unsigned int m_CurrentLineIteration {}
 
vnl_vector< double > m_LineDirection {}
 
ParametersType m_LineOrigin {}
 
bool m_Maximize {}
 
unsigned int m_MaximumIteration {}
 
unsigned int m_MaximumLineIteration {}
 
double m_MetricWorstPossibleValue {}
 
unsigned int m_SpaceDimension {}
 
double m_StepLength {}
 
double m_StepTolerance {}
 
bool m_Stop {}
 
std::ostringstream m_StopConditionDescription {}
 
double m_ValueTolerance {}
 

Additional Inherited Members

- Protected Attributes inherited from itk::SingleValuedNonLinearOptimizer
CostFunctionPointer m_CostFunction {}
 
- Protected Attributes inherited from itk::Optimizer
ParametersType m_CurrentPosition {}
 
bool m_ScalesInitialized { false }
 
- Protected Attributes inherited from itk::LightObject
std::atomic< int > m_ReferenceCount {}
 

Member Typedef Documentation

◆ ConstPointer

Definition at line 69 of file itkPowellOptimizer.h.

◆ CostFunctionPointer

Definition at line 81 of file itkPowellOptimizer.h.

◆ CostFunctionType

Type of the Cost Function

Definition at line 80 of file itkPowellOptimizer.h.

◆ ParametersType

Definition at line 71 of file itkPowellOptimizer.h.

◆ Pointer

Definition at line 68 of file itkPowellOptimizer.h.

◆ Self

Standard "Self" type alias.

Definition at line 66 of file itkPowellOptimizer.h.

◆ Superclass

Definition at line 67 of file itkPowellOptimizer.h.

Constructor & Destructor Documentation

◆ PowellOptimizer() [1/2]

itk::PowellOptimizer::PowellOptimizer ( )
protected

◆ PowellOptimizer() [2/2]

itk::PowellOptimizer::PowellOptimizer ( const PowellOptimizer )
protected

◆ ~PowellOptimizer()

itk::PowellOptimizer::~PowellOptimizer ( )
overrideprotected

Member Function Documentation

◆ BracketedLineOptimize() [1/2]

virtual void itk::PowellOptimizer::BracketedLineOptimize ( double  ax,
double  bx,
double  cx,
double  fa,
double  functionValueOfb,
double  fc,
double *  extX,
double *  extVal 
)
protectedvirtual

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 optimizers from NRC.

◆ BracketedLineOptimize() [2/2]

virtual void itk::PowellOptimizer::BracketedLineOptimize ( double  ax,
double  bx,
double  cx,
double  fa,
double  functionValueOfb,
double  fc,
double *  extX,
double *  extVal,
ParametersType tempCoord 
)
protectedvirtual

◆ GetCatchGetValueException()

virtual const bool & itk::PowellOptimizer::GetCatchGetValueException ( ) const
virtual

◆ GetCurrentCost()

virtual const MeasureType & itk::PowellOptimizer::GetCurrentCost ( ) const
virtual

Return Current Value

◆ GetCurrentIteration()

virtual const unsigned int & itk::PowellOptimizer::GetCurrentIteration ( ) const
virtual

Return Current Iteration

◆ GetCurrentLineIteration()

virtual const unsigned int & itk::PowellOptimizer::GetCurrentLineIteration ( ) const
virtual

Get the current line search iteration

◆ GetLineValue() [1/2]

double itk::PowellOptimizer::GetLineValue ( double  x) const
protected

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

◆ GetLineValue() [2/2]

double itk::PowellOptimizer::GetLineValue ( double  x,
ParametersType tempCoord 
) const
protected

◆ GetMaximize()

virtual const bool & itk::PowellOptimizer::GetMaximize ( ) const
virtual

Set if the Optimizer should Maximize the metric

◆ GetMaximumIteration()

virtual const unsigned int & itk::PowellOptimizer::GetMaximumIteration ( ) const
virtual

Set/Get maximum iteration limit.

◆ GetMaximumLineIteration()

virtual unsigned int itk::PowellOptimizer::GetMaximumLineIteration ( ) const
virtual

Set/Get the maximum number of line search iterations

◆ GetMetricWorstPossibleValue()

virtual const double & itk::PowellOptimizer::GetMetricWorstPossibleValue ( ) const
virtual

◆ GetNameOfClass()

const char * itk::PowellOptimizer::GetNameOfClass ( ) const
overridevirtual

◆ GetSpaceDimension()

virtual unsigned int itk::PowellOptimizer::GetSpaceDimension ( )
protectedvirtual

◆ GetStepLength()

virtual const double & itk::PowellOptimizer::GetStepLength ( ) const
virtual

Set/Get StepLength for the (scaled) spacing of the sampling of parameter space while bracketing the extremum

◆ GetStepTolerance()

virtual const double & itk::PowellOptimizer::GetStepTolerance ( ) const
virtual

Set/Get StepTolerance. Once the local extreme is known to be within this distance of the current parameter values, optimization terminates

◆ GetStop()

virtual bool itk::PowellOptimizer::GetStop ( )
protectedvirtual

◆ GetStopConditionDescription()

std::string itk::PowellOptimizer::GetStopConditionDescription ( ) const
overridevirtual

Get the reason for termination

Reimplemented from itk::Optimizer.

◆ GetValue()

MeasureType itk::PowellOptimizer::GetValue ( ) const
inline

Return Current Value

Definition at line 121 of file itkPowellOptimizer.h.

◆ GetValueTolerance()

virtual const double & itk::PowellOptimizer::GetValueTolerance ( ) const
virtual

Set/Get ValueTolerance. Once this current cost function value is known to be within this tolerance of the cost function value at the local extreme, optimization terminates

◆ LineBracket() [1/2]

virtual void itk::PowellOptimizer::LineBracket ( double *  x1,
double *  x2,
double *  x3,
double *  f1,
double *  f2,
double *  f3 
)
protectedvirtual

The LineBracket routine from NRC. Later reimplemented from the description of the method available in the Wikipedia.

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.

◆ LineBracket() [2/2]

virtual void itk::PowellOptimizer::LineBracket ( double *  x1,
double *  x2,
double *  x3,
double *  f1,
double *  f2,
double *  f3,
ParametersType tempCoord 
)
protectedvirtual

◆ MaximizeOn()

virtual void itk::PowellOptimizer::MaximizeOn ( )
virtual

Set if the Optimizer should Maximize the metric

◆ New()

static Pointer itk::PowellOptimizer::New ( )
static

Method for creation through the object factory.

◆ PrintSelf()

void itk::PowellOptimizer::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
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::Optimizer.

◆ SetCatchGetValueException()

virtual void itk::PowellOptimizer::SetCatchGetValueException ( bool  _arg)
virtual

◆ SetCurrentCost()

virtual void itk::PowellOptimizer::SetCurrentCost ( double  _arg)
protectedvirtual

◆ SetCurrentIteration()

virtual void itk::PowellOptimizer::SetCurrentIteration ( unsigned int  _arg)
protectedvirtual

◆ SetCurrentLinePoint()

void itk::PowellOptimizer::SetCurrentLinePoint ( double  x,
double  fx 
)
protected

Set the given scalar step distance (x) and function value (fx) as the "best-so-far" optimizer values.

◆ SetLine()

void itk::PowellOptimizer::SetLine ( const ParametersType origin,
const vnl_vector< double > &  direction 
)
protected

Used to specify the line direction through the n-dimensional parameter space the is currently being bracketed and optimized.

◆ SetMaximize()

virtual void itk::PowellOptimizer::SetMaximize ( bool  _arg)
virtual

Set if the Optimizer should Maximize the metric

◆ SetMaximumIteration()

virtual void itk::PowellOptimizer::SetMaximumIteration ( unsigned int  _arg)
virtual

Set/Get maximum iteration limit.

◆ SetMaximumLineIteration()

virtual void itk::PowellOptimizer::SetMaximumLineIteration ( unsigned int  _arg)
virtual

Set/Get the maximum number of line search iterations

◆ SetMetricWorstPossibleValue()

virtual void itk::PowellOptimizer::SetMetricWorstPossibleValue ( double  _arg)
virtual

◆ SetSpaceDimension()

void itk::PowellOptimizer::SetSpaceDimension ( unsigned int  dim)
inlineprotected

Definition at line 236 of file itkPowellOptimizer.h.

◆ SetStepLength()

virtual void itk::PowellOptimizer::SetStepLength ( double  _arg)
virtual

Set/Get StepLength for the (scaled) spacing of the sampling of parameter space while bracketing the extremum

◆ SetStepTolerance()

virtual void itk::PowellOptimizer::SetStepTolerance ( double  _arg)
virtual

Set/Get StepTolerance. Once the local extreme is known to be within this distance of the current parameter values, optimization terminates

◆ SetStop()

virtual void itk::PowellOptimizer::SetStop ( bool  _arg)
protectedvirtual

◆ SetValueTolerance()

virtual void itk::PowellOptimizer::SetValueTolerance ( double  _arg)
virtual

Set/Get ValueTolerance. Once this current cost function value is known to be within this tolerance of the cost function value at the local extreme, optimization terminates

◆ Shift()

void itk::PowellOptimizer::Shift ( double *  a,
double *  b,
double *  c,
double  d 
) const
protected

Used in bracketing the extreme along the current line. Adapted from NRC

◆ StartOptimization()

void itk::PowellOptimizer::StartOptimization ( )
overridevirtual

Start optimization.

Reimplemented from itk::Optimizer.

◆ StopOptimization()

void itk::PowellOptimizer::StopOptimization ( )
inline

When users call StartOptimization, this value will be set false. By calling StopOptimization, this flag will be set true, and optimization will stop at the next iteration.

Definition at line 141 of file itkPowellOptimizer.h.

◆ Swap()

void itk::PowellOptimizer::Swap ( double *  a,
double *  b 
) const
protected

Used in bracketing the extreme along the current line. Adapted from NRC

Member Data Documentation

◆ m_CatchGetValueException

bool itk::PowellOptimizer::m_CatchGetValueException {}
private

Definition at line 261 of file itkPowellOptimizer.h.

◆ m_CurrentCost

MeasureType itk::PowellOptimizer::m_CurrentCost {}
private

Internal storage for the value type / used as a cache

Definition at line 277 of file itkPowellOptimizer.h.

◆ m_CurrentIteration

unsigned int itk::PowellOptimizer::m_CurrentIteration {}
private

Current iteration

Definition at line 254 of file itkPowellOptimizer.h.

◆ m_CurrentLineIteration

unsigned int itk::PowellOptimizer::m_CurrentLineIteration {}
private

Definition at line 255 of file itkPowellOptimizer.h.

◆ m_LineDirection

vnl_vector<double> itk::PowellOptimizer::m_LineDirection {}
private

Definition at line 272 of file itkPowellOptimizer.h.

◆ m_LineOrigin

ParametersType itk::PowellOptimizer::m_LineOrigin {}
private

Definition at line 271 of file itkPowellOptimizer.h.

◆ m_Maximize

bool itk::PowellOptimizer::m_Maximize {}
private

Set if the Metric should be maximized: Default = False

Definition at line 265 of file itkPowellOptimizer.h.

◆ m_MaximumIteration

unsigned int itk::PowellOptimizer::m_MaximumIteration {}
private

Maximum iteration limit.

Definition at line 258 of file itkPowellOptimizer.h.

◆ m_MaximumLineIteration

unsigned int itk::PowellOptimizer::m_MaximumLineIteration {}
private

Definition at line 259 of file itkPowellOptimizer.h.

◆ m_MetricWorstPossibleValue

double itk::PowellOptimizer::m_MetricWorstPossibleValue {}
private

Definition at line 262 of file itkPowellOptimizer.h.

◆ m_SpaceDimension

unsigned int itk::PowellOptimizer::m_SpaceDimension {}
private

Definition at line 251 of file itkPowellOptimizer.h.

◆ m_StepLength

double itk::PowellOptimizer::m_StepLength {}
private

The minimal size of search

Definition at line 268 of file itkPowellOptimizer.h.

◆ m_StepTolerance

double itk::PowellOptimizer::m_StepTolerance {}
private

Definition at line 269 of file itkPowellOptimizer.h.

◆ m_Stop

bool itk::PowellOptimizer::m_Stop {}
private

this is user-settable flag to stop optimization. when users call StartOptimization, this value will be set false. By calling StopOptimization, this flag will be set true, and optimization will stop at the next iteration.

Definition at line 283 of file itkPowellOptimizer.h.

◆ m_StopConditionDescription

std::ostringstream itk::PowellOptimizer::m_StopConditionDescription {}
private

Definition at line 285 of file itkPowellOptimizer.h.

◆ m_ValueTolerance

double itk::PowellOptimizer::m_ValueTolerance {}
private

Definition at line 274 of file itkPowellOptimizer.h.


The documentation for this class was generated from the following file: