GestureRecognitionToolkit  Version: 0.1.0
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE > Class Template Reference

Public Member Functions

 ParticleSwarmOptimization ()
 
virtual ~ParticleSwarmOptimization ()
 
PARTICLE_TYPE & operator[] (const unsigned int &index)
 
virtual bool init (const unsigned int numParticles, const unsigned int K, const VectorFloat &xMin, const VectorFloat &xMax, const VectorFloat &propagationModel)
 
virtual bool reset ()
 
virtual bool search (OBSERVATION_TYPE &observation)
 
virtual Float searchIteration (OBSERVATION_TYPE &observation)
 
bool setPropagationModel (const VectorFloat &propagationModel)
 

Public Attributes

bool initialized
 A flag to indicate if the PSO algorithm has been initialized.
 
unsigned int K
 The size of the particles state Vector.
 
Float minImprovement
 
unsigned int maxIter
 
unsigned int maxNumIterNoChange
 
Float globalBestCost
 The current global best cost over all the particles.
 
VectorFloat finalX
 The final estimate.
 
VectorFloat globalBestX
 The state Vector of the particle with the best cost.
 
VectorFloat xMin
 The minimum range of the state space.
 
VectorFloat xMax
 The maximum range of the state space.
 
VectorFloat propagationModel
 The propagation model used to update each particle.
 
Vector< PARTICLE_TYPE > particles
 A Vector containing all the particles used for the search.
 
Vector< VectorFloatglobalBestXHistory
 A buffer to keep track of the search history.
 
Vector< Vector< PARTICLE_TYPE > > iterHistory
 A buffer to keep track of the search history.
 
InfoLog infoLog
 
ErrorLog errorLog
 

Detailed Description

template<class PARTICLE_TYPE, class OBSERVATION_TYPE>
class ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >

Definition at line 41 of file ParticleSwarmOptimization.h.

Constructor & Destructor Documentation

template<class PARTICLE_TYPE , class OBSERVATION_TYPE >
ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >::ParticleSwarmOptimization ( )
inline

Default Constructor.

Definition at line 47 of file ParticleSwarmOptimization.h.

template<class PARTICLE_TYPE , class OBSERVATION_TYPE >
virtual ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >::~ParticleSwarmOptimization ( )
inlinevirtual

Default Destructor.

Definition at line 57 of file ParticleSwarmOptimization.h.

Member Function Documentation

template<class PARTICLE_TYPE , class OBSERVATION_TYPE >
virtual bool ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >::init ( const unsigned int  numParticles,
const unsigned int  K,
const VectorFloat xMin,
const VectorFloat xMax,
const VectorFloat propagationModel 
)
inlinevirtual

This function initializes the PSO algorithm. This allows the user to set the number of particles, the size of the particle state Vector (set by K), the minimum and maximum range of the space the PSO algorithm should search, and the propagation model.

The default propagation model for each particle is just Gaussian noise, in that case the propagation model will be a K dimensional Vector, with each element representing sigma for the Gaussian noise for each dimension.

After you call this function, you can call the search() function to run the actual search. You can reset the particles at any time using the reset() function.

Parameters
numParticlesthe number of particles that will be used for the search
Kthe size of the particles state Vector
xMinthe minimum range of the x state Vector (i.e. the space that should be searched)
xMaxthe maximum range of the x state Vector (i.e. the space that should be searched)
propagationModelthe propagation model used for each particle, this is normally just gaussian noise (see above)
Returns
returns true if the PSO algorithm was initialized successfully, false otherwise

Definition at line 88 of file ParticleSwarmOptimization.h.

template<class PARTICLE_TYPE , class OBSERVATION_TYPE >
PARTICLE_TYPE& ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >::operator[] ( const unsigned int &  index)
inline

Provides direct access to the i'th particle. It is up to the user to ensure that i is within the range [0 numParticles-1].

Parameters
indexthe index of the particle you want to access
Returns
returns a reference to the i'th particle

Definition at line 68 of file ParticleSwarmOptimization.h.

template<class PARTICLE_TYPE , class OBSERVATION_TYPE >
virtual bool ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >::reset ( )
inlinevirtual

Resets each particles state Vector to a random position and velocity. You need to initialize the PSO algorithm first before you can use this function.

Returns
returns true if the PSO algorithm was reset successfully, false otherwise

Definition at line 133 of file ParticleSwarmOptimization.h.

template<class PARTICLE_TYPE , class OBSERVATION_TYPE >
virtual bool ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >::search ( OBSERVATION_TYPE &  observation)
inlinevirtual

Performs the main search. You need to initialize the PSO algorithm first before you can use this function.

Parameters
OBSERVATION_TYPE&observation: a reference to the observation data used for the search
Returns
returns true if the search ran successfully, false otherwise

Definition at line 151 of file ParticleSwarmOptimization.h.

template<class PARTICLE_TYPE , class OBSERVATION_TYPE >
virtual Float ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >::searchIteration ( OBSERVATION_TYPE &  observation)
inlinevirtual

Performs one iteration of the search. Normally, you do not call this function directly but instead call the main search() function. You need to initialize the PSO algorithm first before you can use this function.

Parameters
observationa reference to the observation data used for the search
Returns
returns true if the search ran successfully, false otherwise

Definition at line 209 of file ParticleSwarmOptimization.h.

template<class PARTICLE_TYPE , class OBSERVATION_TYPE >
bool ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >::setPropagationModel ( const VectorFloat propagationModel)
inline

Updates the propagation model. You need to initialize the PSO algorithm first before you can use this function.

const propagationModel: the new propagation model

Returns
returns true if the propagationModel was updated successfully, false otherwise

Definition at line 254 of file ParticleSwarmOptimization.h.


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