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 <itkExhaustiveOptimizer.h>

Detailed Description

Optimizer that fully samples a grid on the parametric space.

This optimizer is equivalent to an exhaustive search in a discrete grid defined over the parametric space. The grid is centered on the initial position. The subdivisions of the grid along each one of the dimensions of the parametric space is defined by an array of number of steps.

A typical use is to plot the metric space to get an idea of how noisy it is. An example is given below, where it is desired to plot the metric space with respect to translations along x, y and z in a 3D registration application: Here it is assumed that the transform is TranslationTransform.

OptimizerType::StepsType steps( m_Transform->GetNumberOfParameters() );
steps[0] = 10;
steps[1] = 10;
steps[2] = 10;
m_Optimizer->SetNumberOfSteps( steps );
m_Optimizer->SetStepLength( 2 );

The optimizer throws IterationEvents after every iteration. We use this to plot the metric space in an image as follows:

if( itk::IterationEvent().CheckEvent(& event ) )
{
IndexType index;
index[0] = m_Optimizer->GetCurrentIndex()[0];
index[1] = m_Optimizer->GetCurrentIndex()[1];
index[2] = m_Optimizer->GetCurrentIndex()[2];
image->SetPixel( index, m_Optimizer->GetCurrentValue() );
}

The image size is expected to be 11 x 11 x 11.

If you wish to use different step lengths along each parametric axis, you can use the SetScales() method. This accepts an array, each element represents the number of subdivisions per step length. For instance scales of [0.5 1 4] along with a step length of 2 will cause the optimizer to search the metric space on a grid with x,y,z spacing of [1 2 8].

The number of samples for each dimension of the parameter grid are influenced by both the scales and the number of steps along each dimension:

parameter_samples[d] = stepLength*(2*numberOfSteps[d]+1)*scaling[d]

start_parameter[d] = - stepLength * scaling[d] * numberOfSteps[d] end_parameter[d] = + stepLength * scaling[d] * numberOfSteps[d]

ITK Sphinx Examples:
  • <a href=
  • <a href=

Definition at line 88 of file itkExhaustiveOptimizer.h.

+ Inheritance diagram for itk::ExhaustiveOptimizer:
+ Collaboration diagram for itk::ExhaustiveOptimizer:

Public Types

using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = ExhaustiveOptimizer
 
using StepsType = Array< SizeValueType >
 
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 const ParametersTypeGetCurrentIndex () const
 
virtual const MeasureTypeGetCurrentValue () const
 
virtual const MeasureTypeGetMaximumMetricValue () const
 
virtual const ParametersTypeGetMaximumMetricValuePosition () const
 
virtual const SizeValueTypeGetMaximumNumberOfIterations () const
 
virtual const MeasureTypeGetMinimumMetricValue () const
 
virtual const ParametersTypeGetMinimumMetricValuePosition () const
 
const char * GetNameOfClass () const override
 
virtual const StepsTypeGetNumberOfSteps () const
 
virtual const double & GetStepLength () const
 
std::string GetStopConditionDescription () const override
 
void ResumeWalking ()
 
virtual void SetNumberOfSteps (StepsType _arg)
 
virtual void SetStepLength (double _arg)
 
void StartOptimization () override
 
void StartWalking ()
 
void StopWalking ()
 
- Public Member Functions inherited from itk::SingleValuedNonLinearOptimizer
virtual CostFunctionTypeGetModifiableCostFunction ()
 
const char * GetNameOfClass () const override
 
MeasureType GetValue (const ParametersType &parameters) const
 
virtual void SetCostFunction (CostFunctionType *costFunction)
 
const char * GetNameOfClass () const override
 
- Public Member Functions inherited from itk::Optimizer
virtual const ParametersTypeGetCurrentPosition () const
 
virtual const ParametersTypeGetInitialPosition () const
 
const char * GetNameOfClass () const override
 
virtual std::string GetStopConditionDescription () const
 
virtual void SetInitialPosition (const ParametersType &param)
 
