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

#include <itkInitializationBiasedParticleSwarmOptimizer.h>

Detailed Description

Implementation of a biased/regularized Particle Swarm Optimization (PSO) algorithm.

This PSO algorithm was originally described in: M. P. Wachowiak, R. Smolikova, Y. Zheng, J. M. Zurada, A. S. Elmaghraby, "An approach to multimodal biomedical image registration utilizing particle swarm optimization", IEEE Transactions on Evolutionary Computing, vol. 8(3): 289-301, 2004.

The algorithm uses a stochastic optimization approach. Optimization is performed by maintaining a swarm (flock) of particles that traverse the parameter space, searching for the optimal function value. Associated with each particle are its location and speed, in parameter space. A particle's next location is determined by its current location, its current speed, the location of the best function value it previously encountered, the location of the best function value the particles in its neighborhood previously encountered and the initial position the user specified.

The assumption is that the user's initial parameter settings are close to the minimum, which is often the case for registration. The initial parameter values are incorporated into the PSO's update rules, biasing the search in their direction. The swarms update equations are thus:

\(v_i(t+1) = wv_i(t) + c_1u_1(p_i-x_i(t)) + c_2u_2(p_g-x_i(t)) + c_3u_3(x_{init} - x_i(t))\) \(x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1))\)

where \(u_i\) are \(~U(0,1)\) and \(w,c_1,c_2, c_3\) are user selected weights, and c_3 is linearly decreased per iteration so that it is in \(c_3=initial, 0\).

Swarm initialization is performed within the user supplied parameter bounds using a uniform distribution or a normal distribution centered on the initial parameter values supplied by the user, \(x_{init}\). The search terminates when the maximal number of iterations has been reached or when the change in the best value in the past \(g\) generations is below a threshold and the swarm has collapsed (i.e. particles are close to each other in parameter space).

Note
This implementation only performs minimization.

Definition at line 73 of file itkInitializationBiasedParticleSwarmOptimizer.h.

+ Inheritance diagram for itk::InitializationBiasedParticleSwarmOptimizer:
+ Collaboration diagram for itk::InitializationBiasedParticleSwarmOptimizer:

Public Types

using CoefficientType = double
 
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = InitializationBiasedParticleSwarmOptimizer
 
using Superclass = ParticleSwarmOptimizerBase
 
- Public Types inherited from itk::ParticleSwarmOptimizerBase
using ConstPointer = SmartPointer< const Self >
 
using MeasureType = CostFunctionType::MeasureType
 
using NumberOfGenerationsType = unsigned int
 
using NumberOfIterationsType = unsigned int
 
using NumberOfParticlesType = unsigned int
 
using ParameterBoundsType = std::vector< std::pair< ParametersType::ValueType, ParametersType::ValueType > >
 
using Pointer = SmartPointer< Self >
 
using RandomVariateGeneratorType = Statistics::MersenneTwisterRandomVariateGenerator
 
using Self = ParticleSwarmOptimizerBase
 
using Superclass = SingleValuedNonLinearOptimizer
 
using SwarmType = std::vector< ParticleData >
 
using ValueType = ParametersType::ValueType
 
- 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
 
virtual void SetInertiaCoefficient (CoefficientType _arg)
 
virtual CoefficientType GetInertiaCoefficient ()
 
virtual void SetPersonalCoefficient (CoefficientType _arg)
 
virtual CoefficientType GetPersonalCoefficient ()
 
virtual void SetGlobalCoefficient (CoefficientType _arg)
 
virtual CoefficientType GetGlobalCoefficient ()
 
virtual void SetInitializationCoefficient (CoefficientType _arg)
 
virtual CoefficientType GetInitializationCoefficient ()
 
- Public Member Functions inherited from itk::ParticleSwarmOptimizerBase
virtual MeasureType GetFunctionConvergenceTolerance ()
 
const char * GetNameOfClass () const override
 
ParameterBoundsType GetParameterBounds () const
 
const std::string GetStopConditionDescription () const override
 
MeasureType GetValue () const
 
void PrintSwarm (std::ostream &os, Indent indent) const
 
virtual void SetFunctionConvergenceTolerance (MeasureType _arg)
 
void StartOptimization () override
 
virtual void SetInitializeNormalDistribution (bool _arg)
 
virtual bool GetInitializeNormalDistribution ()
 
virtual void InitializeNormalDistributionOn ()
 
