ITK  5.2.0
Insight Toolkit
Public Types | Public Member Functions | Static Public Member Functions | List of all members

#include <itkParticleSwarmOptimizer.h>

+ Inheritance diagram for itk::ParticleSwarmOptimizer:
+ Collaboration diagram for itk::ParticleSwarmOptimizer:

Public Types

using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = ParticleSwarmOptimizer
 
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

virtual ::itk::LightObject::Pointer CreateAnother () const
 
virtual const char * GetNameOfClass () const
 
- Public Member Functions inherited from itk::ParticleSwarmOptimizerBase
virtual void SetInitializeNormalDistribution (bool _arg)
 
virtual bool GetInitializeNormalDistribution ()
 
virtual void InitializeNormalDistributionOn ()
 
virtual void InitializeNormalDistributionOff ()
 
void SetInitialSwarm (const SwarmType &initialSwarm)
 
void ClearSwarm ()
 
virtual void SetPrintSwarm (bool _arg)
 
virtual bool GetPrintSwarm ()
 
virtual void PrintSwarmOn ()
 
virtual void PrintSwarmOff ()
 
void StartOptimization () override
 
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)
 
ParameterBoundsType GetParameterBounds () const
 
virtual void SetFunctionConvergenceTolerance (MeasureType _arg)
 
virtual MeasureType GetFunctionConvergenceTolerance ()
 
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 ()
 
virtual void UseSeedOff ()
 
MeasureType GetValue () const
 
const std::string GetStopConditionDescription () const override
 
void PrintSwarm (std::ostream &os, Indent indent) const
 
- Public Member Functions inherited from itk::SingleValuedNonLinearOptimizer
virtual ::itk::LightObject::Pointer CreateAnother () const
 
virtual const CostFunctionTypeGetCostFunction () const
 
virtual CostFunctionTypeGetModifiableCostFunction ()
 
MeasureType GetValue (const ParametersType &parameters) const
 
virtual void SetCostFunction (CostFunctionType *costFunction)
 
- Public Member Functions inherited from itk::Optimizer
virtual const ParametersTypeGetInitialPosition () const
 
virtual void SetInitialPosition (const ParametersType &param)
 
void SetScales (const ScalesType &scales)
 
virtual const ScalesTypeGetScales () const
 
virtual const ScalesTypeGetInverseScales () const
 
virtual const ParametersTypeGetCurrentPosition () 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
 
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 ()
 
ParametersType::ValueType m_InertiaCoefficient
 
ParametersType::ValueType m_PersonalCoefficient
 
ParametersType::ValueType m_GlobalCoefficient
 
virtual void SetInertiaCoefficient (double _arg)
 
virtual double GetInertiaCoefficient ()
 
virtual void SetPersonalCoefficient (double _arg)
 
virtual double GetPersonalCoefficient ()
 
virtual void SetGlobalCoefficient (double _arg)
 
virtual double GetGlobalCoefficient ()
 
 ParticleSwarmOptimizer ()
 
 ~ParticleSwarmOptimizer () override
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
void UpdateSwarm () override
 

Additional Inherited Members

- Protected Member Functions inherited from itk::ParticleSwarmOptimizerBase
 ParticleSwarmOptimizerBase ()
 
 ~ParticleSwarmOptimizerBase () override
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
void PrintParamtersType (const ParametersType &x, std::ostream &os) const
 
virtual void ValidateSettings ()
 
virtual void Initialize ()
 
void RandomInitialization ()
 
void FileInitialization ()
 
- 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 ()
 
 ~Optimizer () override=default
 
virtual void SetCurrentPosition (const ParametersType &param)
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
 ~Object () override
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
virtual void SetTimeStamp (const TimeStamp &timeStamp)
 
- 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 ()
 
- Protected Attributes inherited from itk::ParticleSwarmOptimizerBase
bool m_PrintSwarm
 
std::ostringstream m_StopConditionDescription
 
bool m_InitializeNormalDistribution
 
NumberOfParticlesType m_NumberOfParticles
 
NumberOfIterationsType m_MaximalNumberOfIterations
 
NumberOfGenerationsType m_NumberOfGenerationsWithMinimalImprovement
 
ParameterBoundsType m_ParameterBounds
 
ParametersType m_ParametersConvergenceTolerance
 
double m_PercentageParticlesConverged
 
CostFunctionType::MeasureType m_FunctionConvergenceTolerance
 
std::vector< ParticleDatam_Particles
 
CostFunctionType::MeasureType m_FunctionBestValue { 0 }
 
std::vector< MeasureTypem_FunctionBestValueMemory
 
ParametersType m_ParametersBestValue
 