void SetScales (const ScalesType &scales)
 
virtual void StartOptimization ()
 
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
 
const char * GetNameOfClass () const override
 
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 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::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

void AdvanceOneStep ()
 
 ExhaustiveOptimizer ()
 
void IncrementIndex (ParametersType &newPosition)
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
 ~ExhaustiveOptimizer () override=default
 
- Protected Member Functions inherited from itk::SingleValuedNonLinearOptimizer
void PrintSelf (std::ostream &os, Indent indent) const override
 
 SingleValuedNonLinearOptimizer ()
 
 ~SingleValuedNonLinearOptimizer () override=default
 
- Protected Member Functions inherited from itk::NonLinearOptimizer
 NonLinearOptimizer ()=default
 
 ~NonLinearOptimizer () override
 
- Protected Member Functions inherited from itk::Optimizer
 Optimizer ()
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
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
 
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 ()
 

Protected Attributes

ParametersType m_CurrentIndex {}
 
SizeValueType m_CurrentIteration { 0 }
 
unsigned int m_CurrentParameter { 0 }
 
MeasureType m_CurrentValue { 0 }
 
MeasureType m_MaximumMetricValue { itk::NumericTraits<MeasureType>::max() }
 
ParametersType m_MaximumMetricValuePosition {}
 
SizeValueType m_MaximumNumberOfIterations { 1 }
 
MeasureType m_MinimumMetricValue { itk::NumericTraits<MeasureType>::Zero }
 
ParametersType m_MinimumMetricValuePosition {}
 
StepsType m_NumberOfSteps {}
 
double m_StepLength { 1.0 }
 
bool m_Stop { false }
 
- 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

std::ostringstream m_StopConditionDescription {}
 

Member Typedef Documentation

◆ ConstPointer

Definition at line 97 of file itkExhaustiveOptimizer.h.

◆ Pointer

Definition at line 96 of file itkExhaustiveOptimizer.h.

◆ Self

Standard "Self" type alias.

Definition at line 94 of file itkExhaustiveOptimizer.h.

◆ StepsType

Definition at line 99 of file itkExhaustiveOptimizer.h.

◆ Superclass

Definition at line 95 of file itkExhaustiveOptimizer.h.

Constructor & Destructor Documentation

◆ ExhaustiveOptimizer()

itk::ExhaustiveOptimizer::ExhaustiveOptimizer ( )
protected

◆ ~ExhaustiveOptimizer()

itk::ExhaustiveOptimizer::~ExhaustiveOptimizer ( )
overrideprotecteddefault

Member Function Documentation

◆ AdvanceOneStep()

void itk::ExhaustiveOptimizer::AdvanceOneStep ( )
protected

Advance to the next grid position.

◆ GetCurrentIndex()

virtual const ParametersType & itk::ExhaustiveOptimizer::GetCurrentIndex ( ) const
virtual

◆ GetCurrentValue()

virtual const MeasureType & itk::ExhaustiveOptimizer::GetCurrentValue ( ) const
virtual

◆ GetMaximumMetricValue()

virtual const MeasureType & itk::ExhaustiveOptimizer::GetMaximumMetricValue ( ) const
virtual

◆ GetMaximumMetricValuePosition()

virtual const ParametersType & itk::ExhaustiveOptimizer::GetMaximumMetricValuePosition ( ) const
virtual

◆ GetMaximumNumberOfIterations()

virtual const SizeValueType & itk::ExhaustiveOptimizer::GetMaximumNumberOfIterations ( ) const
virtual

◆ GetMinimumMetricValue()

virtual const MeasureType & itk::ExhaustiveOptimizer::GetMinimumMetricValue ( ) const
virtual

◆ GetMinimumMetricValuePosition()

virtual const ParametersType & itk::ExhaustiveOptimizer::GetMinimumMetricValuePosition ( ) const
virtual

◆ GetNameOfClass()

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

Reimplemented from itk::Object.

◆ GetNumberOfSteps()