void SetInitialSwarm (const SwarmType &initialSwarm)
 
void ClearSwarm ()
 
virtual void SetPrintSwarm (bool _arg)
 
virtual bool GetPrintSwarm ()
 
virtual void PrintSwarmOn ()
 
void SetNumberOfParticles (NumberOfParticlesType n)
 
virtual NumberOfParticlesType GetNumberOfParticles ()
 
virtual void SetMaximalNumberOfIterations (NumberOfIterationsType _arg)
 
virtual NumberOfIterationsType GetMaximalNumberOfIterations ()
 
virtual void SetNumberOfGenerationsWithMinimalImprovement (NumberOfGenerationsType _arg)
 
virtual NumberOfGenerationsType GetNumberOfGenerationsWithMinimalImprovement ()
 
virtual void SetParameterBounds (ParameterBoundsType &bounds)
 
void SetParameterBounds (std::pair< ParametersType::ValueType, ParametersType::ValueType > &bounds, unsigned int n)
 
void SetParametersConvergenceTolerance (ValueType convergenceTolerance, unsigned int sz)
 
virtual void SetParametersConvergenceTolerance (ParametersType _arg)
 
virtual ParametersType GetParametersConvergenceTolerance ()
 
virtual double GetPercentageParticlesConverged ()
 
virtual void SetPercentageParticlesConverged (double _arg)
 
virtual void SetSeed (RandomVariateGeneratorType::IntegerType _arg)
 
virtual RandomVariateGeneratorType::IntegerType GetSeed ()
 
virtual void SetUseSeed (bool _arg)
 
virtual bool GetUseSeed ()
 
virtual void UseSeedOn ()
 
- 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)
 
- 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 *)
 
unsigned long AddObserver (const EventObject &event, Command *) 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)
 
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 Member Functions

 InitializationBiasedParticleSwarmOptimizer ()
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
void UpdateSwarm () override
 
 ~InitializationBiasedParticleSwarmOptimizer () override=default
 
- Protected Member Functions inherited from itk::ParticleSwarmOptimizerBase
void FileInitialization ()
 
virtual void Initialize ()
 
 ParticleSwarmOptimizerBase ()
 
void PrintParamtersType (const ParametersType &x, std::ostream &os) const
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
void RandomInitialization ()
 
virtual void ValidateSettings ()
 
 ~ParticleSwarmOptimizerBase () override
 
- 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 ()
 
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 Attributes

ParametersType::ValueType m_GlobalCoefficient {}
 
ParametersType::ValueType m_InertiaCoefficient {}
 
ParametersType::ValueType m_InitializationCoefficient {}
 
ParametersType::ValueType m_PersonalCoefficient {}
 

Additional Inherited Members

- Protected Attributes inherited from itk::ParticleSwarmOptimizerBase
CostFunctionType::MeasureType m_FunctionBestValue { 0 }
 
std::vector< MeasureTypem_FunctionBestValueMemory {}
 
CostFunctionType::MeasureType m_FunctionConvergenceTolerance {}
 
bool m_InitializeNormalDistribution {}
 
NumberOfIterationsType m_IterationIndex { 0 }
 
NumberOfIterationsType m_MaximalNumberOfIterations {}
 
NumberOfGenerationsType m_NumberOfGenerationsWithMinimalImprovement {}
 
NumberOfParticlesType m_NumberOfParticles {}
 
ParameterBoundsType m_ParameterBounds {}
 
ParametersType m_ParametersBestValue {}
 
ParametersType m_ParametersConvergenceTolerance {}
 
std::vector< ParticleDatam_Particles {}
 
double m_PercentageParticlesConverged {}
 
bool m_PrintSwarm {}
 
RandomVariateGeneratorType::IntegerType m_Seed {}
 
std::ostringstream m_StopConditionDescription {}
 
bool m_UseSeed {}
 
- 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

◆ CoefficientType

◆ ConstPointer

◆ Pointer

◆ Self

Standard "Self" type alias.

Definition at line 79 of file itkInitializationBiasedParticleSwarmOptimizer.h.

◆ Superclass

Constructor & Destructor Documentation

◆ InitializationBiasedParticleSwarmOptimizer()

itk::InitializationBiasedParticleSwarmOptimizer::InitializationBiasedParticleSwarmOptimizer ( )
protected

◆ ~InitializationBiasedParticleSwarmOptimizer()

itk::InitializationBiasedParticleSwarmOptimizer::~InitializationBiasedParticleSwarmOptimizer ( )
overrideprotecteddefault

Member Function Documentation

◆ GetGlobalCoefficient()

virtual CoefficientType itk::InitializationBiasedParticleSwarmOptimizer::GetGlobalCoefficient ( )
virtual

The Particle swarm optimizer uses the following update formula:

\[c_3 = c_{3initial}(1.0 - IterationIndex/MaximalNumberOfIterations)\]

\[v_i(t+1) = w*v_i(t) + c_1*uniform(0,1)*(p_i-x_i(t)) + c_2*uniform(0,1)*(p_g-x_i(t)) + c_3*uniform(0,1)*(x_{init}-x_i(t))\]

\[x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1))\]

where \(w\) - inertia constant \(c_1\) - personal coefficient \(c_2\) - global coefficient \(c_3\) - initial location coefficient \(p_i\) - parameters yielding the best function value obtained by this particle \(p_g\) - parameters yielding the best function value obtained by all particles \(x_{init}\) - initial parameter values provided by user

◆ GetInertiaCoefficient()

virtual CoefficientType itk::InitializationBiasedParticleSwarmOptimizer::GetInertiaCoefficient ( )
virtual

The Particle swarm optimizer uses the following update formula:

\[c_3 = c_{3initial}(1.0 - IterationIndex/MaximalNumberOfIterations)\]

\[v_i(t+1) = w*v_i(t) + c_1*uniform(0,1)*(p_i-x_i(t)) + c_2*uniform(0,1)*(p_g-x_i(t)) + c_3*uniform(0,1)*(x_{init}-x_i(t))\]

\[x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1))\]

where \(w\) - inertia constant \(c_1\) - personal coefficient \(c_2\) - global coefficient \(c_3\) - initial location coefficient \(p_i\) - parameters yielding the best function value obtained by this particle \(p_g\) - parameters yielding the best function value obtained by all particles \(x_{init}\) - initial parameter values provided by user

◆ GetInitializationCoefficient()

virtual CoefficientType itk::InitializationBiasedParticleSwarmOptimizer::GetInitializationCoefficient ( )
virtual

The Particle swarm optimizer uses the following update formula:

\[c_3 = c_{3initial}(1.0 - IterationIndex/MaximalNumberOfIterations)\]

\[v_i(t+1) = w*v_i(t) + c_1*uniform(0,1)*(p_i-x_i(t)) + c_2*uniform(0,1)*(p_g-x_i(t)) + c_3*uniform(0,1)*(x_{init}-x_i(t))\]

\[x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1))\]

where \(w\) - inertia constant \(c_1\) - personal coefficient \(c_2\) - global coefficient \(c_3\) - initial location coefficient \(p_i\) - parameters yielding the best function value obtained by this particle \(p_g\) - parameters yielding the best function value obtained by all particles \(x_{init}\) - initial parameter values provided by user

◆ GetNameOfClass()

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

Reimplemented from itk::Object.

◆ GetPersonalCoefficient()

virtual CoefficientType itk::InitializationBiasedParticleSwarmOptimizer::GetPersonalCoefficient ( )
virtual

The Particle swarm optimizer uses the following update formula:

\[c_3 = c_{3initial}(1.0 - IterationIndex/MaximalNumberOfIterations)\]

\[v_i(t+1) = w*v_i(t) + c_1*uniform(0,1)*(p_i-x_i(t)) + c_2*uniform(0,1)*(p_g-x_i(t)) + c_3*uniform(0,1)*(x_{init}-x_i(t))\]

\[x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1))\]

where \(w\) - inertia constant \(c_1\) - personal coefficient \(c_2\) - global coefficient \(c_3\) - initial location coefficient \(p_i\) - parameters yielding the best function value obtained by this particle \(p_g\) - parameters yielding the best function value obtained by all particles \(x_{init}\) - initial parameter values provided by user

◆ New()

static Pointer itk::InitializationBiasedParticleSwarmOptimizer::New ( )
static

Method for creation through the object factory.

◆ PrintSelf()

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

◆ SetGlobalCoefficient()

virtual void itk::InitializationBiasedParticleSwarmOptimizer::SetGlobalCoefficient ( CoefficientType  _arg)
virtual

The Particle swarm optimizer uses the following update formula:

\[c_3 = c_{3initial}(1.0 - IterationIndex/MaximalNumberOfIterations)\]

\[v_i(t+1) = w*v_i(t) + c_1*uniform(0,1)*(p_i-x_i(t)) + c_2*uniform(0,1)*(p_g-x_i(t)) + c_3*uniform(0,1)*(x_{init}-x_i(t))\]

\[x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1))\]

where \(w\) - inertia constant \(c_1\) - personal coefficient \(c_2\) - global coefficient \(c_3\) - initial location coefficient \(p_i\) - parameters yielding the best function value obtained by this particle \(p_g\) - parameters yielding the best function value obtained by all particles \(x_{init}\) - initial parameter values provided by user

◆ SetInertiaCoefficient()

virtual void itk::InitializationBiasedParticleSwarmOptimizer::SetInertiaCoefficient ( CoefficientType  _arg)
virtual

The Particle swarm optimizer uses the following update formula:

\[c_3 = c_{3initial}(1.0 - IterationIndex/MaximalNumberOfIterations)\]

\[v_i(t+1) = w*v_i(t) + c_1*uniform(0,1)*(p_i-x_i(t)) + c_2*uniform(0,1)*(p_g-x_i(t)) + c_3*uniform(0,1)*(x_{init}-x_i(t))\]

\[x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1))\]

where \(w\) - inertia constant \(c_1\) - personal coefficient \(c_2\) - global coefficient \(c_3\) - initial location coefficient \(p_i\) - parameters yielding the best function value obtained by this particle \(p_g\) - parameters yielding the best function value obtained by all particles \(x_{init}\) - initial parameter values provided by user

◆ SetInitializationCoefficient()

virtual void itk::InitializationBiasedParticleSwarmOptimizer::SetInitializationCoefficient ( CoefficientType  _arg)
virtual

The Particle swarm optimizer uses the following update formula:

\[c_3 = c_{3initial}(1.0 - IterationIndex/MaximalNumberOfIterations)\]

\[v_i(t+1) = w*v_i(t) + c_1*uniform(0,1)*(p_i-x_i(t)) + c_2*uniform(0,1)*(p_g-x_i(t)) + c_3*uniform(0,1)*(x_{init}-x_i(t))\]

\[x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1))\]

where \(w\) - inertia constant \(c_1\) - personal coefficient \(c_2\) - global coefficient \(c_3\) - initial location coefficient \(p_i\) - parameters yielding the best function value obtained by this particle \(p_g\) - parameters yielding the best function value obtained by all particles \(x_{init}\) - initial parameter values provided by user

◆ SetPersonalCoefficient()

virtual void itk::InitializationBiasedParticleSwarmOptimizer::SetPersonalCoefficient ( CoefficientType  _arg)
virtual

The Particle swarm optimizer uses the following update formula:

\[c_3 = c_{3initial}(1.0 - IterationIndex/MaximalNumberOfIterations)\]

\[v_i(t+1) = w*v_i(t) + c_1*uniform(0,1)*(p_i-x_i(t)) + c_2*uniform(0,1)*(p_g-x_i(t)) + c_3*uniform(0,1)*(x_{init}-x_i(t))\]

\[x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1))\]

where \(w\) - inertia constant \(c_1\) - personal coefficient \(c_2\) - global coefficient \(c_3\) - initial location coefficient \(p_i\) - parameters yielding the best function value obtained by this particle \(p_g\) - parameters yielding the best function value obtained by all particles \(x_{init}\) - initial parameter values provided by user

◆ UpdateSwarm()

void itk::InitializationBiasedParticleSwarmOptimizer::UpdateSwarm ( )
overrideprotectedvirtual

Implement your update rule in this function.

Implements itk::ParticleSwarmOptimizerBase.

Member Data Documentation

◆ m_GlobalCoefficient

ParametersType::ValueType itk::InitializationBiasedParticleSwarmOptimizer::m_GlobalCoefficient {}
private

◆ m_InertiaCoefficient

ParametersType::ValueType itk::InitializationBiasedParticleSwarmOptimizer::m_InertiaCoefficient {}
private

◆ m_InitializationCoefficient

ParametersType::ValueType itk::InitializationBiasedParticleSwarmOptimizer::m_InitializationCoefficient {}
private

◆ m_PersonalCoefficient

ParametersType::ValueType itk::InitializationBiasedParticleSwarmOptimizer::m_PersonalCoefficient {}
private

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