ITK  4.9.0
Insight Segmentation and Registration Toolkit
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
itk::ParticleSwarmOptimizerBase Class Referenceabstract

#include <itkParticleSwarmOptimizerBase.h>

+ Inheritance diagram for itk::ParticleSwarmOptimizerBase:
+ Collaboration diagram for itk::ParticleSwarmOptimizerBase:

Detailed Description

Abstract 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 is a stochastic global search optimization approach. Optimization is performed by maintaining a swarm 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.

Swarm initialization is performed within the user supplied parameter bounds using either 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. best personal particle locations are close to the swarm's best location in parameter space).

The actual optimization procedure, updating the swarm, is performed in the subclasses, required to implement the UpdateSwarm() method.

NOTE: This implementation only performs minimization.

Definition at line 56 of file itkParticleSwarmOptimizerBase.h.

Classes

struct  ParticleData
 

Public Types

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 MeasureType GetFunctionConvergenceTolerance ()
 
virtual bool GetInitializeNormalDistribution ()
 
virtual NumberOfIterationsType GetMaximalNumberOfIterations ()
 
virtual const char * GetNameOfClass () const
 
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
 

Protected Member Functions

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
 
virtual void PrintSelf (std::ostream &os, Indent indent) const override
 
void RandomInitialization ()
 
virtual void UpdateSwarm ()=0
 
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 ()
 

Protected Attributes

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
 

Additional Inherited Members

- 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 ()
 

Member Typedef Documentation

Definition at line 64 of file itkParticleSwarmOptimizerBase.h.

Definition at line 85 of file itkParticleSwarmOptimizerBase.h.

Definition at line 84 of file itkParticleSwarmOptimizerBase.h.

Definition at line 82 of file itkParticleSwarmOptimizerBase.h.

Definition at line 83 of file itkParticleSwarmOptimizerBase.h.

Definition at line 63 of file itkParticleSwarmOptimizerBase.h.

Definition at line 88 of file itkParticleSwarmOptimizerBase.h.

Standard "Self" typedef.

Definition at line 61 of file itkParticleSwarmOptimizerBase.h.

Definition at line 62 of file itkParticleSwarmOptimizerBase.h.

Definition at line 81 of file itkParticleSwarmOptimizerBase.h.

Definition at line 86 of file itkParticleSwarmOptimizerBase.h.

Constructor & Destructor Documentation

itk::ParticleSwarmOptimizerBase::ParticleSwarmOptimizerBase ( )
protected
virtual itk::ParticleSwarmOptimizerBase::~ParticleSwarmOptimizerBase ( )
protectedvirtual
itk::ParticleSwarmOptimizerBase::ParticleSwarmOptimizerBase ( const Self )
protected

Member Function Documentation

void itk::ParticleSwarmOptimizerBase::ClearSwarm ( )

Specify the initial swarm. Useful for evaluating PSO variants. If the initial swarm is set it will be used. To revert to random initialization (uniform or normal particle distributions) set using an empty swarm.

void itk::ParticleSwarmOptimizerBase::FileInitialization ( )
protected
virtual MeasureType itk::ParticleSwarmOptimizerBase::GetFunctionConvergenceTolerance ( )
virtual
virtual bool itk::ParticleSwarmOptimizerBase::GetInitializeNormalDistribution ( )
virtual
virtual NumberOfIterationsType itk::ParticleSwarmOptimizerBase::GetMaximalNumberOfIterations ( )
virtual
virtual const char* itk::ParticleSwarmOptimizerBase::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods).

Reimplemented from itk::SingleValuedNonLinearOptimizer.

Reimplemented in itk::InitializationBiasedParticleSwarmOptimizer, and itk::ParticleSwarmOptimizer.

virtual NumberOfGenerationsType itk::ParticleSwarmOptimizerBase::GetNumberOfGenerationsWithMinimalImprovement ( )
virtual
virtual NumberOfParticlesType itk::ParticleSwarmOptimizerBase::GetNumberOfParticles ( )
virtual
ParameterBoundsType itk::ParticleSwarmOptimizerBase::GetParameterBounds ( ) const
virtual ParametersType itk::ParticleSwarmOptimizerBase::GetParametersConvergenceTolerance ( )
virtual
virtual double itk::ParticleSwarmOptimizerBase::GetPercentageParticlesConverged ( )
virtual
virtual bool itk::ParticleSwarmOptimizerBase::GetPrintSwarm ( )
virtual
virtual RandomVariateGeneratorType::IntegerType itk::ParticleSwarmOptimizerBase::GetSeed ( )
virtual
virtual const std::string itk::ParticleSwarmOptimizerBase::GetStopConditionDescription ( ) const
overridevirtual

Get the reason for termination

Reimplemented from itk::Optimizer.

