GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
GRT::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 vector< double > &xMin, const vector< double > &xMax, const vector< double > &propagationModel)
 
virtual bool reset ()
 
virtual bool search (OBSERVATION_TYPE &observation)
 
virtual double searchIteration (OBSERVATION_TYPE &observation)
 
bool setPropagationModel (const vector< double > &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.
 
double minImprovement
 
unsigned int maxIter
 
unsigned int maxNumIterNoChange
 
double globalBestCost
 The current global best cost over all the particles.
 
vector< double > finalX
 The final estimate.
 
vector< double > globalBestX
 The state vector of the particle with the best cost.
 
vector< double > xMin
 The minimum range of the state space.
 
vector< double > xMax
 The maximum range of the state space.
 
vector< double > propagationModel
 The propagation model used to update each particle.
 
vector< PARTICLE_TYPE > particles
 A vector containing all the particles used for the search.
 
vector< vector< double > > globalBestXHistory
 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 GRT::ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >

Definition at line 41 of file ParticleSwarmOptimization.h.

Constructor & Destructor Documentation

template<class PARTICLE_TYPE , class OBSERVATION_TYPE >
GRT::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 GRT::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 GRT::ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >::init ( const unsigned int  numParticles,
const unsigned int  K,
const vector< double > &  xMin,
const vector< double > &  xMax,
const vector< double > &  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
constunsigned int numParticles: the number of particles that will be used for the search
constunsigned int K: the size of the particles state vector
constvector< double > &xMin: the minimum range of the x state vector (i.e. the space that should be searched)
constvector< double > &xMax: the maximum range of the x state vector (i.e. the space that should be searched)
constvector< double > &propagationModel: the 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& GRT::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
constunsigned int &index: the 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 GRT::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 GRT::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 double GRT::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
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 209 of file ParticleSwarmOptimization.h.

template<class PARTICLE_TYPE , class OBSERVATION_TYPE >
bool GRT::ParticleSwarmOptimization< PARTICLE_TYPE, OBSERVATION_TYPE >::setPropagationModel ( const vector< double > &  propagationModel)
inline

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

const vector< double > &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: