ITK  4.4.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
itk::SPSAOptimizer Class Reference

#include <itkSPSAOptimizer.h>

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

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 43 of file itkSPSAOptimizer.h.

Public Types

typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef SPSAOptimizer Self
 
enum  StopConditionType {
  Unknown,
  MaximumNumberOfIterations,
  BelowTolerance,
  MetricError
}
 
typedef
SingleValuedNonLinearOptimizer 
Superclass
 
- Public Types inherited from itk::SingleValuedNonLinearOptimizer
typedef SmartPointer< const SelfConstPointer
 
typedef CostFunctionType::Pointer CostFunctionPointer
 
typedef SingleValuedCostFunction CostFunctionType
 
typedef
CostFunctionType::DerivativeType 
DerivativeType
 
typedef
CostFunctionType::MeasureType 
MeasureType
 
typedef Superclass::ParametersType ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef
SingleValuedNonLinearOptimizer 
Self
 
typedef NonLinearOptimizer Superclass
 
- Public Types inherited from itk::NonLinearOptimizer
typedef SmartPointer< const SelfConstPointer
 
typedef Superclass::ParametersType ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef Superclass::ScalesType ScalesType
 
typedef NonLinearOptimizer Self
 
typedef Optimizer Superclass
 
- Public Types inherited from itk::Optimizer
typedef SmartPointer< const SelfConstPointer
 
typedef OptimizerParameters
< double > 
ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef Array< double > ScalesType
 
typedef Optimizer Self
 
typedef Object Superclass
 
- Public Types inherited from itk::Object
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef Object Self
 
typedef LightObject Superclass
 
- Public Types inherited from itk::LightObject
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef LightObject Self
 

Public Member Functions

virtual void AdvanceOneStep (void)
 
virtual ::itk::LightObject::Pointer CreateAnother (void) const
 
virtual SizeValueType GetCurrentIteration () const
 
virtual const DerivativeTypeGetGradient ()
 
virtual double GetGradientMagnitude () const
 
virtual double GetLearningRate () const
 
virtual const char * GetNameOfClass () const
 
virtual double GetStateOfConvergence () const
 
virtual StopConditionType GetStopCondition () const
 
const std::string GetStopConditionDescription () const
 
virtual MeasureType GetValue (void) const
 
virtual MeasureType GetValue (const ParametersType &parameters) const
 
virtual void GuessParameters (SizeValueType numberOfGradientEstimates, double initialStepSize)
 
void ResumeOptimization (void)
 
void StartOptimization (void)
 
void StopOptimization (void)
 
virtual void SetSa (double _arg)
 
virtual double GetSa () const
 
void Seta (double a)
 
double Geta ()
 
virtual void SetSc (double _arg)
 
virtual double GetSc () const
 
void Setc (double c)
 
double Getc ()
 
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 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 const CostFunctionTypeGetCostFunction () const
 
virtual CostFunctionTypeGetModifiableCostFunction ()
 
MeasureType GetValue (const ParametersType &parameters) const
 
virtual void SetCostFunction (CostFunctionType *costFunction)
 

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 ()
 

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
 
 SPSAOptimizer ()
 
virtual ~SPSAOptimizer ()
 
- Protected Member Functions inherited from itk::SingleValuedNonLinearOptimizer
 SingleValuedNonLinearOptimizer ()
 
virtual ~SingleValuedNonLinearOptimizer ()
 
- Protected Member Functions inherited from itk::NonLinearOptimizer
 NonLinearOptimizer ()
 
virtual ~NonLinearOptimizer ()
 
- Protected Member Functions inherited from itk::Optimizer
 Optimizer ()
 
virtual void SetCurrentPosition (const ParametersType &param)
 
virtual ~Optimizer ()
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
virtual void SetTimeStamp (const TimeStamp &time)
 
virtual ~Object ()
 
- 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
 
StopConditionType m_StopCondition
 
- Protected Attributes inherited from itk::SingleValuedNonLinearOptimizer
CostFunctionPointer m_CostFunction
 

Private Member Functions

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

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
 

Additional Inherited Members

- Protected Types inherited from itk::LightObject
typedef int InternalReferenceCountType
 

Member Typedef Documentation

Definition at line 52 of file itkSPSAOptimizer.h.

Definition at line 51 of file itkSPSAOptimizer.h.

Standard class typedefs.

Definition at line 49 of file itkSPSAOptimizer.h.

Definition at line 50 of file itkSPSAOptimizer.h.

Member Enumeration Documentation

Codes of stopping conditions

Enumerator
Unknown 
MaximumNumberOfIterations 
BelowTolerance 
MetricError 

Definition at line 61 of file itkSPSAOptimizer.h.

Constructor & Destructor Documentation

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

Definition at line 213 of file itkSPSAOptimizer.h.

itk::SPSAOptimizer::SPSAOptimizer ( const Self )
private

Member Function Documentation

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

Advance one step following the gradient direction.

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

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

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

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

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.

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

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

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

double itk::SPSAOptimizer::Geta ( )
inline

Set/Get a.

Definition at line 125 of file itkSPSAOptimizer.h.

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

Set/Get A.

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

Set/Get alpha.

double itk::SPSAOptimizer::Getc ( )
inline