virtual bool itk::ParticleSwarmOptimizerBase::GetUseSeed ( )
virtual
MeasureType itk::ParticleSwarmOptimizerBase::GetValue ( ) const

Get the function value for the current position. NOTE: This value is only valid during and after the execution of the StartOptimization() method.

virtual void itk::ParticleSwarmOptimizerBase::Initialize ( )
protectedvirtual

Initialize the particle swarm, and seed the random number generator.

virtual void itk::ParticleSwarmOptimizerBase::InitializeNormalDistributionOff ( )
virtual
virtual void itk::ParticleSwarmOptimizerBase::InitializeNormalDistributionOn ( )
virtual
void itk::ParticleSwarmOptimizerBase::operator= ( const Self )
protected
void itk::ParticleSwarmOptimizerBase::PrintParamtersType ( const ParametersType x,
std::ostream &  os 
) const
protected
virtual void itk::ParticleSwarmOptimizerBase::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::SingleValuedNonLinearOptimizer.

Reimplemented in itk::InitializationBiasedParticleSwarmOptimizer, and itk::ParticleSwarmOptimizer.

void itk::ParticleSwarmOptimizerBase::PrintSwarm ( std::ostream &  os,
Indent  indent 
) const

Print the swarm information to the given output stream. Each line (particle data) is of the form: current_parameters current_velocity current_value best_parameters best_value

virtual void itk::ParticleSwarmOptimizerBase::PrintSwarmOff ( )
virtual
virtual void itk::ParticleSwarmOptimizerBase::PrintSwarmOn ( )
virtual
void itk::ParticleSwarmOptimizerBase::RandomInitialization ( )
protected
virtual void itk::ParticleSwarmOptimizerBase::SetFunctionConvergenceTolerance ( MeasureType  _arg)
virtual

The optimization algorithm will terminate when the function improvement in the last m_NumberOfGenerationsWithMinimalImprovement generations is less than m_FunctionConvergenceTolerance and the maximal distance between particles and the best particle in each dimension is less than m_ParametersConvergenceTolerance[i] for the specified percentage of the particles. That is, we haven't improved the best function value for a while and in the parameter space most (m%) of our particles attained their best value close to the swarm's best value. NOTE: The use of different tolerances for each dimension is desired when optimizing over non-commensurate parameters (e.g. rotation and translation). Alternatively, we could use ITK's parameter scaling approach. The current approach seems more intuitive.

virtual void itk::ParticleSwarmOptimizerBase::SetInitializeNormalDistribution ( bool  _arg)
virtual

Specify whether to initialize the particles using a normal distribution centered on the user supplied initial value or a uniform distribution. If the optimum is expected to be near the initial value it is likely that initializing with a normal distribution will result in faster convergence.

void itk::ParticleSwarmOptimizerBase::SetInitialSwarm ( const SwarmType initialSwarm)

Specify the initial swarm. Useful for evaluating PSO variants. If the initial swarm is set it will be used. To revert to random initialization (uniform or normal particle distributions) set using an empty swarm.

virtual void itk::ParticleSwarmOptimizerBase::SetMaximalNumberOfIterations ( NumberOfIterationsType  _arg)
virtual

Set/Get maximal number of iterations - the maximal number of function evaluations is m_MaximalNumberOfIterations*m_NumberOfParticles

virtual void itk::ParticleSwarmOptimizerBase::SetNumberOfGenerationsWithMinimalImprovement ( NumberOfGenerationsType  _arg)
virtual

Set/Get the number of generations to continue with minimal improvement in the function value, |f_best(g_i) - f_best(g_k)|<threshold where k <= i+NumberOfGenerationsWithMinimalImprovement Minimal value is one.

void itk::ParticleSwarmOptimizerBase::SetNumberOfParticles ( NumberOfParticlesType  n)

Set/Get number of particles in the swarm - the maximal number of function evaluations is m_MaximalNumberOfIterations*m_NumberOfParticles

virtual void itk::ParticleSwarmOptimizerBase::SetParameterBounds ( ParameterBoundsType bounds)
virtual

Set/Get the parameter bounds. Search for optimal value is inside these bounds. NOTE: It is assumed that the first entry is the minimal value, second is the maximal value.

void itk::ParticleSwarmOptimizerBase::SetParameterBounds ( std::pair< ParametersType::ValueType, ParametersType::ValueType > &  bounds,
unsigned int  n 
)

Set/Get the parameter bounds. Search for optimal value is inside these bounds. NOTE: It is assumed that the first entry is the minimal value, second is the maximal value.

void itk::ParticleSwarmOptimizerBase::SetParametersConvergenceTolerance ( ValueType  convergenceTolerance,
unsigned int  sz 
)

Set parameters convergence tolerance using the same value for all, sz, parameters

