particle.h
Go to the documentation of this file.
1 
40 #ifndef HIGH_PRECISION_PSO_GENERAL_PARTICLE_H_
41 #define HIGH_PRECISION_PSO_GENERAL_PARTICLE_H_
42 
43 #include <fstream>
44 #include <gmp.h>
45 #include <vector>
46 
48 
49 namespace highprecisionpso {
50 
54 class Particle {
55 public:
61  Particle();
62 
68  std::vector<mpf_t*> GetLocalAttractorPosition();
74  mpf_t* GetLocalAttractorValue();
80  std::vector<mpf_t*> GetPosition();
86  std::vector<mpf_t*> GetVelocity();
87 
93  void SetLocalAttractorPosition(std::vector<mpf_t*> pos);
102  void SetPosition(std::vector<mpf_t*> pos);
108  void SetVelocity(std::vector<mpf_t*> vel);
109 
116  void UpdateGlobalAttractor(std::vector<mpf_t*> goodPosition,
117  mpf_t* goodValue);
121  void UpdatePosition();
122 
129  void LoadData(std::ifstream* input_stream, ProgramVersion* version_of_stored_data);
135  void StoreData(std::ofstream* output_stream);
136 
141  int id;
146  std::vector<mpf_t*> local_attractor_position;
151  std::vector<mpf_t*> position;
156  std::vector<mpf_t*> velocity;
157 
158 private:
159  static int active_particles_;
160  mpf_t* local_attractor_value_cached_;
161  unsigned int local_attractor_value_cached_precision_;
162 };
163 
164 } // namespace highprecisionpso
165 
166 #endif /* HIGH_PRECISION_PSO_GENERAL_PARTICLE_H_ */
void SetLocalAttractorPosition(std::vector< mpf_t * > pos)
Sets the position of the local attractor to the supplied position.
The particles for the particle swarm optimization algorithm.
Definition: particle.h:54
std::vector< mpf_t * > local_attractor_position
The local attractor of the particle.
Definition: particle.h:146
void LoadData(std::ifstream *input_stream, ProgramVersion *version_of_stored_data)
Loads the complete data of this particle from some input stream.
This class stores a program version.
Definition: general_objects.h:54
void UpdatePosition()
Tells the position and velocity updater to update position and velocity of this particle.
void StoreData(std::ofstream *output_stream)
Stores the complete data of this particle to some output stream.
mpf_t * GetLocalAttractorValue()
Calculates the objective function value of the local attractor.
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 glo...
void SetPosition(std::vector< mpf_t * > pos)
Sets the position to the supplied position.
std::vector< mpf_t * > GetLocalAttractorPosition()
Clones the position of the current local attractor.
int id
The index of the particle.
Definition: particle.h:141
std::vector< mpf_t * > GetVelocity()
Clones the velocity of the particle.
std::vector< mpf_t * > position
The position of the particle.
Definition: particle.h:151
std::vector< mpf_t * > GetPosition()
Clones the position of the particle.
void SetVelocity(std::vector< mpf_t * > vel)
Sets the velocity to the supplied velocity.
This file contains various general objects which can be used by or contained in other objects...
base namespace for this project.
Definition: absorption.h:45
Particle()
The constructor.
std::vector< mpf_t * > velocity
The velocity of the particle.
Definition: particle.h:156