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

Public Member Functions

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

Public Attributes

bool initialized
 
unsigned int K
 
Float w
 
Float c1
 
Float c2
 
Float localBestCost
 
VectorFloat x
 
VectorFloat v
 
VectorFloat localBestX
 
VectorFloat xMin
 
VectorFloat xMax
 
Random random
 

Detailed Description

template<class OBSERVATION_TYPE>
class PSOParticle< OBSERVATION_TYPE >

Definition at line 29 of file PSOParticle.h.

Constructor & Destructor Documentation

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

Default Constructor.

Definition at line 35 of file PSOParticle.h.

template<class OBSERVATION_TYPE >
PSOParticle< OBSERVATION_TYPE >::PSOParticle ( const unsigned int  K,
const VectorFloat xMin,
const VectorFloat xMax 
)
inline

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

Parameters
Kthe size of the particle state Vector, must be greater than zero
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)

Definition at line 46 of file PSOParticle.h.

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

Defines the copy constructor.

Parameters
rhsanother instance of the PSOParticle which will be copied to this instance

Definition at line 55 of file PSOParticle.h.

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

Default Destructor.

Definition at line 62 of file PSOParticle.h.

Member Function Documentation

template<class OBSERVATION_TYPE >
virtual Float 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
observationa 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 >
Float PSOParticle< OBSERVATION_TYPE >::gauss ( Float  x,
Float  mu,
Float  sigma 
)
inline

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

Parameters
xthe x parameter for the Gaussian distrubution
muthe mu parameter for the Gaussian distrubution
sigmathe 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 PSOParticle< OBSERVATION_TYPE >::init ( const unsigned int  K,
const VectorFloat xMin,
const VectorFloat xMax 
)
inlinevirtual

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

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

Definition at line 97 of file PSOParticle.h.

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

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

Parameters
xthe x parameter for the Gaussian distrubution
muthe mu parameter for the Gaussian distrubution
sigmathe 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& 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
rhsanother 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 PSOParticle< OBSERVATION_TYPE >::propagate ( const VectorFloat 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
modelthe 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 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 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 >
Float PSOParticle< OBSERVATION_TYPE >::SQR ( Float  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 PSOParticle< OBSERVATION_TYPE >::update ( const VectorFloat globalBestX)
inlinevirtual

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

Parameters
globalBestXthe 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: