highprecisionpso::Particle Class Reference

The particles for the particle swarm optimization algorithm. More...

#include <particle.h>

Public Member Functions

 Particle ()
 The constructor. More...
 
std::vector< mpf_t * > GetLocalAttractorPosition ()
 Clones the position of the current local attractor. More...
 
mpf_t * GetLocalAttractorValue ()
 Calculates the objective function value of the local attractor. More...
 
std::vector< mpf_t * > GetPosition ()
 Clones the position of the particle. More...
 
std::vector< mpf_t * > GetVelocity ()
 Clones the velocity of the particle. More...
 
void LoadData (std::ifstream *input_stream, ProgramVersion *version_of_stored_data)
 Loads the complete data of this particle from some input stream. More...
 
void SetLocalAttractorPosition (std::vector< mpf_t * > pos)
 Sets the position of the local attractor to the supplied position. More...
 
void SetPosition (std::vector< mpf_t * > pos)
 Sets the position to the supplied position. More...
 
void SetVelocity (std::vector< mpf_t * > vel)
 Sets the velocity to the supplied velocity. More...
 
void StoreData (std::ofstream *output_stream)
 Stores the complete data of this particle to some output stream. More...
 
void UpdateGlobalAttractor (std::vector< mpf_t * > goodPosition, mpf_t *goodValue)
 Informs the neighborhood about a new local attractor, which might be relevant for the choice of a global attractor. More...
 
void UpdatePosition ()
 Tells the position and velocity updater to update position and velocity of this particle. More...
 

Public Attributes

int id
 The index of the particle. More...
 
std::vector< mpf_t * > local_attractor_position
 The local attractor of the particle. More...
 
std::vector< mpf_t * > position
 The position of the particle. More...
 
std::vector< mpf_t * > velocity
 The velocity of the particle. More...
 

Detailed Description

The particles for the particle swarm optimization algorithm.

Constructor & Destructor Documentation

highprecisionpso::Particle::Particle ( )

The constructor.

Initializes the index of the particle. Position and velocity need to be set manually with the set methods.

Member Function Documentation

std::vector<mpf_t*> highprecisionpso::Particle::GetLocalAttractorPosition ( )

Clones the position of the current local attractor.

Returns
The position of the local attractor.
mpf_t* highprecisionpso::Particle::GetLocalAttractorValue ( )

Calculates the objective function value of the local attractor.

Returns
The function value.
std::vector<mpf_t*> highprecisionpso::Particle::GetPosition ( )

Clones the position of the particle.

Returns
The position.
std::vector<mpf_t*> highprecisionpso::Particle::GetVelocity ( )

Clones the velocity of the particle.

Returns
The velocity.
void highprecisionpso::Particle::LoadData ( std::ifstream *  input_stream,
ProgramVersion version_of_stored_data 
)

Loads the complete data of this particle from some input stream.

Parameters
input_streamThe input stream.
version_of_stored_dataThe version of the program at the time of backup generation.
void highprecisionpso::Particle::SetLocalAttractorPosition ( std::vector< mpf_t * >  pos)

Sets the position of the local attractor to the supplied position.

Parameters
posThe new position of the local attractor.
void highprecisionpso::Particle::SetPosition ( std::vector< mpf_t * >  pos)

Sets the position to the supplied position.

Additionally it checks whether the new position is better than the local attractor. If this is the case the local attractor position is updated and the updateGlobalAttractor function is called.

Parameters
posThe new position of the particle.
void highprecisionpso::Particle::SetVelocity ( std::vector< mpf_t * >  vel)

Sets the velocity to the supplied velocity.

Parameters
velThe new velocity of the particle.
void highprecisionpso::Particle::StoreData ( std::ofstream *  output_stream)

Stores the complete data of this particle to some output stream.

Parameters
output_streamThe output stream.
void highprecisionpso::Particle::UpdateGlobalAttractor ( std::vector< mpf_t * >  goodPosition,
mpf_t *  goodValue 
)

Informs the neighborhood about a new local attractor, which might be relevant for the choice of a global attractor.

Parameters
goodPositionThe position of the new local attractor.
goodValueThe value of the objective function at the specified position.
void highprecisionpso::Particle::UpdatePosition ( )

Tells the position and velocity updater to update position and velocity of this particle.

Member Data Documentation

int highprecisionpso::Particle::id

The index of the particle.

Warning
Do not change this value.
std::vector<mpf_t*> highprecisionpso::Particle::local_attractor_position

The local attractor of the particle.

Warning
Change this value only with the set method.
std::vector<mpf_t*> highprecisionpso::Particle::position

The position of the particle.

Warning
Change this value only with the set method.
std::vector<mpf_t*> highprecisionpso::Particle::velocity

The velocity of the particle.

Warning
Change this value only with the set method.

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