ITK
6.0.0
Insight Toolkit
|
#include <itkAmoebaOptimizerv4.h>
Wrap of the vnl_amoeba algorithm.
AmoebaOptimizerv4 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 (SetNumberOfIterations) 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).
Definition at line 62 of file itkAmoebaOptimizerv4.h.
Public Member Functions | |
const char * | GetNameOfClass () const override |
vnl_amoeba * | GetOptimizer () const |
std::string | GetStopConditionDescription () const override |
void | SetMetric (MetricType *metric) override |
void | StartOptimization (bool doOnlyInitialization=false) override |
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::SingleValuedNonLinearVnlOptimizerv4 | |
const char * | GetNameOfClass () const override |
StopConditionReturnStringType | GetStopConditionDescription () const override=0 |
void | SetMetric (MetricType *metric) override=0 |
void | StartOptimization (bool doOnlyInitialization=false) override |
virtual const DerivativeType & | GetCachedDerivative () const |
virtual const ParametersType & | GetCachedCurrentPosition () const |
Public Member Functions inherited from itk::ObjectToObjectOptimizerBaseTemplate< double > | |
virtual bool | CanUseScales () const |
virtual SizeValueType | GetCurrentIteration () const |
virtual const MeasureType & | GetCurrentMetricValue () const |
virtual const ParametersType & | GetCurrentPosition () const |
const char * | GetNameOfClass () const override |
virtual SizeValueType | GetNumberOfIterations () const |
virtual const ThreadIdType & | GetNumberOfWorkUnits () const |
virtual const ScalesType & | GetScales () const |
virtual const bool & | GetScalesAreIdentity () const |
bool | GetScalesInitialized () const |
virtual StopConditionReturnStringType | GetStopConditionDescription () const=0 |
virtual const MeasureType & | GetValue () const |
virtual const ScalesType & | GetWeights () const |
virtual const bool & | GetWeightsAreIdentity () const |
virtual void | SetNumberOfIterations (SizeValueType _arg) |
virtual void | SetNumberOfWorkUnits (ThreadIdType number) |
virtual void | SetScalesEstimator (ScalesEstimatorType *_arg) |
virtual void | SetWeights (ScalesType _arg) |
virtual void | StartOptimization (bool doOnlyInitialization=false) |
virtual void | SetMetric (MetricType *_arg) |
virtual MetricType * | GetModifiableMetric () |
virtual void | SetScales (const ScalesType &scales) |
virtual void | SetDoEstimateScales (bool _arg) |
virtual const bool & | GetDoEstimateScales () const |
virtual void | DoEstimateScalesOn () |
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 |
Command * | GetCommand (unsigned long tag) |
bool | GetDebug () const |
MetaDataDictionary & | GetMetaDataDictionary () |
const MetaDataDictionary & | GetMetaDataDictionary () const |
virtual ModifiedTimeType | GetMTime () const |
const char * | GetNameOfClass () const override |
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 |
Public Member Functions inherited from itk::LightObject | |
Pointer | Clone () const |
virtual Pointer | CreateAnother () const |
virtual void | Delete () |
virtual const char * | GetNameOfClass () const |
virtual int | GetReferenceCount () const |
void | Print (std::ostream &os, Indent indent=0) const |
virtual void | Register () const |
virtual void | SetReferenceCount (int) |
virtual void | UnRegister () const noexcept |
Static Public Member Functions | |
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::SingleValuedNonLinearVnlOptimizerv4 | |
using | CostFunctionAdaptorType = SingleValuedVnlCostFunctionAdaptorv4 |
Protected Member Functions | |
AmoebaOptimizerv4 () | |
void | PrintSelf (std::ostream &os, Indent indent) const override |
~AmoebaOptimizerv4 () override | |
Protected Member Functions inherited from itk::SingleValuedNonLinearVnlOptimizerv4 | |
CostFunctionAdaptorType * | GetCostFunctionAdaptor () |
const CostFunctionAdaptorType * | GetCostFunctionAdaptor () const |
CostFunctionAdaptorType * | GetNonConstCostFunctionAdaptor () const |
void | PrintSelf (std::ostream &os, Indent indent) const override |
void | SetCostFunctionAdaptor (CostFunctionAdaptorType *adaptor) |
SingleValuedNonLinearVnlOptimizerv4 () | |
~SingleValuedNonLinearVnlOptimizerv4 () override | |
Protected Member Functions inherited from itk::ObjectToObjectOptimizerBaseTemplate< double > | |
void | PrintSelf (std::ostream &os, Indent indent) const override |
ObjectToObjectOptimizerBaseTemplate () | |
~ObjectToObjectOptimizerBaseTemplate () override | |
Protected Member Functions inherited from itk::Object | |
Object () | |
bool | PrintObservers (std::ostream &os, Indent indent) const |
void | PrintSelf (std::ostream &os, Indent indent) const override |
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 | PrintSelf (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 {} |
MeasureType | m_FunctionConvergenceTolerance {} |
ParametersType | m_InitialSimplexDelta {} |
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::ObjectToObjectOptimizerBaseTemplate< double > | |
SizeValueType | m_CurrentIteration |
MeasureType | m_CurrentMetricValue |
bool | m_DoEstimateScales |
MetricTypePointer | m_Metric |
SizeValueType | m_NumberOfIterations |
ThreadIdType | m_NumberOfWorkUnits |
ScalesType | m_Scales |
bool | m_ScalesAreIdentity |
ScalesEstimatorType::Pointer | m_ScalesEstimator |
ScalesType | m_Weights |
bool | m_WeightsAreIdentity |
Protected Attributes inherited from itk::LightObject | |
std::atomic< int > | m_ReferenceCount {} |
using itk::AmoebaOptimizerv4::ConstPointer = SmartPointer<const Self> |
Definition at line 71 of file itkAmoebaOptimizerv4.h.
|
protected |
Definition at line 155 of file itkAmoebaOptimizerv4.h.
using itk::AmoebaOptimizerv4::InternalParametersType = vnl_vector<double> |
InternalParameters type alias.
Definition at line 84 of file itkAmoebaOptimizerv4.h.
Parameters type. It defines a position in the optimization search space.
Definition at line 81 of file itkAmoebaOptimizerv4.h.
Definition at line 70 of file itkAmoebaOptimizerv4.h.
Standard "Self" type alias.
Definition at line 68 of file itkAmoebaOptimizerv4.h.
Definition at line 69 of file itkAmoebaOptimizerv4.h.
|
protected |
|
overrideprotected |
|
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]].
|
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]].
|
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().
|
virtual |
Set/Get the deltas that are used to define the initial simplex when AutomaticInitialSimplex is off.
|
overridevirtual |
Reimplemented from itk::Object.
vnl_amoeba * itk::AmoebaOptimizerv4::GetOptimizer | ( | ) | const |
Method for getting access to the internal optimizer.
|
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.
|
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().
|
overridevirtual |
Report the reason for stopping.
Implements itk::SingleValuedNonLinearVnlOptimizerv4.
|
static |
Method for creation through the object factory.
|
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.
|
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.
|
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]].
|
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().
void itk::AmoebaOptimizerv4::SetInitialSimplexDelta | ( | ParametersType | initialSimplexDelta, |
bool | automaticInitialSimplex = false |
||
) |
Set/Get the deltas that are used to define the initial simplex when AutomaticInitialSimplex is off.
|
overridevirtual |
Plug in a Cost Function into the optimizer
Implements itk::SingleValuedNonLinearVnlOptimizerv4.
|
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.
|
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().
|
overridevirtual |
Start optimization with an initial value.
Reimplemented from itk::ObjectToObjectOptimizerBaseTemplate< double >.
|
private |
Check that the settings are valid. If not throw an exception.
|
private |
Definition at line 164 of file itkAmoebaOptimizerv4.h.
|
private |
Definition at line 163 of file itkAmoebaOptimizerv4.h.
|
private |
Definition at line 165 of file itkAmoebaOptimizerv4.h.
|
private |
Definition at line 166 of file itkAmoebaOptimizerv4.h.
|
private |
Definition at line 162 of file itkAmoebaOptimizerv4.h.
|
private |
Definition at line 169 of file itkAmoebaOptimizerv4.h.
|
private |
Definition at line 167 of file itkAmoebaOptimizerv4.h.