NumberOfIterationsType m_IterationIndex { 0 }
 
RandomVariateGeneratorType::IntegerType m_Seed
 
bool m_UseSeed
 
- Protected Attributes inherited from itk::SingleValuedNonLinearOptimizer
CostFunctionPointer m_CostFunction
 
- Protected Attributes inherited from itk::Optimizer
bool m_ScalesInitialized { false }
 
ParametersType m_CurrentPosition
 
- Protected Attributes inherited from itk::LightObject
std::atomic< int > m_ReferenceCount
 

Detailed Description

Implementation of a Particle Swarm Optimization (PSO) algorithm.

The PSO algorithm was originally presented in:
J. Kennedy, R. Eberhart, "Particle Swarm Optimization", Proc. IEEE Int. Neural Networks, 1995.

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, and the location of the best function value the particles in its neighborhood previously encountered. In this implementation we use a global neighborhood with the following update equations:

\[v_i(t+1) = wv_i(t) + c_1u_1(p_i-x_i(t)) + c_2u_2(p_g-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$ are user selected weights.

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. 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 60 of file itkParticleSwarmOptimizer.h.

Member Typedef Documentation

◆ ConstPointer

Definition at line 69 of file itkParticleSwarmOptimizer.h.

◆ Pointer

Definition at line 68 of file itkParticleSwarmOptimizer.h.

◆ Self

Standard "Self" type alias.

Definition at line 66 of file itkParticleSwarmOptimizer.h.

◆ Superclass

Definition at line 67 of file itkParticleSwarmOptimizer.h.

Constructor & Destructor Documentation

◆ ParticleSwarmOptimizer()

itk::ParticleSwarmOptimizer::ParticleSwarmOptimizer ( )
protected

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

◆ ~ParticleSwarmOptimizer()

itk::ParticleSwarmOptimizer::~ParticleSwarmOptimizer ( )
overrideprotected

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

Member Function Documentation

◆ CreateAnother()

virtual::itk::LightObject::Pointer itk::ParticleSwarmOptimizer::CreateAnother ( ) const
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::NonLinearOptimizer.

◆ GetGlobalCoefficient()

virtual double itk::ParticleSwarmOptimizer::GetGlobalCoefficient ( )
virtual

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

◆ GetInertiaCoefficient()

virtual double itk::ParticleSwarmOptimizer::GetInertiaCoefficient ( )
virtual

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

◆ GetNameOfClass()

virtual const char* itk::ParticleSwarmOptimizer::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods).

Reimplemented from itk::ParticleSwarmOptimizerBase.

◆ GetPersonalCoefficient()

virtual double itk::ParticleSwarmOptimizer::GetPersonalCoefficient ( )
virtual

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

◆ New()

static Pointer itk::ParticleSwarmOptimizer::New ( )
static

Method for creation through the object factory.

Examples
Examples/IO/XML/ParticleSwarmOptimizerReadWrite.cxx.

◆ PrintSelf()

void itk::ParticleSwarmOptimizer::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
overrideprotectedvirtual

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

Reimplemented from itk::Optimizer.

◆ SetGlobalCoefficient()

virtual void itk::ParticleSwarmOptimizer::SetGlobalCoefficient ( double  _arg)
virtual

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

◆ SetInertiaCoefficient()

virtual void itk::ParticleSwarmOptimizer::SetInertiaCoefficient ( double  _arg)
virtual

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

◆ SetPersonalCoefficient()

virtual void itk::ParticleSwarmOptimizer::SetPersonalCoefficient ( double  _arg)
virtual

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

◆ UpdateSwarm()

void itk::ParticleSwarmOptimizer::UpdateSwarm ( )
overrideprotectedvirtual

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

Implements itk::ParticleSwarmOptimizerBase.

Member Data Documentation

◆ m_GlobalCoefficient

ParametersType::ValueType itk::ParticleSwarmOptimizer::m_GlobalCoefficient
private

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

Definition at line 108 of file itkParticleSwarmOptimizer.h.

◆ m_InertiaCoefficient

ParametersType::ValueType itk::ParticleSwarmOptimizer::m_InertiaCoefficient
private

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

Definition at line 106 of file itkParticleSwarmOptimizer.h.

◆ m_PersonalCoefficient

ParametersType::ValueType itk::ParticleSwarmOptimizer::m_PersonalCoefficient
private

The Particle swarm optimizer uses the following update formula: 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)) x_i(t+1) = clampToBounds(x_i(t) + v_i(t+1)) where w - inertia constant c_1 - personal coefficient c_2 - global 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

Definition at line 107 of file itkParticleSwarmOptimizer.h.


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