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

#include <itkSPSAOptimizer.h>

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.

+ 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 SizeValueType GetCurrentIteration () const
 
virtual const DerivativeTypeGetGradient () const
 
virtual double GetGradientMagnitude () const
 
virtual double GetLearningRate () const
 
const char * GetNameOfClass () const override
 
virtual double GetStateOfConvergence () const
 
virtual StopConditionSPSAOptimizerEnum GetStopCondition () const
 
std::string GetStopConditionDescription () const override
 
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 ()
 
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 ()
 
bool GetMinimize () const
 
void SetMinimize (bool v)
 
void MinimizeOn ()
 
void MinimizeOff ()
 
virtual void SetNumberOfPerturbations (SizeValueType _arg)
 
virtual SizeValueType GetNumberOfPerturbations () 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
 
- Public Member Functions inherited from itk::SingleValuedNonLinearOptimizer
virtual CostFunctionTypeGetModifiableCostFunction ()
 
MeasureType GetValue (const ParametersType &parameters) const
 
virtual void SetCostFunction (CostFunctionType *costFunction)
 
- Public Member Functions inherited from itk::Optimizer
virtual const ParametersTypeGetCurrentPosition () const
 
virtual const ParametersTypeGetInitialPosition () const
 
virtual void SetInitialPosition (const ParametersType &param)
 
void SetScales (const ScalesType &scales)
 
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
 
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 void Delete ()
 
virtual int GetReferenceCount () const
 
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 val)
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 

Protected Member Functions

virtual double Compute_a (SizeValueType k) const
 
virtual double Compute_c (SizeValueType k) const
 
virtual void ComputeGradient (const ParametersType &parameters, DerivativeType &gradient)
 
virtual void GenerateDelta (const unsigned int spaceDimension)
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
 SPSAOptimizer ()
 
 ~SPSAOptimizer () override=default
 
- 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 ()
 
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
 
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 PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 

Protected Attributes

SizeValueType m_CurrentIteration {}
 
DerivativeType m_Delta {}
 
Statistics::MersenneTwisterRandomVariateGenerator::Pointer m_Generator {}
 
DerivativeType m_Gradient {}
 
double m_LearningRate {}
 
double m_StateOfConvergence {}
 
bool m_Stop { false }
 
StopConditionSPSAOptimizerEnum m_StopCondition {}
 
- 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 {}
 

Private Attributes

double m_A {}
 
double m_Alpha {}
 
double m_Gamma {}
 
double m_GradientMagnitude {}
 
bool m_Maximize {}
 
SizeValueType m_MaximumNumberOfIterations {}
 
SizeValueType m_MinimumNumberOfIterations {}
 
SizeValueType m_NumberOfPerturbations {}
 
double m_Sa {}
 
double m_Sc {}
 
double m_StateOfConvergenceDecayRate {}
 
double m_Tolerance {}
 

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

◆ ~SPSAOptimizer()

itk::SPSAOptimizer::~SPSAOptimizer ( )
overrideprotecteddefault

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.

◆ GenerateDelta()

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

Generate a perturbation vector delta.

The elements are drawn from a Bernoulli distribution (+-1).

Takes scales into account.

◆ Geta()

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

Set/Get a.

Definition at line 159 of file itkSPSAOptimizer.h.

◆ GetA()

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

Set/Get A.

◆ GetAlpha()

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

Set/Get alpha.

◆ Getc()

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

Set/Get c.

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

Set/Get gamma.

◆ 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

Set/Get the maximum number of iterations.

◆ GetMinimize()

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

Methods to configure the cost function.

Definition at line 201 of file itkSPSAOptimizer.h.

◆ GetMinimumNumberOfIterations()

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

Set/Get the minimum number of iterations

◆ GetNameOfClass()

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

◆ GetNumberOfPerturbations()

virtual SizeValueType itk::SPSAOptimizer::GetNumberOfPerturbations ( ) const
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

◆ GetSa()

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

Set/Get a.

◆ GetSc()

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

Set/Get c.

◆ 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

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

◆ GetStopCondition()

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

Get Stop condition.

◆ GetStopConditionDescription()

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

Get the reason for termination

Reimplemented from itk::Optimizer.

◆ GetTolerance()

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

Set/Get Tolerance

◆ 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.

◆ MaximizeOn()

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

Methods to configure the cost function.

◆ MinimizeOff()

void itk::SPSAOptimizer::MinimizeOff ( )
inline

Methods to configure the cost function.

Definition at line 216 of file itkSPSAOptimizer.h.

◆ MinimizeOn()

void itk::SPSAOptimizer::MinimizeOn ( )
inline

Methods to configure the cost function.

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

Set/Get a.

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

Set/Get c.

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

Methods to configure the cost function.

◆ SetMaximumNumberOfIterations()

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

Set/Get the maximum number of iterations.

◆ SetMinimize()

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

Methods to configure the cost function.

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

Definition at line 334 of file itkSPSAOptimizer.h.

◆ m_Alpha

double itk::SPSAOptimizer::m_Alpha {}
private

Definition at line 335 of file itkSPSAOptimizer.h.

◆ m_CurrentIteration

SizeValueType itk::SPSAOptimizer::m_CurrentIteration {}
protected

Definition at line 289 of file itkSPSAOptimizer.h.

◆ m_Delta

DerivativeType itk::SPSAOptimizer::m_Delta {}
protected

Definition at line 281 of file itkSPSAOptimizer.h.

◆ m_Gamma

double itk::SPSAOptimizer::m_Gamma {}
private

Definition at line 336 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

Definition at line 328 of file itkSPSAOptimizer.h.

◆ m_LearningRate

double itk::SPSAOptimizer::m_LearningRate {}
protected

Definition at line 279 of file itkSPSAOptimizer.h.

◆ m_Maximize

bool itk::SPSAOptimizer::m_Maximize {}
private

Definition at line 327 of file itkSPSAOptimizer.h.

◆ m_MaximumNumberOfIterations

SizeValueType itk::SPSAOptimizer::m_MaximumNumberOfIterations {}
private

Definition at line 324 of file itkSPSAOptimizer.h.

◆ m_MinimumNumberOfIterations

SizeValueType itk::SPSAOptimizer::m_MinimumNumberOfIterations {}
private

Settings.

Definition at line 323 of file itkSPSAOptimizer.h.

◆ m_NumberOfPerturbations

SizeValueType itk::SPSAOptimizer::m_NumberOfPerturbations {}
private

Definition at line 329 of file itkSPSAOptimizer.h.

◆ m_Sa

double itk::SPSAOptimizer::m_Sa {}
private

Parameters, as described by Spall.

Definition at line 332 of file itkSPSAOptimizer.h.

◆ m_Sc

double itk::SPSAOptimizer::m_Sc {}
private

Definition at line 333 of file itkSPSAOptimizer.h.

◆ m_StateOfConvergence

double itk::SPSAOptimizer::m_StateOfConvergence {}
protected

Definition at line 287 of file itkSPSAOptimizer.h.

◆ m_StateOfConvergenceDecayRate

double itk::SPSAOptimizer::m_StateOfConvergenceDecayRate {}
private

Definition at line 325 of file itkSPSAOptimizer.h.

◆ m_Stop

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

Definition at line 283 of file itkSPSAOptimizer.h.

◆ m_StopCondition

StopConditionSPSAOptimizerEnum itk::SPSAOptimizer::m_StopCondition {}
protected

Definition at line 285 of file itkSPSAOptimizer.h.

◆ m_Tolerance

double itk::SPSAOptimizer::m_Tolerance {}
private

Definition at line 326 of file itkSPSAOptimizer.h.


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