neighborhood.h
Go to the documentation of this file.
1 
40 #ifndef HIGH_PRECISION_PSO_NEIGHBORHOOD_NEIGHBORHOOD_H_
41 #define HIGH_PRECISION_PSO_NEIGHBORHOOD_NEIGHBORHOOD_H_
42 
43 #include <fstream>
44 #include <gmp.h>
45 #include <queue>
46 #include <vector>
47 
49 #include "general/particle.h"
50 
51 namespace highprecisionpso {
52 
57 public:
61  virtual ~Neighborhood();
69  std::vector<mpf_t*> GetGlobalAttractorPosition(Particle* p);
77  virtual std::vector<mpf_t*> GetGlobalAttractorPosition(int particle_id) = 0;
83  virtual std::vector<mpf_t*> GetGlobalAttractorPosition() = 0;
99  virtual mpf_t* GetGlobalAttractorValue(int particle_id) = 0;
105  virtual mpf_t* GetGlobalAttractorValue() = 0;
116  void UpdateAttractor(std::vector<mpf_t*> position, mpf_t* value, Particle* p);
127  void UpdateAttractor(std::vector<mpf_t*> position, mpf_t* value, int particle_id);
135  void UpdateAttractorInstantly(std::vector<mpf_t*> position, mpf_t* value, Particle* p);
143  virtual void UpdateAttractorInstantly(std::vector<mpf_t*> position, mpf_t* value, int particle_id) = 0;
149  void ProceedAllUpdates();
155  virtual std::string GetName() = 0;
162  virtual void LoadData(std::ifstream* input_stream, ProgramVersion* version_of_stored_data) = 0;
168  virtual void StoreData(std::ofstream* output_stream) = 0;
169 
170 private:
171  std::queue<std::pair< std::pair< std::vector<mpf_t*>, mpf_t*>, int> > remaining_updates_;
172 };
173 
174 } // namespace highprecisionpso
175 
176 #endif /* HIGH_PRECISION_PSO_NEIGHBORHOOD_NEIGHBORHOOD_H_ */
virtual ~Neighborhood()
The destructor.
The particles for the particle swarm optimization algorithm.
Definition: particle.h:54
virtual mpf_t * GetGlobalAttractorValue()=0
Returns the value of the best global attractor.
This class stores a program version.
Definition: general_objects.h:54
void UpdateAttractorInstantly(std::vector< mpf_t * > position, mpf_t *value, Particle *p)
Depending on the neighborhood topology the new position replaces previous global attractors if the ne...
This class is an abstract class. It supplies the interface for neighborhood topologies of the particl...
Definition: neighborhood.h:56
virtual std::vector< mpf_t * > GetGlobalAttractorPosition()=0
Returns the position of the best global attractor.
virtual void StoreData(std::ofstream *output_stream)=0
Stores the current state of this neighborhood topology such that it can completely restore the curren...
This file contains information about the particles of the swarm.
virtual void LoadData(std::ifstream *input_stream, ProgramVersion *version_of_stored_data)=0
Loads data to reset the state of the neighborhood topology to the state which was stored...
void UpdateAttractor(std::vector< mpf_t * > position, mpf_t *value, Particle *p)
Appends the tuple of specified position, value and particle to the list of pending updates for global...
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
void ProceedAllUpdates()
Initializes the processing of all entries in the list of pending updates for the global attractors...
virtual std::string GetName()=0
Returns a string representation of this object.