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

#include <itkAmoebaOptimizer.h>

Detailed Description

Wrap of the vnl_amoeba algorithm.

AmoebaOptimizer is a wrapper around the vnl_amoeba algorithm which is an implementation of the Nelder-Meade downhill simplex problem. For most problems, it is a few times slower than a Levenberg-Marquardt algorithm but does not require derivatives of its cost function. It works by creating a simplex (n+1 points in ND space). The cost function is evaluated at each corner of the simplex. The simplex is then modified (by reflecting a corner about the opposite edge, by shrinking the entire simplex, by contracting one edge of the simplex, or by expanding the simplex) in searching for the minimum of the cost function.

The methods AutomaticInitialSimplex() and SetInitialSimplexDelta() control whether the optimizer defines the initial simplex automatically (by constructing a very small simplex around the initial position) or uses a user supplied simplex size.

The method SetOptimizeWithRestarts() indicates that the amoeba algorithm should be rerun after if converges. This heuristic increases the chances of escaping from a local optimum. Each time the simplex is initialized with the best solution obtained by the previous runs. The edge length is half of that from the previous iteration. The heuristic is terminated if the total number of iterations is greater-equal than the maximal number of iterations (SetMaximumNumberOfIterations) or the difference between the current function value and the best function value is less than a threshold (SetFunctionConvergenceTolerance) and max(|best_parameters_i - current_parameters_i|) is less than a threshold (SetParametersConvergenceTolerance).

ITK Sphinx Examples:
Examples
Examples/RegistrationITKv4/ImageRegistration10.cxx, Examples/RegistrationITKv4/ImageRegistration16.cxx, Examples/RegistrationITKv4/ImageRegistration17.cxx, Examples/RegistrationITKv4/ImageRegistration19.cxx, and SphinxExamples/src/Numerics/Optimizers/AmoebaOptimizer/Code.cxx.

Definition at line 67 of file itkAmoebaOptimizer.h.

+ Inheritance diagram for itk::AmoebaOptimizer:
+ Collaboration diagram for itk::AmoebaOptimizer:

Public Types

using ConstPointer = SmartPointer< const Self >
 
using InternalParametersType = vnl_vector< double >
 
using NumberOfIterationsType = unsigned int
 
using ParametersType = Superclass::ParametersType
 
using Pointer = SmartPointer< Self >
 
using Self = AmoebaOptimizer
 
using Superclass = SingleValuedNonLinearVnlOptimizer
 
- Public Types inherited from itk::SingleValuedNonLinearVnlOptimizer
using CommandType = ReceptorMemberCommand< Self >
 
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = SingleValuedNonLinearVnlOptimizer
 
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

const char * GetNameOfClass () const override
 
vnl_amoeba * GetOptimizer () const
 
std::string GetStopConditionDescription () const override
 
MeasureType GetValue () const
 
void SetCostFunction (SingleValuedCostFunction *costFunction) override
 
void StartOptimization () override
 
virtual void SetMaximumNumberOfIterations (NumberOfIterationsType _arg)
 
virtual NumberOfIterationsType GetMaximumNumberOfIterations () const
 
virtual void SetAutomaticInitialSimplex (bool _arg)
 
virtual void AutomaticInitialSimplexOn ()
 
virtual bool GetAutomaticInitialSimplex () const
 
virtual void SetOptimizeWithRestarts (bool _arg)
 
virtual void OptimizeWithRestartsOn ()
 
virtual bool GetOptimizeWithRestarts () const
 
void SetInitialSimplexDelta (ParametersType initialSimplexDelta, bool automaticInitialSimplex=false)
 
virtual ParametersType GetInitialSimplexDelta () const
 
virtual void SetParametersConvergenceTolerance (double _arg)
 
virtual double GetParametersConvergenceTolerance () const
 
virtual void SetFunctionConvergenceTolerance (double _arg)
 
virtual double GetFunctionConvergenceTolerance () const
 
- Public Member Functions inherited from itk::SingleValuedNonLinearVnlOptimizer
virtual bool CanUseScales () const
 
const char * GetNameOfClass () const override
 
virtual const bool & GetMaximize () const
 
virtual void SetMaximize (bool _arg)
 
virtual void MaximizeOn ()
 
bool GetMinimize () const
 
void SetMinimize (bool v)
 
void MinimizeOn ()
 
void MinimizeOff ()
 
virtual const MeasureTypeGetCachedValue () const
 
virtual const DerivativeTypeGetCachedDerivative () const
 
virtual const ParametersTypeGetCachedCurrentPosition () 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 Types

using CostFunctionAdaptorType = Superclass::CostFunctionAdaptorType
 
- Protected Types inherited from itk::SingleValuedNonLinearVnlOptimizer
using CostFunctionAdaptorType = SingleValuedVnlCostFunctionAdaptor
 

Protected Member Functions

 AmoebaOptimizer ()
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
 ~AmoebaOptimizer () override
 
- Protected Member Functions inherited from itk::SingleValuedNonLinearVnlOptimizer
CostFunctionAdaptorTypeGetCostFunctionAdaptor ()
 
const CostFunctionAdaptorTypeGetCostFunctionAdaptor () const
 
CostFunctionAdaptorTypeGetNonConstCostFunctionAdaptor () const
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
void SetCostFunctionAdaptor (CostFunctionAdaptorType *adaptor)
 
 SingleValuedNonLinearVnlOptimizer ()
 
 ~SingleValuedNonLinearVnlOptimizer () override
 
- 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 ()
 

Private Member Functions

void ValidateSettings ()
 

Private Attributes

bool m_AutomaticInitialSimplex {}
 
CostFunctionType::MeasureType m_FunctionConvergenceTolerance {}
 
ParametersType m_InitialSimplexDelta {}
 
NumberOfIterationsType m_MaximumNumberOfIterations {}
 
bool m_OptimizeWithRestarts {}
 
ParametersType::ValueType m_ParametersConvergenceTolerance {}
 
std::ostringstream m_StopConditionDescription {}
 
std::unique_ptr< vnl_amoeba > m_VnlOptimizer
 

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 76 of file itkAmoebaOptimizer.h.

◆ CostFunctionAdaptorType

using itk::AmoebaOptimizer::CostFunctionAdaptorType = Superclass::CostFunctionAdaptorType
protected

Definition at line 172 of file itkAmoebaOptimizer.h.

◆ InternalParametersType

InternalParameters type alias.

Definition at line 90 of file itkAmoebaOptimizer.h.

◆ NumberOfIterationsType

Definition at line 77 of file itkAmoebaOptimizer.h.

◆ ParametersType

using itk::AmoebaOptimizer::ParametersType = Superclass::ParametersType

Parameters type. It defines a position in the optimization search space.

Definition at line 87 of file itkAmoebaOptimizer.h.

◆ Pointer

Definition at line 75 of file itkAmoebaOptimizer.h.

◆ Self

Standard "Self" type alias.

Definition at line 73 of file itkAmoebaOptimizer.h.

◆ Superclass

Definition at line 74 of file itkAmoebaOptimizer.h.

Constructor & Destructor Documentation

◆ AmoebaOptimizer()

itk::AmoebaOptimizer::AmoebaOptimizer ( )
protected

◆ ~AmoebaOptimizer()

itk::AmoebaOptimizer::~AmoebaOptimizer ( )
overrideprotected

Member Function Documentation

◆ AutomaticInitialSimplexOn()

virtual void itk::AmoebaOptimizer::AutomaticInitialSimplexOn ( )
virtual

Set/Get the mode which determines how the amoeba algorithm defines the initial simplex. Default is AutomaticInitialSimplexOn. If AutomaticInitialSimplex is on, the initial simplex is created with a default size. If AutomaticInitialSimplex is off, then InitialSimplexDelta will be used to define the initial simplex, setting the ith corner of the simplex as [x0[0], x0[1], ..., x0[i]+InitialSimplexDelta[i], ..., x0[d-1]].

◆ GetAutomaticInitialSimplex()

