ITK  5.2.0
Insight Toolkit
Public Types | Public Member Functions | Static Public Member Functions | List of all members

#include <itkSPSAOptimizer.h>

+ Inheritance diagram for itk::SPSAOptimizer:
+ Collaboration diagram for itk::SPSAOptimizer:

Public Types

using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = SPSAOptimizer
 
using StopConditionSPSAOptimizerEnum = SPSAOptimizerEnums::StopConditionSPSAOptimizer
 
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 void AdvanceOneStep ()
 
virtual ::itk::LightObject::Pointer CreateAnother () const
 
virtual SizeValueType GetCurrentIteration () const
 
virtual const DerivativeTypeGetGradient () const
 
virtual double GetGradientMagnitude () const
 
virtual double GetLearningRate () const
 
virtual const char * GetNameOfClass () const
 
virtual StopConditionSPSAOptimizerEnum GetStopCondition () const
 
virtual MeasureType GetValue () const
 
virtual MeasureType GetValue (const ParametersType &parameters) const
 
virtual void GuessParameters (SizeValueType numberOfGradientEstimates, double initialStepSize)
 
void ResumeOptimization ()
 
void StartOptimization () override
 
void StopOptimization ()
 
- Public Member Functions inherited from itk::SingleValuedNonLinearOptimizer
virtual const CostFunctionTypeGetCostFunction () const
 
virtual CostFunctionTypeGetModifiableCostFunction ()
 
MeasureType GetValue (const ParametersType &parameters) const
 
virtual void SetCostFunction (CostFunctionType *costFunction)
 
- Public Member Functions inherited from itk::Optimizer
virtual const ParametersTypeGetInitialPosition () const
 
virtual void SetInitialPosition (const ParametersType &param)
 
void SetScales (const ScalesType &scales)
 
virtual const ScalesTypeGetScales () const
 
virtual const ScalesTypeGetInverseScales () const
 
virtual const ParametersTypeGetCurrentPosition () const
 
- Public Member Functions inherited from itk::Object
unsigned long AddObserver (const EventObject &event, Command *)
 
unsigned long AddObserver (const EventObject &event, Command *) const
 
virtual void DebugOff () const
 
virtual void DebugOn () const
 
CommandGetCommand (unsigned long tag)
 
bool GetDebug () const
 
MetaDataDictionaryGetMetaDataDictionary ()
 
const MetaDataDictionaryGetMetaDataDictionary () const
 
virtual ModifiedTimeType GetMTime () const
 
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)
 
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
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
 itkCloneMacro (Self)
 
void Print (std::ostream &os, Indent indent=0) const
 

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 flag)
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 
DerivativeType m_Gradient
 
double m_LearningRate
 
DerivativeType m_Delta
 
bool m_Stop { false }
 
StopConditionSPSAOptimizerEnum m_StopCondition
 
double m_StateOfConvergence
 
SizeValueType m_CurrentIteration
 
Statistics::MersenneTwisterRandomVariateGenerator::Pointer m_Generator
 
SizeValueType m_MinimumNumberOfIterations
 
SizeValueType m_MaximumNumberOfIterations
 
double m_StateOfConvergenceDecayRate
 
double m_Tolerance
 
bool m_Maximize
 
double m_GradientMagnitude
 
SizeValueType m_NumberOfPerturbations
 
double m_Sa
 
double m_Sc
 
double m_A
 
double m_Alpha
 
double m_Gamma
 
virtual void SetSa (double _arg)
 
virtual double GetSa () const
 
void Seta (double a)
 
double Geta () const
 
virtual void SetSc (double _arg)
 
virtual double GetSc () const
 
void Setc (double c)
 
double Getc () const
 
virtual void SetA (double _arg)
 
virtual double GetA () const
 
virtual void SetAlpha (double _arg)
 
virtual double GetAlpha () const
 
virtual void SetGamma (double _arg)
 
virtual double GetGamma () const
 
virtual bool GetMaximize () const
 
virtual void SetMaximize (bool _arg)
 
virtual void MaximizeOn ()
 
virtual void MaximizeOff ()
 
bool GetMinimize () const
 
void SetMinimize (bool v)
 
void MinimizeOn ()
 
void MinimizeOff ()
 