Set/Get c.

Definition at line 133 of file itkSPSAOptimizer.h.

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

Get the current iteration number.

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

Set/Get gamma.

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

Get the latest computed gradient

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

Get the GradientMagnitude of the latest computed gradient

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

Get the current LearningRate (a_k)

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

Methods to configure the cost function.

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

Set/Get the maximum number of iterations.

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

Methods to configure the cost function.

Definition at line 155 of file itkSPSAOptimizer.h.

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

Set/Get the minimum number of iterations

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

Run-time type information (and related methods).

Reimplemented from itk::SingleValuedNonLinearOptimizer.

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

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

Set/Get a.

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

Set/Get c.

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

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

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

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

Get Stop condition.

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

Get the reason for termination

Reimplemented from itk::Optimizer.

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

Set/Get Tolerance

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

Get the cost function value at the current position.

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

Get the cost function value at any position

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.

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

Methods to configure the cost function.

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

Methods to configure the cost function.

void itk::SPSAOptimizer::MinimizeOff ( )
inline

Methods to configure the cost function.

Definition at line 161 of file itkSPSAOptimizer.h.

void itk::SPSAOptimizer::MinimizeOn ( )
inline

Methods to configure the cost function.

Definition at line 159 of file itkSPSAOptimizer.h.

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

Method for creation through the object factory.

void itk::SPSAOptimizer::operator= ( const Self )
private
void itk::SPSAOptimizer::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
protectedvirtual

PrintSelf method.

Reimplemented from itk::SingleValuedNonLinearOptimizer.

void itk::SPSAOptimizer::ResumeOptimization ( void  )

Resume previously stopped optimization with current parameters

See Also
StopOptimization.
void itk::SPSAOptimizer::Seta ( double  a)
inline

Set/Get a.

Definition at line 124 of file itkSPSAOptimizer.h.

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

Set/Get A.

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

Set/Get alpha.

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

Set/Get c.

Definition at line 132 of file itkSPSAOptimizer.h.

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

Set/Get gamma.

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

Methods to configure the cost function.

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

Set/Get the maximum number of iterations.

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

Methods to configure the cost function.

Definition at line 157 of file itkSPSAOptimizer.h.

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

Set/Get the minimum number of iterations

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

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

Set/Get a.

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

Set/Get c.

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

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

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

Set/Get Tolerance

void itk::SPSAOptimizer::StartOptimization ( void  )
virtual

Start optimization.

Reimplemented from itk::Optimizer.

void itk::SPSAOptimizer::StopOptimization ( void  )

Stop optimization.

See Also
ResumeOptimization

Member Data Documentation

double itk::SPSAOptimizer::m_A
private

Definition at line 273 of file itkSPSAOptimizer.h.

double itk::SPSAOptimizer::m_Alpha
private

Definition at line 274 of file itkSPSAOptimizer.h.

SizeValueType itk::SPSAOptimizer::m_CurrentIteration
protected

Definition at line 231 of file itkSPSAOptimizer.h.

DerivativeType itk::SPSAOptimizer::m_Delta
protected

Definition at line 223 of file itkSPSAOptimizer.h.

double itk::SPSAOptimizer::m_Gamma
private

Definition at line 275 of file itkSPSAOptimizer.h.

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

Random number generator

Definition at line 234 of file itkSPSAOptimizer.h.

DerivativeType itk::SPSAOptimizer::m_Gradient
protected

Variables updated during optimization

Definition at line 219 of file itkSPSAOptimizer.h.

double itk::SPSAOptimizer::m_GradientMagnitude
private

Definition at line 267 of file itkSPSAOptimizer.h.

double itk::SPSAOptimizer::m_LearningRate
protected

Definition at line 221 of file itkSPSAOptimizer.h.

bool itk::SPSAOptimizer::m_Maximize
private

Definition at line 266 of file itkSPSAOptimizer.h.

SizeValueType itk::SPSAOptimizer::m_MaximumNumberOfIterations
private

Definition at line 263 of file itkSPSAOptimizer.h.

SizeValueType itk::SPSAOptimizer::m_MinimumNumberOfIterations
private

Settings.

Definition at line 262 of file itkSPSAOptimizer.h.

SizeValueType itk::SPSAOptimizer::m_NumberOfPerturbations
private

Definition at line 268 of file itkSPSAOptimizer.h.

double itk::SPSAOptimizer::m_Sa
private

Parameters, as described by Spall.

Definition at line 271 of file itkSPSAOptimizer.h.

double itk::SPSAOptimizer::m_Sc
private

Definition at line 272 of file itkSPSAOptimizer.h.

double itk::SPSAOptimizer::m_StateOfConvergence
protected

Definition at line 229 of file itkSPSAOptimizer.h.

double itk::SPSAOptimizer::m_StateOfConvergenceDecayRate
private

Definition at line 264 of file itkSPSAOptimizer.h.

bool itk::SPSAOptimizer::m_Stop
protected

Definition at line 225 of file itkSPSAOptimizer.h.

StopConditionType itk::SPSAOptimizer::m_StopCondition
protected

Definition at line 227 of file itkSPSAOptimizer.h.

double itk::SPSAOptimizer::m_Tolerance
private

Definition at line 265 of file itkSPSAOptimizer.h.


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