virtual bool itk::AmoebaOptimizer::GetAutomaticInitialSimplex ( ) const
virtual

Set/Get the mode which determines how the amoeba algorithm defines the initial simplex. Default is AutomaticInitialSimplexOn. If AutomaticInitialSimplex is on, the initial simplex is created with a default size. If AutomaticInitialSimplex is off, then InitialSimplexDelta will be used to define the initial simplex, setting the ith corner of the simplex as [x0[0], x0[1], ..., x0[i]+InitialSimplexDelta[i], ..., x0[d-1]].

◆ GetFunctionConvergenceTolerance()

virtual double itk::AmoebaOptimizer::GetFunctionConvergenceTolerance ( ) const
virtual

The optimization algorithm will terminate when the simplex diameter and the difference in cost function values at the corners of the simplex falls below user specified thresholds. The cost function convergence threshold is set via SetFunctionConvergenceTolerance().

◆ GetInitialSimplexDelta()

virtual ParametersType itk::AmoebaOptimizer::GetInitialSimplexDelta ( ) const
virtual

Set/Get the deltas that are used to define the initial simplex when AutomaticInitialSimplex is off.

◆ GetMaximumNumberOfIterations()

virtual NumberOfIterationsType itk::AmoebaOptimizer::GetMaximumNumberOfIterations ( ) const
virtual

Set/Get the maximum number of iterations. The optimization algorithm will terminate after the maximum number of iterations has been reached. The default value is defined as DEFAULT_MAXIMAL_NUMBER_OF_ITERATIONS.

◆ GetNameOfClass()

const char* itk::AmoebaOptimizer::GetNameOfClass ( ) const
overridevirtual
See also
LightObject::GetNameOfClass()

Reimplemented from itk::Object.

◆ GetOptimizer()

vnl_amoeba* itk::AmoebaOptimizer::GetOptimizer ( ) const

Method for getting access to the internal optimizer.

◆ GetOptimizeWithRestarts()

virtual bool itk::AmoebaOptimizer::GetOptimizeWithRestarts ( ) const
virtual

Set/Get the mode that determines if we want to use multiple runs of the Amoeba optimizer. If true, then the optimizer is rerun after it converges. The additional runs are performed using a simplex initialized with the best solution obtained by the previous runs. The edge length is half of that from the previous iteration.

◆ GetParametersConvergenceTolerance()

virtual double itk::AmoebaOptimizer::GetParametersConvergenceTolerance ( ) const
virtual

The optimization algorithm will terminate when the simplex diameter and the difference in cost function values at the corners of the simplex falls below user specified thresholds. The simplex diameter threshold is set via SetParametersConvergenceTolerance().

◆ GetStopConditionDescription()

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

Report the reason for stopping.

Reimplemented from itk::Optimizer.

◆ GetValue()

MeasureType itk::AmoebaOptimizer::GetValue ( ) const

Return Current Value

◆ New()

static Pointer itk::AmoebaOptimizer::New ( )
static

Method for creation through the object factory.

◆ OptimizeWithRestartsOn()

virtual void itk::AmoebaOptimizer::OptimizeWithRestartsOn ( )
virtual

Set/Get the mode that determines if we want to use multiple runs of the Amoeba optimizer. If true, then the optimizer is rerun after it converges. The additional runs are performed using a simplex initialized with the best solution obtained by the previous runs. The edge length is half of that from the previous iteration.

◆ PrintSelf()

void itk::AmoebaOptimizer::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::Object.

◆ SetAutomaticInitialSimplex()

virtual void itk::AmoebaOptimizer::SetAutomaticInitialSimplex ( bool  _arg)
virtual

Set/Get the mode which determines how the amoeba algorithm defines the initial simplex. Default is AutomaticInitialSimplexOn. If AutomaticInitialSimplex is on, the initial simplex is created with a default size. If AutomaticInitialSimplex is off, then InitialSimplexDelta will be used to define the initial simplex, setting the ith corner of the simplex as [x0[0], x0[1], ..., x0[i]+InitialSimplexDelta[i], ..., x0[d-1]].

