adjacency_list_neighborhood.h
Go to the documentation of this file.
1 
40 #ifndef HIGH_PRECISION_PSO_NEIGHBORHOOD_ADJACENCY_LIST_NEIGHBORHOOD_H_
41 #define HIGH_PRECISION_PSO_NEIGHBORHOOD_ADJACENCY_LIST_NEIGHBORHOOD_H_
42 
44 
45 namespace highprecisionpso {
46 
51 public:
60  std::vector<mpf_t*> GetGlobalAttractorPosition();
61  std::vector<mpf_t*> GetGlobalAttractorPosition(int particle_id);
62  mpf_t* GetGlobalAttractorValue();
63  mpf_t* GetGlobalAttractorValue(int particle_id);
64  void UpdateAttractorInstantly(std::vector<mpf_t*> position, mpf_t* value, int particle_id);
65  virtual std::string GetName() = 0;
66  void LoadData(std::ifstream* input_stream, ProgramVersion* version_of_stored_data);
67  void StoreData(std::ofstream* output_stream);
68 
69 protected:
75  virtual void InitializeAdjacencyList() = 0;
79  std::vector<std::vector<unsigned int> > adjacency_list;
80 
81 private:
82  int GetGlobalAttractorIndex();
83 
84  // index of particle, who's global attractor is
85  // equal to the attractor of the common swarm
86  int global_attractor_index_;
87  // global attractor visible to each particle
88  std::vector<std::vector<mpf_t*> > global_attractor_positions_;
89  std::vector<mpf_t*> global_attractor_values_cached_;
90  std::vector<unsigned int> global_attractor_values_cached_precision_;
91 };
92 
99 public:
107  LBestNeighborhood(int num_neighbors);
108  std::string GetName();
109 
110 protected:
112 
113 private:
114  const int num_neighbors_;
115 };
116 
123 public:
128  std::string GetName();
129 };
130 
138 public:
147  GridNeighborhood(int rows, int columns);
148  std::string GetName();
149 
150 protected:
152 
153 private:
154  const int grid_rows_;
155  const int grid_columns_;
156 };
157 
164 public:
169  std::string GetName();
170 
171 protected:
173 };
174 
175 } // namespace highprecisionpso
176 
177 #endif /* HIGH_PRECISION_PSO_NEIGHBORHOOD_ADJACENCY_LIST_NEIGHBORHOOD_H_ */
virtual void InitializeAdjacencyList()=0
This method initializes the adjacency list.
This class implements the lbest neighborhood topology for the particle swarm.
Definition: adjacency_list_neighborhood.h:98
This class implements the wheel topology for the particle swarm.
Definition: adjacency_list_neighborhood.h:163
This class stores a program version.
Definition: general_objects.h:54
This class implements the grid or von Neumann topology for the particle swarm.
Definition: adjacency_list_neighborhood.h:137
This file contains an abstract classes for neighborhood generation.
virtual std::string GetName()=0
Returns a string representation of this object.
mpf_t * GetGlobalAttractorValue()
Returns the value of the best global attractor.
void StoreData(std::ofstream *output_stream)
Stores the current state of this neighborhood topology such that it can completely restore the curren...
void UpdateAttractorInstantly(std::vector< mpf_t * > position, mpf_t *value, int particle_id)
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
This class implements the ring neighborhood topology for the particle swarm.
Definition: adjacency_list_neighborhood.h:122
This class is an abstract class, which implements a complete neighborhood topology through a neighbor...
Definition: adjacency_list_neighborhood.h:50
void LoadData(std::ifstream *input_stream, ProgramVersion *version_of_stored_data)
Loads data to reset the state of the neighborhood topology to the state which was stored...
std::vector< mpf_t * > GetGlobalAttractorPosition()
Returns the position of the best global attractor.
std::vector< std::vector< unsigned int > > adjacency_list
The adjacency lists, which specify the neighborhood relationship.
Definition: adjacency_list_neighborhood.h:79
base namespace for this project.
Definition: absorption.h:45