virtual void SetNumberOfPerturbations (SizeValueType _arg)
 
virtual SizeValueType GetNumberOfPerturbations () const
 
virtual double GetStateOfConvergence () const
 
virtual void SetStateOfConvergenceDecayRate (double _arg)
 
virtual double GetStateOfConvergenceDecayRate () const
 
virtual void SetMinimumNumberOfIterations (SizeValueType _arg)
 
virtual SizeValueType GetMinimumNumberOfIterations () const
 
virtual void SetMaximumNumberOfIterations (SizeValueType _arg)
 
virtual SizeValueType GetMaximumNumberOfIterations () const
 
virtual void SetTolerance (double _arg)
 
virtual double GetTolerance () const
 
const std::string GetStopConditionDescription () const override
 
 SPSAOptimizer ()
 
 ~SPSAOptimizer () override=default
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
virtual double Compute_a (SizeValueType k) const
 
virtual double Compute_c (SizeValueType k) const
 
virtual void GenerateDelta (const unsigned int spaceDimension)
 
virtual void ComputeGradient (const ParametersType &parameters, DerivativeType &gradient)
 

Additional Inherited Members

- Protected Member Functions inherited from itk::SingleValuedNonLinearOptimizer
 SingleValuedNonLinearOptimizer ()
 
 ~SingleValuedNonLinearOptimizer () override=default
 
- Protected Member Functions inherited from itk::NonLinearOptimizer
 NonLinearOptimizer ()=default
 
 ~NonLinearOptimizer () override
 
- Protected Member Functions inherited from itk::Optimizer
 Optimizer ()
 
 ~Optimizer () override=default
 
virtual void SetCurrentPosition (const ParametersType &param)
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
 ~Object () override
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
virtual void SetTimeStamp (const TimeStamp &time)
 
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 
 LightObject ()
 
virtual void PrintHeader (std::ostream &os, Indent indent) const
 
virtual void PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 
- Protected Attributes inherited from itk::SingleValuedNonLinearOptimizer
CostFunctionPointer m_CostFunction
 
- Protected Attributes inherited from itk::Optimizer
bool m_ScalesInitialized { false }
 
ParametersType m_CurrentPosition
 
- Protected Attributes inherited from itk::LightObject
std::atomic< int > m_ReferenceCount
 

Detailed Description

An optimizer based on simultaneous perturbation...

This optimizer is an implementation of the Simultaneous Perturbation Stochastic Approximation method, described in:

Definition at line 65 of file itkSPSAOptimizer.h.

Member Typedef Documentation

◆ ConstPointer

Definition at line 74 of file itkSPSAOptimizer.h.

◆ Pointer

Definition at line 73 of file itkSPSAOptimizer.h.

◆ Self

Standard class type aliases.

Definition at line 71 of file itkSPSAOptimizer.h.

◆ StopConditionSPSAOptimizerEnum

Definition at line 82 of file itkSPSAOptimizer.h.

◆ Superclass

Definition at line 72 of file itkSPSAOptimizer.h.

Constructor & Destructor Documentation

◆ SPSAOptimizer()

itk::SPSAOptimizer::SPSAOptimizer ( )
protected

Variables updated during optimization

◆ ~SPSAOptimizer()

itk::SPSAOptimizer::~SPSAOptimizer ( )
overrideprotecteddefault

Variables updated during optimization

Member Function Documentation

◆ AdvanceOneStep()

virtual void itk::SPSAOptimizer::AdvanceOneStep ( )
virtual

Advance one step following the gradient direction.

◆ Compute_a()

virtual double itk::SPSAOptimizer::Compute_a ( SizeValueType  k) const
protectedvirtual

Method to compute the learning rate at iteration k (a_k).

◆ Compute_c()

virtual double itk::SPSAOptimizer::Compute_c ( SizeValueType  k) const
protectedvirtual

Method to compute the gain factor for the perturbation at iteration k (c_k).

◆ ComputeGradient()

virtual void itk::SPSAOptimizer::ComputeGradient ( const ParametersType parameters,
DerivativeType gradient 
)
protectedvirtual

Compute the gradient at a position. m_NumberOfPerturbations are used, and scales are taken into account.

◆ CreateAnother()

