ITK  4.9.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
itk::ParticleSwarmOptimizer Class Reference

#include <itkParticleSwarmOptimizer.h>

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

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.

Public Types

typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef ParticleSwarmOptimizer Self
 
typedef ParticleSwarmOptimizerBase Superclass
 
- Public Types inherited from itk::ParticleSwarmOptimizerBase
typedef SmartPointer< const SelfConstPointer
 
typedef
CostFunctionType::MeasureType 
MeasureType
 
typedef unsigned int NumberOfGenerationsType
 
typedef unsigned int NumberOfIterationsType
 
typedef unsigned int NumberOfParticlesType
 
typedef std::vector< std::pair
< ParametersType::ValueType,
ParametersType::ValueType > > 
ParameterBoundsType
 
typedef SmartPointer< SelfPointer
 
typedef
Statistics::MersenneTwisterRandomVariateGenerator 
RandomVariateGeneratorType
 
typedef ParticleSwarmOptimizerBase Self
 
typedef
SingleValuedNonLinearOptimizer 
Superclass
 
typedef std::vector< ParticleDataSwarmType
 
typedef ParametersType::ValueType ValueType
 
- Public Types inherited from itk::SingleValuedNonLinearOptimizer
typedef SmartPointer< const SelfConstPointer
 
typedef CostFunctionType::Pointer CostFunctionPointer
 
typedef SingleValuedCostFunction CostFunctionType
 
typedef
CostFunctionType::DerivativeType 
DerivativeType
 
typedef
CostFunctionType::MeasureType 
MeasureType
 
typedef Superclass::ParametersType ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef
SingleValuedNonLinearOptimizer 
Self
 
typedef NonLinearOptimizer Superclass
 
- Public Types inherited from itk::NonLinearOptimizer
typedef SmartPointer< const SelfConstPointer
 
typedef Superclass::ParametersType ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef Superclass::ScalesType ScalesType
 
typedef NonLinearOptimizer Self
 
typedef Optimizer Superclass
 
- Public Types inherited from itk::Optimizer
typedef SmartPointer< const SelfConstPointer
 
typedef OptimizerParameters
< double > 
ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef Array< double > ScalesType
 
typedef Optimizer Self
 
typedef Object Superclass
 
- Public Types inherited from itk::Object
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef Object Self
 
typedef LightObject Superclass
 
- Public Types inherited from itk::LightObject
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef LightObject Self
 

Public Member Functions

virtual ::itk::LightObject::Pointer CreateAnother () const
 
virtual double GetGlobalCoefficient ()
 
virtual double GetInertiaCoefficient ()
 
virtual const char * GetNameOfClass () const
 
virtual double GetPersonalCoefficient ()
 
virtual void SetGlobalCoefficient (double _arg)
 
virtual void SetInertiaCoefficient (double _arg)
 
virtual void SetPersonalCoefficient (double _arg)
 
- Public Member Functions inherited from itk::ParticleSwarmOptimizerBase
virtual MeasureType GetFunctionConvergenceTolerance ()
 
virtual bool GetInitializeNormalDistribution ()
 
virtual NumberOfIterationsType GetMaximalNumberOfIterations ()
 
virtual NumberOfGenerationsType GetNumberOfGenerationsWithMinimalImprovement ()
 
virtual NumberOfParticlesType GetNumberOfParticles ()
 
ParameterBoundsType GetParameterBounds () const
 
virtual ParametersType GetParametersConvergenceTolerance ()
 
virtual double GetPercentageParticlesConverged ()
 
virtual bool GetPrintSwarm ()
 
virtual
RandomVariateGeneratorType::IntegerType 
GetSeed ()
 
virtual const std::string GetStopConditionDescription () const override
 
virtual bool GetUseSeed ()
 
MeasureType GetValue () const
 
virtual void InitializeNormalDistributionOff ()
 
virtual void InitializeNormalDistributionOn ()
 
void PrintSwarm (std::ostream &os, Indent indent) const
 
virtual void PrintSwarmOff ()
 
virtual void PrintSwarmOn ()
 
virtual void SetFunctionConvergenceTolerance (MeasureType _arg)
 
virtual void SetInitializeNormalDistribution (bool _arg)
 
virtual void SetMaximalNumberOfIterations (NumberOfIterationsType _arg)
 
virtual void SetNumberOfGenerationsWithMinimalImprovement (NumberOfGenerationsType _arg)
 
void SetNumberOfParticles (NumberOfParticlesType n)
 
void SetParametersConvergenceTolerance (ValueType convergenceTolerance, unsigned int sz)
 
virtual void SetParametersConvergenceTolerance (ParametersType _arg)
 
virtual void SetPercentageParticlesConverged (double _arg)
 
virtual void SetPrintSwarm (bool _arg)
 
virtual void SetSeed (RandomVariateGeneratorType::IntegerType _arg)
 
virtual void SetUseSeed (bool _arg)
 
virtual void StartOptimization (void) override
 
virtual void UseSeedOff ()
 
virtual void UseSeedOn ()
 
void SetInitialSwarm (const SwarmType &initialSwarm)
 
void ClearSwarm ()
 