virtual const StepsType & itk::ExhaustiveOptimizer::GetNumberOfSteps ( ) const
virtual

◆ GetStepLength()

virtual const double & itk::ExhaustiveOptimizer::GetStepLength ( ) const
virtual

◆ GetStopConditionDescription()

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

Get the reason for termination

Reimplemented from itk::Optimizer.

◆ IncrementIndex()

void itk::ExhaustiveOptimizer::IncrementIndex ( ParametersType newPosition)
protected

◆ New()

static Pointer itk::ExhaustiveOptimizer::New ( )
static

Method for creation through the object factory.

◆ PrintSelf()

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

◆ ResumeWalking()

void itk::ExhaustiveOptimizer::ResumeWalking ( )

Resume optimization.

◆ SetNumberOfSteps()

virtual void itk::ExhaustiveOptimizer::SetNumberOfSteps ( StepsType  _arg)
virtual

◆ SetStepLength()

virtual void itk::ExhaustiveOptimizer::SetStepLength ( double  _arg)
virtual

◆ StartOptimization()

void itk::ExhaustiveOptimizer::StartOptimization ( )
overridevirtual

Start optimization.

Reimplemented from itk::Optimizer.

◆ StartWalking()

void itk::ExhaustiveOptimizer::StartWalking ( )

◆ StopWalking()

void itk::ExhaustiveOptimizer::StopWalking ( )

Stop optimization.

Member Data Documentation

◆ m_CurrentIndex

ParametersType itk::ExhaustiveOptimizer::m_CurrentIndex {}
protected

Definition at line 163 of file itkExhaustiveOptimizer.h.

◆ m_CurrentIteration

SizeValueType itk::ExhaustiveOptimizer::m_CurrentIteration { 0 }
protected

Definition at line 155 of file itkExhaustiveOptimizer.h.

◆ m_CurrentParameter

unsigned int itk::ExhaustiveOptimizer::m_CurrentParameter { 0 }
protected

Definition at line 159 of file itkExhaustiveOptimizer.h.

◆ m_CurrentValue

MeasureType itk::ExhaustiveOptimizer::m_CurrentValue { 0 }
protected

Definition at line 151 of file itkExhaustiveOptimizer.h.

◆ m_MaximumMetricValue

MeasureType itk::ExhaustiveOptimizer::m_MaximumMetricValue { itk::NumericTraits<MeasureType>::max() }
protected

Definition at line 167 of file itkExhaustiveOptimizer.h.

◆ m_MaximumMetricValuePosition

ParametersType itk::ExhaustiveOptimizer::m_MaximumMetricValuePosition {}
protected

Definition at line 173 of file itkExhaustiveOptimizer.h.

◆ m_MaximumNumberOfIterations

SizeValueType itk::ExhaustiveOptimizer::m_MaximumNumberOfIterations { 1 }
protected

Definition at line 165 of file itkExhaustiveOptimizer.h.

◆ m_MinimumMetricValue

MeasureType itk::ExhaustiveOptimizer::m_MinimumMetricValue { itk::NumericTraits<MeasureType>::Zero }
protected

Definition at line 169 of file itkExhaustiveOptimizer.h.

◆ m_MinimumMetricValuePosition

ParametersType itk::ExhaustiveOptimizer::m_MinimumMetricValuePosition {}
protected

Definition at line 171 of file itkExhaustiveOptimizer.h.

◆ m_NumberOfSteps

StepsType itk::ExhaustiveOptimizer::m_NumberOfSteps {}
protected

Definition at line 153 of file itkExhaustiveOptimizer.h.

◆ m_StepLength

double itk::ExhaustiveOptimizer::m_StepLength { 1.0 }
protected

Definition at line 161 of file itkExhaustiveOptimizer.h.

◆ m_Stop

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

Definition at line 157 of file itkExhaustiveOptimizer.h.

◆ m_StopConditionDescription

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

Definition at line 176 of file itkExhaustiveOptimizer.h.


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