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::PSOParticle< OBSERVATION_TYPE > Class Template Reference

Public Member Functions

 PSOParticle ()
 
 PSOParticle (const unsigned int K, const vector< double > &xMin, const vector< double > &xMax)
 
 PSOParticle (const PSOParticle &rhs)
 
virtual ~PSOParticle ()
 
PSOParticleoperator= (const PSOParticle &rhs)
 
virtual bool init (const unsigned int K, const vector< double > &xMin, const vector< double > &xMax)
 
virtual bool propagate (const vector< double > &model)
 
virtual bool update (const vector< double > &globalBestX)
 
virtual double evaluate (OBSERVATION_TYPE &observation)
 
virtual bool reset ()
 
bool setRandomSeed (unsigned long long seed)
 
double normal (double x, double mu, double sigma)
 
double gauss (double x, double mu, double sigma)
 
double SQR (double x)
 

Public Attributes

bool initialized
 
unsigned int K
 
double w
 
double c1
 
double c2
 
double localBestCost
 
vector< double > x
 
vector< double > v
 
vector< double > localBestX
 
vector< double > xMin
 
vector< double > xMax
 
Random random
 

Detailed Description

template<class OBSERVATION_TYPE>
class GRT::PSOParticle< OBSERVATION_TYPE >

Definition at line 29 of file PSOParticle.h.

Constructor & Destructor Documentation

template<class OBSERVATION_TYPE >
GRT::PSOParticle< OBSERVATION_TYPE >::PSOParticle ( )
inline

Default Constructor.

Definition at line 35 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
GRT::PSOParticle< OBSERVATION_TYPE >::PSOParticle ( const unsigned int  K,
const vector< double > &  xMin,
const vector< double > &  xMax 
)
inline

This constructor attempts to initialize the particle, see the init function for more info.

Parameters
constunsigned int K: the size of the particle state vector, must be greater than zero
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)

Definition at line 46 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
GRT::PSOParticle< OBSERVATION_TYPE >::PSOParticle ( const PSOParticle< OBSERVATION_TYPE > &  rhs)
inline

Defines the copy constructor.

Parameters
constPSOParticle &rhs: another instance of the PSOParticle which will be copied to this instance

Definition at line 55 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
virtual GRT::PSOParticle< OBSERVATION_TYPE >::~PSOParticle ( )
inlinevirtual

Default Destructor.

Definition at line 62 of file PSOParticle.h.

Member Function Documentation

template<class OBSERVATION_TYPE >
virtual double GRT::PSOParticle< OBSERVATION_TYPE >::evaluate ( OBSERVATION_TYPE &  observation)
inlinevirtual

This function is used to evaluate the fitness of each particle. This function uses the squared distance between the estimated state vector and the observation, the observation must therefore have a length of K.

For most cases, you will need to override this function and replace the evaluation code with your own.

Parameters
OBSERVATION_TYPE&observation: a reference to the latest observation
Returns
returns the particles evaluation, -1 will be returned if the evaluation fails

Definition at line 191 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
double GRT::PSOParticle< OBSERVATION_TYPE >::gauss ( double  x,
double  mu,
double  sigma 
)
inline

Gets the standard Gaussian Distrubution for x, given mu and sigma

Parameters
doublex: the x parameter for the Gaussian distrubution
doublemu: the mu parameter for the Gaussian distrubution
doublesigma: the sigma parameter for the Gaussian distrubution
Returns
returns the likelihood of x, given mu and sigma

Definition at line 264 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
virtual bool GRT::PSOParticle< OBSERVATION_TYPE >::init ( const unsigned int  K,
const vector< double > &  xMin,
const vector< double > &  xMax 
)
inlinevirtual

Initializes the PSOParticle. The size of xMin and xMax must match K.

Parameters
constunsigned int K: the size of the particle state vector, must be greater than zero
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)
Returns
returns true if the particle was initialized, false otherwise

Definition at line 97 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
double GRT::PSOParticle< OBSERVATION_TYPE >::normal ( double  x,
double  mu,
double  sigma 
)
inline

Gets the Normal Gaussian Distrubution for x, given mu and sigma

Parameters
doublex: the x parameter for the Gaussian distrubution
doublemu: the mu parameter for the Gaussian distrubution
doublesigma: the sigma parameter for the Gaussian distrubution
Returns
returns the likelihood of x, given mu and sigma

Definition at line 252 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
PSOParticle& GRT::PSOParticle< OBSERVATION_TYPE >::operator= ( const PSOParticle< OBSERVATION_TYPE > &  rhs)
inline

Defines the equals operator, copies the data from the right hand instance to this instance.

Parameters
constPSOParticle &rhs: another instance of the PSOParticle which will be copied to this instance

Definition at line 69 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
virtual bool GRT::PSOParticle< OBSERVATION_TYPE >::propagate ( const vector< double > &  model)
inlinevirtual

Propogates the particle, using the model. The default model used here is Gaussian Noise, in that case the propagation model will be a K dimensional vector, with each of the k values represen representing sigma for each dimension (it is assumed mu = 0).

If you override this function then you can define your own model.

Parameters
constvector< double > &model: the propagation model, this should be a K*2 dimensional vector
Returns
returns true if the particle was propagated, false otherwise

Definition at line 129 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
virtual bool GRT::PSOParticle< OBSERVATION_TYPE >::reset ( )
inlinevirtual

Resets the particles state vector with random uniform noise.

Returns
returns true if the particle was reset, false otherwise

Definition at line 217 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
bool GRT::PSOParticle< OBSERVATION_TYPE >::setRandomSeed ( unsigned long long  seed)
inline

Sets the particles random seed.

Parameters
unsignedlong long seed: the new seed value
Returns
returns true if the seed was set, false otherwise

Definition at line 239 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
double GRT::PSOParticle< OBSERVATION_TYPE >::SQR ( double  x)
inline

Gets the square of x.

Parameters
doublex: the value you want to square
Returns
returns the square of x

Definition at line 274 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
virtual bool GRT::PSOParticle< OBSERVATION_TYPE >::update ( const vector< double > &  globalBestX)
inlinevirtual

Update the particle, using the globalBest state vector across all particles.

Parameters
constvector< double > &globalBestX: the globe best state vector across all particles
Returns
returns true if the particle was updated, false otherwise

Definition at line 152 of file PSOParticle.h.


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