virtual void SetParameterBounds (ParameterBoundsType &bounds)
 
void SetParameterBounds (std::pair< ParametersType::ValueType, ParametersType::ValueType > &bounds, unsigned int n)
 
- 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 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
 
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
 
virtual void Register () const override
 
void RemoveAllObservers ()
 
void RemoveObserver (unsigned long tag)
 
void SetDebug (bool debugFlag) const
 
void SetMetaDataDictionary (const MetaDataDictionary &rhs)
 
virtual void SetReferenceCount (int) override
 
virtual void UnRegister () const noexceptoverride
 
virtual void SetObjectName (std::string _arg)
 
virtual const std::string & GetObjectName () const
 
- Public Member Functions inherited from itk::LightObject
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
 itkCloneMacro (Self)
 
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 flag)
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 

Protected Member Functions

 ParticleSwarmOptimizer ()
 
virtual void PrintSelf (std::ostream &os, Indent indent) const override
 
virtual void UpdateSwarm () override
 
virtual ~ParticleSwarmOptimizer ()
 
- Protected Member Functions inherited from itk::ParticleSwarmOptimizerBase
void FileInitialization ()
 
virtual void Initialize ()
 
void operator= (const Self &) ITK_DELETE_FUNCTION
 
 ParticleSwarmOptimizerBase ()
 
 ParticleSwarmOptimizerBase (const Self &) ITK_DELETE_FUNCTION
 
void PrintParamtersType (const ParametersType &x, std::ostream &os) const
 
void RandomInitialization ()
 
virtual void ValidateSettings ()
 
virtual ~ParticleSwarmOptimizerBase ()
 
- Protected Member Functions inherited from itk::SingleValuedNonLinearOptimizer
 SingleValuedNonLinearOptimizer ()
 
virtual ~SingleValuedNonLinearOptimizer ()
 
- Protected Member Functions inherited from itk::NonLinearOptimizer
 NonLinearOptimizer ()
 
virtual ~NonLinearOptimizer ()
 
- Protected Member Functions inherited from itk::Optimizer
 Optimizer ()
 
virtual void SetCurrentPosition (const ParametersType &param)
 
virtual ~Optimizer ()
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
virtual void SetTimeStamp (const TimeStamp &time)
 
virtual ~Object ()
 
- 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 operator= (const Self &) ITK_DELETE_FUNCTION
 
 ParticleSwarmOptimizer (const Self &) ITK_DELETE_FUNCTION
 

Private Attributes

ParametersType::ValueType m_GlobalCoefficient
 
ParametersType::ValueType m_InertiaCoefficient
 
ParametersType::ValueType m_PersonalCoefficient
 

Additional Inherited Members

- Protected Attributes inherited from itk::ParticleSwarmOptimizerBase
CostFunctionType::MeasureType m_FunctionBestValue
 
std::vector< MeasureTypem_FunctionBestValueMemory
 
CostFunctionType::MeasureType m_FunctionConvergenceTolerance
 
bool m_InitializeNormalDistribution
 
NumberOfIterationsType m_IterationIndex
 
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
 
- Protected Attributes inherited from itk::LightObject
AtomicInt< int > m_ReferenceCount
 

Member Typedef Documentation

Definition at line 68 of file itkParticleSwarmOptimizer.h.

Definition at line 67 of file itkParticleSwarmOptimizer.h.

Standard "Self" typedef.

Definition at line 65 of file itkParticleSwarmOptimizer.h.

Definition at line 66 of file itkParticleSwarmOptimizer.h.

Constructor & Destructor Documentation

itk::ParticleSwarmOptimizer::ParticleSwarmOptimizer ( )
protected
virtual itk::ParticleSwarmOptimizer::~ParticleSwarmOptimizer ( )
protectedvirtual
itk::ParticleSwarmOptimizer::ParticleSwarmOptimizer ( const Self )
private

Member Function Documentation

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.

virtual double itk::ParticleSwarmOptimizer::GetGlobalCoefficient ( )
virtual
virtual double itk::ParticleSwarmOptimizer::GetInertiaCoefficient ( )
virtual
virtual const char* itk::ParticleSwarmOptimizer::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods).

Reimplemented from itk::ParticleSwarmOptimizerBase.

virtual double itk::ParticleSwarmOptimizer::GetPersonalCoefficient ( )
virtual
static Pointer itk::ParticleSwarmOptimizer::New ( )
static

Method for creation through the object factory.

Examples:
Examples/IO/XML/ParticleSwarmOptimizerReadWrite.cxx.
void itk::ParticleSwarmOptimizer::operator= ( const Self )
private
virtual void itk::ParticleSwarmOptimizer::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::ParticleSwarmOptimizerBase.

virtual void itk::ParticleSwarmOptimizer::SetGlobalCoefficient ( double  _arg)
virtual
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

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

Implement your update rule in this function.

Implements itk::ParticleSwarmOptimizerBase.

Member Data Documentation

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

Definition at line 107 of file itkParticleSwarmOptimizer.h.

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

Definition at line 105 of file itkParticleSwarmOptimizer.h.

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

Definition at line 106 of file itkParticleSwarmOptimizer.h.


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