virtual::itk::LightObject::Pointer itk::SPSAOptimizer::CreateAnother ( ) const
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::SingleValuedNonLinearOptimizer.

◆ GenerateDelta()

virtual void itk::SPSAOptimizer::GenerateDelta ( const unsigned int  spaceDimension)
protectedvirtual

Method to generate a perturbation vector. Takes scales into account.

◆ Geta()

double itk::SPSAOptimizer::Geta ( ) const
inline

Variables updated during optimization

Definition at line 159 of file itkSPSAOptimizer.h.

◆ GetA()

virtual double itk::SPSAOptimizer::GetA ( ) const
virtual

Variables updated during optimization

◆ GetAlpha()

virtual double itk::SPSAOptimizer::GetAlpha ( ) const
virtual

Variables updated during optimization

◆ Getc()

double itk::SPSAOptimizer::Getc ( ) const
inline

Variables updated during optimization

Definition at line 175 of file itkSPSAOptimizer.h.

◆ GetCurrentIteration()

virtual SizeValueType itk::SPSAOptimizer::GetCurrentIteration ( ) const
virtual

Get the current iteration number.

◆ GetGamma()

virtual double itk::SPSAOptimizer::GetGamma ( ) const
virtual

Variables updated during optimization

◆ GetGradient()

virtual const DerivativeType& itk::SPSAOptimizer::GetGradient ( ) const
virtual

Get the latest computed gradient

◆ GetGradientMagnitude()

virtual double itk::SPSAOptimizer::GetGradientMagnitude ( ) const
virtual

Get the GradientMagnitude of the latest computed gradient

◆ GetLearningRate()

virtual double itk::SPSAOptimizer::GetLearningRate ( ) const
virtual

Get the current LearningRate (a_k)

◆ GetMaximize()

virtual bool itk::SPSAOptimizer::GetMaximize ( ) const
virtual

Methods to configure the cost function.

◆ GetMaximumNumberOfIterations()

virtual SizeValueType itk::SPSAOptimizer::GetMaximumNumberOfIterations ( ) const
virtual

Variables updated during optimization

◆ GetMinimize()

bool itk::SPSAOptimizer::GetMinimize ( ) const
inline

Variables updated during optimization

Definition at line 201 of file itkSPSAOptimizer.h.

◆ GetMinimumNumberOfIterations()

virtual SizeValueType itk::SPSAOptimizer::GetMinimumNumberOfIterations ( ) const
virtual

Variables updated during optimization

◆ GetNameOfClass()

virtual const char* itk::SPSAOptimizer::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods).

Reimplemented from itk::SingleValuedNonLinearOptimizer.

◆ GetNumberOfPerturbations()

virtual SizeValueType itk::SPSAOptimizer::GetNumberOfPerturbations ( ) const
virtual

Variables updated during optimization

◆ GetSa()

virtual double itk::SPSAOptimizer::GetSa ( ) const
virtual

Variables updated during optimization

◆ GetSc()

virtual double itk::SPSAOptimizer::GetSc ( ) const
virtual

Variables updated during optimization

◆ GetStateOfConvergence()

virtual double itk::SPSAOptimizer::GetStateOfConvergence ( ) const
virtual

Get the state of convergence in the last iteration. When the StateOfConvergence is lower than the Tolerance, and the minimum number of iterations has been performed, the optimization stops.

The state of convergence (SOC) is initialized with 0.0 and updated after each iteration as follows: SOC *= SOCDecayRate SOC += a_k * GradientMagnitude

◆ GetStateOfConvergenceDecayRate()

virtual double itk::SPSAOptimizer::GetStateOfConvergenceDecayRate ( ) const
virtual

Variables updated during optimization

◆ GetStopCondition()

virtual StopConditionSPSAOptimizerEnum itk::SPSAOptimizer::GetStopCondition ( ) const
virtual

Get Stop condition.

◆ GetStopConditionDescription()

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

Get the reason for termination

Reimplemented from itk::Optimizer.

◆ GetTolerance()

virtual double itk::SPSAOptimizer::GetTolerance ( ) const
virtual

Variables updated during optimization

◆ GetValue() [1/2]

virtual MeasureType itk::SPSAOptimizer::GetValue ( ) const
virtual

Get the cost function value at the current position.

◆ GetValue() [2/2]

