#include <itkSPSAOptimizer.h>
An optimizer based on simultaneous perturbation...
This optimizer is an implementation of the Simultaneous Perturbation Stochastic Approximation method, described in [108].
Definition at line 60 of file itkSPSAOptimizer.h.
Public Member Functions | |
virtual void | AdvanceOneStep () |
virtual::itk::LightObject::Pointer | CreateAnother () const |
virtual SizeValueType | GetCurrentIteration () const |
virtual const DerivativeType & | GetGradient () 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 ¶meters) 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 () |
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 |
![]() | |
virtual const CostFunctionType * | GetCostFunction () const |
virtual CostFunctionType * | GetModifiableCostFunction () |
MeasureType | GetValue (const ParametersType ¶meters) const |
virtual void | SetCostFunction (CostFunctionType *costFunction) |
![]() | |
virtual const ParametersType & | GetCurrentPosition () const |
virtual const ParametersType & | GetInitialPosition () const |
virtual void | SetInitialPosition (const ParametersType ¶m) |
void | SetScales (const ScalesType &scales) |
virtual const ScalesType & | GetScales () const |
virtual const ScalesType & | GetInverseScales () const |
![]() | |
unsigned long | AddObserver (const EventObject &event, Command *cmd) const |
unsigned long | AddObserver (const EventObject &event, std::function< void(const EventObject &)> function) const |
virtual void | DebugOff () const |
virtual void | DebugOn () const |
Command * | GetCommand (unsigned long tag) |
bool | GetDebug () const |
MetaDataDictionary & | GetMetaDataDictionary () |
const MetaDataDictionary & | GetMetaDataDictionary () const |
virtual ModifiedTimeType | GetMTime () const |
virtual const TimeStamp & | GetTimeStamp () 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 |
![]() | |
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 Pointer | New () |
![]() | |
static Pointer | New () |
![]() | |
static Pointer | New () |
![]() | |
static bool | GetGlobalWarningDisplay () |
static void | GlobalWarningDisplayOff () |
static void | GlobalWarningDisplayOn () |
static Pointer | New () |
static void | SetGlobalWarningDisplay (bool val) |
![]() | |
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 ¶meters, DerivativeType &gradient) |
virtual void | GenerateDelta (const unsigned int spaceDimension) |
void | PrintSelf (std::ostream &os, Indent indent) const override |
SPSAOptimizer () | |
~SPSAOptimizer () override=default | |
![]() | |
SingleValuedNonLinearOptimizer () | |
~SingleValuedNonLinearOptimizer () override=default | |
![]() | |
NonLinearOptimizer ()=default | |
~NonLinearOptimizer () override | |
![]() | |
Optimizer () | |
virtual void | SetCurrentPosition (const ParametersType ¶m) |
~Optimizer () override=default | |
![]() | |
Object () | |
bool | PrintObservers (std::ostream &os, Indent indent) const |
virtual void | SetTimeStamp (const TimeStamp &timeStamp) |
~Object () override | |
![]() | |
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 {} |
![]() | |
CostFunctionPointer | m_CostFunction {} |
![]() | |
ParametersType | m_CurrentPosition {} |
bool | m_ScalesInitialized { false } |
![]() | |
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 {} |
using itk::SPSAOptimizer::ConstPointer = SmartPointer<const Self> |
Definition at line 69 of file itkSPSAOptimizer.h.
using itk::SPSAOptimizer::Pointer = SmartPointer<Self> |
Definition at line 68 of file itkSPSAOptimizer.h.
Standard class type aliases.
Definition at line 66 of file itkSPSAOptimizer.h.
using itk::SPSAOptimizer::StopConditionSPSAOptimizerEnum = SPSAOptimizerEnums::StopConditionSPSAOptimizer |
Definition at line 77 of file itkSPSAOptimizer.h.
Definition at line 67 of file itkSPSAOptimizer.h.
|
protected |
Referenced by GetNameOfClass().
|
overrideprotecteddefault |
|
virtual |
Advance one step following the gradient direction.
|
protectedvirtual |
Method to compute the learning rate at iteration k (a_k).
|
protectedvirtual |
Method to compute the gain factor for the perturbation at iteration k (c_k).
|
protectedvirtual |
Compute the gradient at a position. m_NumberOfPerturbations are used, and scales are taken into account.
|
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.
|
protectedvirtual |
Generate a perturbation vector delta.
The elements are drawn from a Bernoulli distribution (+-1).
Takes scales into account.
|
virtual |
Set/Get A.
|
inline |
|
virtual |
Set/Get alpha.
|
inline |
|
virtual |
Get the current iteration number.
|
virtual |
Set/Get gamma.
|
virtual |
Get the latest computed gradient
|
virtual |
Get the GradientMagnitude of the latest computed gradient
|
virtual |
Get the current LearningRate (a_k)
|
virtual |
Methods to configure the cost function.
|
virtual |
Set/Get the maximum number of iterations.
|
inline |
Methods to configure the cost function.
Definition at line 193 of file itkSPSAOptimizer.h.
References m_Maximize.
|
virtual |
Set/Get the minimum number of iterations
|
overridevirtual |
Reimplemented from itk::SingleValuedNonLinearOptimizer.
References SPSAOptimizer().
|
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 |
Set/Get a.
Referenced by Geta().
|
virtual |
Set/Get c.
Referenced by Getc().
|
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 |
Set/Get StateOfConvergenceDecayRate (number between 0 and 1).
|
virtual |
Get Stop condition.
|
overridevirtual |
Get the reason for termination
Reimplemented from itk::Optimizer.
|
virtual |
Set/Get Tolerance
|
virtual |
Get the cost function value at the current position.
|
virtual |
Get the cost function value at any position
|
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 [107].
|
virtual |
Methods to configure the cost function.
Referenced by MinimizeOn().
|
virtual |
Methods to configure the cost function.
Referenced by MinimizeOff().
|
inline |
Methods to configure the cost function.
Definition at line 208 of file itkSPSAOptimizer.h.
References MaximizeOn().
|
inline |
Methods to configure the cost function.
Definition at line 203 of file itkSPSAOptimizer.h.
References MaximizeOff().
|
static |
Method for creation through the object factory.
|
overrideprotectedvirtual |
PrintSelf method.
Reimplemented from itk::SingleValuedNonLinearOptimizer.
void itk::SPSAOptimizer::ResumeOptimization | ( | ) |
Resume previously stopped optimization with current parameters
|
virtual |
Set/Get A.
|
inline |
|
virtual |
Set/Get alpha.
|
inline |
|
virtual |
Set/Get gamma.
|
virtual |
Methods to configure the cost function.
Referenced by SetMinimize().
|
virtual |
Set/Get the maximum number of iterations.
|
inline |
Methods to configure the cost function.
Definition at line 198 of file itkSPSAOptimizer.h.
References SetMaximize().
|
virtual |
Set/Get the minimum number of iterations
|
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 |
Set/Get a.
Referenced by Seta().
|
virtual |
Set/Get c.
Referenced by Setc().
|
virtual |
Set/Get StateOfConvergenceDecayRate (number between 0 and 1).
|
virtual |
Set/Get Tolerance
|
overridevirtual |
Start optimization.
Reimplemented from itk::Optimizer.
void itk::SPSAOptimizer::StopOptimization | ( | ) |
Stop optimization.
|
private |
Definition at line 326 of file itkSPSAOptimizer.h.
|
private |
Definition at line 327 of file itkSPSAOptimizer.h.
|
protected |
Definition at line 281 of file itkSPSAOptimizer.h.
|
protected |
Definition at line 273 of file itkSPSAOptimizer.h.
|
private |
Definition at line 328 of file itkSPSAOptimizer.h.
|
protected |
Random number generator
Definition at line 284 of file itkSPSAOptimizer.h.
|
protected |
Variables updated during optimization
Definition at line 269 of file itkSPSAOptimizer.h.
|
private |
Definition at line 320 of file itkSPSAOptimizer.h.
|
protected |
Definition at line 271 of file itkSPSAOptimizer.h.
|
private |
Definition at line 319 of file itkSPSAOptimizer.h.
Referenced by GetMinimize().
|
private |
Definition at line 316 of file itkSPSAOptimizer.h.
|
private |
Settings.
Definition at line 315 of file itkSPSAOptimizer.h.
|
private |
Definition at line 321 of file itkSPSAOptimizer.h.
|
private |
Parameters, as described by Spall.
Definition at line 324 of file itkSPSAOptimizer.h.
|
private |
Definition at line 325 of file itkSPSAOptimizer.h.
|
protected |
Definition at line 279 of file itkSPSAOptimizer.h.
|
private |
Definition at line 317 of file itkSPSAOptimizer.h.
|
protected |
Definition at line 275 of file itkSPSAOptimizer.h.
|
protected |
Definition at line 277 of file itkSPSAOptimizer.h.
|
private |
Definition at line 318 of file itkSPSAOptimizer.h.