◆ SetCostFunction()

void itk::AmoebaOptimizer::SetCostFunction ( SingleValuedCostFunction costFunction)
overridevirtual

Plug in a Cost Function into the optimizer

Implements itk::SingleValuedNonLinearVnlOptimizer.

◆ SetFunctionConvergenceTolerance()

virtual void itk::AmoebaOptimizer::SetFunctionConvergenceTolerance ( double  _arg)
virtual

The optimization algorithm will terminate when the simplex diameter and the difference in cost function values at the corners of the simplex falls below user specified thresholds. The cost function convergence threshold is set via SetFunctionConvergenceTolerance().

◆ SetInitialSimplexDelta()

void itk::AmoebaOptimizer::SetInitialSimplexDelta ( ParametersType  initialSimplexDelta,
bool  automaticInitialSimplex = false 
)

Set/Get the deltas that are used to define the initial simplex when AutomaticInitialSimplex is off.

◆ SetMaximumNumberOfIterations()

virtual void itk::AmoebaOptimizer::SetMaximumNumberOfIterations ( NumberOfIterationsType  _arg)
virtual

Set/Get the maximum number of iterations. The optimization algorithm will terminate after the maximum number of iterations has been reached. The default value is defined as DEFAULT_MAXIMAL_NUMBER_OF_ITERATIONS.

◆ SetOptimizeWithRestarts()

virtual void itk::AmoebaOptimizer::SetOptimizeWithRestarts ( bool  _arg)
virtual

Set/Get the mode that determines if we want to use multiple runs of the Amoeba optimizer. If true, then the optimizer is rerun after it converges. The additional runs are performed using a simplex initialized with the best solution obtained by the previous runs. The edge length is half of that from the previous iteration.

◆ SetParametersConvergenceTolerance()

virtual void itk::AmoebaOptimizer::SetParametersConvergenceTolerance ( double  _arg)
virtual

The optimization algorithm will terminate when the simplex diameter and the difference in cost function values at the corners of the simplex falls below user specified thresholds. The simplex diameter threshold is set via SetParametersConvergenceTolerance().

◆ StartOptimization()

void itk::AmoebaOptimizer::StartOptimization ( )
overridevirtual

Start optimization with an initial value.

Reimplemented from itk::Optimizer.

◆ ValidateSettings()

void itk::AmoebaOptimizer::ValidateSettings ( )
private

Check that the settings are valid. If not throw an exception.

Member Data Documentation

◆ m_AutomaticInitialSimplex

bool itk::AmoebaOptimizer::m_AutomaticInitialSimplex {}
private

Definition at line 182 of file itkAmoebaOptimizer.h.

◆ m_FunctionConvergenceTolerance

CostFunctionType::MeasureType itk::AmoebaOptimizer::m_FunctionConvergenceTolerance {}
private

Definition at line 181 of file itkAmoebaOptimizer.h.

◆ m_InitialSimplexDelta

ParametersType itk::AmoebaOptimizer::m_InitialSimplexDelta {}
private

Definition at line 183 of file itkAmoebaOptimizer.h.

◆ m_MaximumNumberOfIterations

NumberOfIterationsType itk::AmoebaOptimizer::m_MaximumNumberOfIterations {}
private

Definition at line 179 of file itkAmoebaOptimizer.h.

◆ m_OptimizeWithRestarts

bool itk::AmoebaOptimizer::m_OptimizeWithRestarts {}
private

Definition at line 184 of file itkAmoebaOptimizer.h.

◆ m_ParametersConvergenceTolerance

ParametersType::ValueType itk::AmoebaOptimizer::m_ParametersConvergenceTolerance {}
private

Definition at line 180 of file itkAmoebaOptimizer.h.

◆ m_StopConditionDescription

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

Definition at line 187 of file itkAmoebaOptimizer.h.

◆ m_VnlOptimizer

std::unique_ptr<vnl_amoeba> itk::AmoebaOptimizer::m_VnlOptimizer
private

Definition at line 185 of file itkAmoebaOptimizer.h.


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