virtual MeasureType itk::SPSAOptimizer::GetValue ( const ParametersType parameters) const
virtual

Get the cost function value at any position

◆ GuessParameters()

virtual void itk::SPSAOptimizer::GuessParameters ( SizeValueType  numberOfGradientEstimates,
double  initialStepSize 
)
virtual

Guess the parameters a and A. This function needs the number of GradientEstimates used for estimating a and A and and the expected initial step size (where step size is defined as the maximum of the absolute values of the parameter update). Make sure you set c, Alpha, Gamma, the MaximumNumberOfIterations, the Scales, and the the InitialPosition before calling this method.

Described in: Spall, J.C. (1998), "Implementation of the Simultaneous Perturbation Algorithm for Stochastic Optimization", IEEE Trans. Aerosp. Electron. Syst. 34(3), 817-823.

◆ MaximizeOff()

virtual void itk::SPSAOptimizer::MaximizeOff ( )
virtual

Variables updated during optimization

◆ MaximizeOn()

virtual void itk::SPSAOptimizer::MaximizeOn ( )
virtual

Variables updated during optimization

◆ MinimizeOff()

void itk::SPSAOptimizer::MinimizeOff ( )
inline

Variables updated during optimization

Definition at line 216 of file itkSPSAOptimizer.h.

◆ MinimizeOn()

void itk::SPSAOptimizer::MinimizeOn ( )
inline

Variables updated during optimization

Definition at line 211 of file itkSPSAOptimizer.h.

◆ New()

static Pointer itk::SPSAOptimizer::New ( )
static

Method for creation through the object factory.

◆ PrintSelf()

void itk::SPSAOptimizer::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
overrideprotectedvirtual

PrintSelf method.

Reimplemented from itk::SingleValuedNonLinearOptimizer.

◆ ResumeOptimization()

void itk::SPSAOptimizer::ResumeOptimization ( )

Resume previously stopped optimization with current parameters

See also
StopOptimization.

◆ SetA()

virtual void itk::SPSAOptimizer::SetA ( double  _arg)
virtual

Set/Get A.

◆ Seta()

void itk::SPSAOptimizer::Seta ( double  a)
inline

Variables updated during optimization

Definition at line 154 of file itkSPSAOptimizer.h.

◆ SetAlpha()

virtual void itk::SPSAOptimizer::SetAlpha ( double  _arg)
virtual

Set/Get alpha.

◆ Setc()

void itk::SPSAOptimizer::Setc ( double  c)
inline

Variables updated during optimization

Definition at line 170 of file itkSPSAOptimizer.h.

◆ SetGamma()

virtual void itk::SPSAOptimizer::SetGamma ( double  _arg)
virtual

Set/Get gamma.

◆ SetMaximize()

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

Variables updated during optimization

◆ SetMaximumNumberOfIterations()

virtual void itk::SPSAOptimizer::SetMaximumNumberOfIterations ( SizeValueType  _arg)
virtual

Set/Get the maximum number of iterations.

◆ SetMinimize()

void itk::SPSAOptimizer::SetMinimize ( bool  v)
inline

Variables updated during optimization

Definition at line 206 of file itkSPSAOptimizer.h.

◆ SetMinimumNumberOfIterations()

virtual void itk::SPSAOptimizer::SetMinimumNumberOfIterations ( SizeValueType  _arg)
virtual

Set/Get the minimum number of iterations

◆ SetNumberOfPerturbations()

virtual void itk::SPSAOptimizer::SetNumberOfPerturbations ( SizeValueType  _arg)
virtual

Set/Get the number of perturbation used to construct a gradient estimate g_k. q = NumberOfPerturbations g_k = 1/q sum_{j=1..q} g^(j)_k

◆ SetSa()

virtual void itk::SPSAOptimizer::SetSa ( double  _arg)
virtual

Set/Get a.

◆ SetSc()

virtual void itk::SPSAOptimizer::SetSc ( double  _arg)
virtual

Set/Get c.

◆ SetStateOfConvergenceDecayRate()

virtual void itk::SPSAOptimizer::SetStateOfConvergenceDecayRate ( double  _arg)
virtual

Set/Get StateOfConvergenceDecayRate (number between 0 and 1).

◆ SetTolerance()