virtual void itk::ParticleSwarmOptimizerBase::SetParametersConvergenceTolerance ( ParametersType  _arg)
virtual
virtual void itk::ParticleSwarmOptimizerBase::SetPercentageParticlesConverged ( double  _arg)
virtual
virtual void itk::ParticleSwarmOptimizerBase::SetPrintSwarm ( bool  _arg)
virtual

Indicate whether or not to output the swarm information when printing an object. By default this option is turned off as it generates too much information.

virtual void itk::ParticleSwarmOptimizerBase::SetSeed ( RandomVariateGeneratorType::IntegerType  _arg)
virtual

Set the random number seed for the swarm. Use this method to produce reaptible results, typically, for testing.

virtual void itk::ParticleSwarmOptimizerBase::SetUseSeed ( bool  _arg)
virtual

Use a specific seed to initialize the random number generator. If On, use m_Seed to seed the random number generator. Default is Off.

virtual void itk::ParticleSwarmOptimizerBase::StartOptimization ( void  )
overridevirtual

Start optimization.

Reimplemented from itk::Optimizer.

virtual void itk::ParticleSwarmOptimizerBase::UpdateSwarm ( )
protectedpure virtual

Implement your update rule in this function.

Implemented in itk::InitializationBiasedParticleSwarmOptimizer, and itk::ParticleSwarmOptimizer.

virtual void itk::ParticleSwarmOptimizerBase::UseSeedOff ( )
virtual
virtual void itk::ParticleSwarmOptimizerBase::UseSeedOn ( )
virtual
virtual void itk::ParticleSwarmOptimizerBase::ValidateSettings ( )
protectedvirtual

Member Data Documentation

CostFunctionType::MeasureType itk::ParticleSwarmOptimizerBase::m_FunctionBestValue
protected

Definition at line 236 of file itkParticleSwarmOptimizerBase.h.

std::vector<MeasureType> itk::ParticleSwarmOptimizerBase::m_FunctionBestValueMemory
protected

Definition at line 237 of file itkParticleSwarmOptimizerBase.h.

CostFunctionType::MeasureType itk::ParticleSwarmOptimizerBase::m_FunctionConvergenceTolerance
protected

Definition at line 234 of file itkParticleSwarmOptimizerBase.h.

bool itk::ParticleSwarmOptimizerBase::m_InitializeNormalDistribution
protected

Definition at line 227 of file itkParticleSwarmOptimizerBase.h.

NumberOfIterationsType itk::ParticleSwarmOptimizerBase::m_IterationIndex
protected

Definition at line 239 of file itkParticleSwarmOptimizerBase.h.

NumberOfIterationsType itk::ParticleSwarmOptimizerBase::m_MaximalNumberOfIterations
protected

Definition at line 229 of file itkParticleSwarmOptimizerBase.h.

NumberOfGenerationsType itk::ParticleSwarmOptimizerBase::m_NumberOfGenerationsWithMinimalImprovement
protected

Definition at line 230 of file itkParticleSwarmOptimizerBase.h.

NumberOfParticlesType itk::ParticleSwarmOptimizerBase::m_NumberOfParticles
protected

Definition at line 228 of file itkParticleSwarmOptimizerBase.h.

ParameterBoundsType itk::ParticleSwarmOptimizerBase::m_ParameterBounds
protected

Definition at line 231 of file itkParticleSwarmOptimizerBase.h.

ParametersType itk::ParticleSwarmOptimizerBase::m_ParametersBestValue
protected

Definition at line 238 of file itkParticleSwarmOptimizerBase.h.

ParametersType itk::ParticleSwarmOptimizerBase::m_ParametersConvergenceTolerance
protected

Definition at line 232 of file itkParticleSwarmOptimizerBase.h.

std::vector<ParticleData> itk::ParticleSwarmOptimizerBase::m_Particles
protected

Definition at line 235 of file itkParticleSwarmOptimizerBase.h.

double itk::ParticleSwarmOptimizerBase::m_PercentageParticlesConverged
protected

Definition at line 233 of file itkParticleSwarmOptimizerBase.h.

bool itk::ParticleSwarmOptimizerBase::m_PrintSwarm
protected

Definition at line 225 of file itkParticleSwarmOptimizerBase.h.

RandomVariateGeneratorType::IntegerType itk::ParticleSwarmOptimizerBase::m_Seed
protected

Definition at line 240 of file itkParticleSwarmOptimizerBase.h.

std::ostringstream itk::ParticleSwarmOptimizerBase::m_StopConditionDescription
protected

Definition at line 226 of file itkParticleSwarmOptimizerBase.h.

bool itk::ParticleSwarmOptimizerBase::m_UseSeed
protected

Definition at line 241 of file itkParticleSwarmOptimizerBase.h.


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