virtual void itk::SPSAOptimizer::SetTolerance ( double  _arg)
virtual

Set/Get Tolerance

◆ StartOptimization()

void itk::SPSAOptimizer::StartOptimization ( )
overridevirtual

Start optimization.

Reimplemented from itk::Optimizer.

◆ StopOptimization()

void itk::SPSAOptimizer::StopOptimization ( )

Stop optimization.

See also
ResumeOptimization

Member Data Documentation

◆ m_A

double itk::SPSAOptimizer::m_A
private

Variables updated during optimization

Definition at line 329 of file itkSPSAOptimizer.h.

◆ m_Alpha

double itk::SPSAOptimizer::m_Alpha
private

Variables updated during optimization

Definition at line 330 of file itkSPSAOptimizer.h.

◆ m_CurrentIteration

SizeValueType itk::SPSAOptimizer::m_CurrentIteration
protected

Variables updated during optimization

Definition at line 289 of file itkSPSAOptimizer.h.

◆ m_Delta

DerivativeType itk::SPSAOptimizer::m_Delta
protected

Variables updated during optimization

Definition at line 281 of file itkSPSAOptimizer.h.

◆ m_Gamma

double itk::SPSAOptimizer::m_Gamma
private

Variables updated during optimization

Definition at line 331 of file itkSPSAOptimizer.h.

◆ m_Generator

Statistics::MersenneTwisterRandomVariateGenerator::Pointer itk::SPSAOptimizer::m_Generator
protected

Random number generator

Definition at line 292 of file itkSPSAOptimizer.h.

◆ m_Gradient

DerivativeType itk::SPSAOptimizer::m_Gradient
protected

Variables updated during optimization

Definition at line 277 of file itkSPSAOptimizer.h.

◆ m_GradientMagnitude

double itk::SPSAOptimizer::m_GradientMagnitude
private

Variables updated during optimization

Definition at line 323 of file itkSPSAOptimizer.h.

◆ m_LearningRate

double itk::SPSAOptimizer::m_LearningRate
protected

Variables updated during optimization

Definition at line 279 of file itkSPSAOptimizer.h.

◆ m_Maximize

bool itk::SPSAOptimizer::m_Maximize
private

Variables updated during optimization

Definition at line 322 of file itkSPSAOptimizer.h.

◆ m_MaximumNumberOfIterations

SizeValueType itk::SPSAOptimizer::m_MaximumNumberOfIterations
private

Variables updated during optimization

Definition at line 319 of file itkSPSAOptimizer.h.

◆ m_MinimumNumberOfIterations

SizeValueType itk::SPSAOptimizer::m_MinimumNumberOfIterations
private

Settings.

Definition at line 318 of file itkSPSAOptimizer.h.

◆ m_NumberOfPerturbations

SizeValueType itk::SPSAOptimizer::m_NumberOfPerturbations
private

Variables updated during optimization

Definition at line 324 of file itkSPSAOptimizer.h.

◆ m_Sa

double itk::SPSAOptimizer::m_Sa
private

Parameters, as described by Spall.

Definition at line 327 of file itkSPSAOptimizer.h.

◆ m_Sc

double itk::SPSAOptimizer::m_Sc
private

Variables updated during optimization

Definition at line 328 of file itkSPSAOptimizer.h.

◆ m_StateOfConvergence

double itk::SPSAOptimizer::m_StateOfConvergence
protected

Variables updated during optimization

Definition at line 287 of file itkSPSAOptimizer.h.

◆ m_StateOfConvergenceDecayRate

double itk::SPSAOptimizer::m_StateOfConvergenceDecayRate
private

Variables updated during optimization

Definition at line 320 of file itkSPSAOptimizer.h.

◆ m_Stop

bool itk::SPSAOptimizer::m_Stop { false }
protected

Variables updated during optimization

Definition at line 283 of file itkSPSAOptimizer.h.

◆ m_StopCondition

StopConditionSPSAOptimizerEnum itk::SPSAOptimizer::m_StopCondition
protected

Variables updated during optimization

Definition at line 285 of file itkSPSAOptimizer.h.

◆ m_Tolerance

double itk::SPSAOptimizer::m_Tolerance
private

Variables updated during optimization

Definition at line 321 of file itkSPSAOptimizer.h.


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