Skip to content

Commit

Permalink
remove unnecessary function in neighborhood
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-rass committed Sep 4, 2019
1 parent 0b2d825 commit e17d0d0
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 58 deletions.
28 changes: 0 additions & 28 deletions src/neighborhood/adjacency_list_neighborhood.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,34 +67,6 @@ AdjacencyListNeighborhood::AdjacencyListNeighborhood(){
adjacency_list.clear();
}

void AdjacencyListNeighborhood::SetGlobalAttractorPositions(std::vector<std::vector<mpf_t*> > globalAttractors){
AssertCondition(configuration::g_particles > 0, "The number of particles needs to be positive.");
AssertCondition(globalAttractors.size() == (unsigned int)configuration::g_particles, "The number of particles is inconsistent.");
AssertCondition(configuration::g_dimensions > 0, "The number of dimensions needs to be positive.");
AssertCondition(globalAttractors[0].size() == (unsigned int)configuration::g_dimensions, "The number of dimensions is inconsistent.");
for(int p = 0; p < configuration::g_particles; p++){
AssertCondition(globalAttractors[p].size() == (unsigned int)configuration::g_dimensions, "The number of dimensions is inconsistent.");
}
for(unsigned int i = 0; i < global_attractor_positions_.size(); i++){
arbitraryprecisioncalculation::vectoroperations::ReleaseValues(global_attractor_positions_[i]);
global_attractor_positions_[i].clear();
}
global_attractor_positions_ = std::vector<std::vector<mpf_t*> >(configuration::g_particles);
for(int i = 0; i < configuration::g_particles; i++) {
global_attractor_positions_[i] = arbitraryprecisioncalculation::vectoroperations::Clone(globalAttractors[i]);
}
for(unsigned int i = 0; i < global_attractor_values_cached_.size(); i++){
if(global_attractor_values_cached_[i] != NULL) {
arbitraryprecisioncalculation::mpftoperations::ChangeNumberOfMpftValuesCached(-1);
arbitraryprecisioncalculation::mpftoperations::ReleaseValue(global_attractor_values_cached_[i]);
global_attractor_values_cached_[i] = NULL;
}
}
global_attractor_values_cached_ = std::vector<mpf_t*>(configuration::g_particles, (mpf_t*) NULL);
global_attractor_values_cached_precision_ = std::vector<unsigned int>(configuration::g_particles, 0);
global_attractor_index_ = -1;
}

std::vector<mpf_t*> AdjacencyListNeighborhood::GetGlobalAttractorPosition(){
int id = GetGlobalAttractorIndex();
return arbitraryprecisioncalculation::vectoroperations::Clone(global_attractor_positions_[id]);
Expand Down
1 change: 0 additions & 1 deletion src/neighborhood/adjacency_list_neighborhood.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class AdjacencyListNeighborhood: public Neighborhood {
* @brief The destructor.
*/
~AdjacencyListNeighborhood();
void SetGlobalAttractorPositions(std::vector<std::vector<mpf_t*> > global_attractors);
std::vector<mpf_t*> GetGlobalAttractorPosition();
std::vector<mpf_t*> GetGlobalAttractorPosition(int particle_id);
mpf_t* GetGlobalAttractorValue();
Expand Down
19 changes: 0 additions & 19 deletions src/neighborhood/global_best.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,6 @@ GlobalBest::GlobalBest(){
global_attractor_value_cached_precision_ = 1;
}

void GlobalBest::SetGlobalAttractorPositions(std::vector<std::vector<mpf_t*> > globalAttractors){
AssertCondition(configuration::g_particles > 0, "The number of particles needs to be positive.");
AssertCondition(globalAttractors.size() == (unsigned int)configuration::g_particles, "The number of particles is inconsistent.");
AssertCondition(configuration::g_dimensions > 0, "The number of dimensions needs to be positive.");
AssertCondition(globalAttractors[0].size() == (unsigned int)configuration::g_dimensions, "The number of dimensions is inconsistent.");
arbitraryprecisioncalculation::vectoroperations::ReleaseValues(global_attractor_position_);
arbitraryprecisioncalculation::mpftoperations::ReleaseValue(global_attractor_value_cached_);
if(global_attractor_value_cached_ == NULL) arbitraryprecisioncalculation::mpftoperations::ChangeNumberOfMpftValuesCached(1);
global_attractor_position_ = arbitraryprecisioncalculation::vectoroperations::Clone(globalAttractors[0]);
global_attractor_value_cached_ = configuration::g_function->Evaluate(global_attractor_position_);
global_attractor_value_cached_precision_ = mpf_get_default_prec();
for(int p = 0; p < configuration::g_particles; p++){
AssertCondition(globalAttractors[p].size() == (unsigned int)configuration::g_dimensions, "The number of dimensions is inconsistent.");
for(int d = 0; d < configuration::g_dimensions; d++){
AssertCondition(arbitraryprecisioncalculation::mpftoperations::Compare((globalAttractors[p][d]), (global_attractor_position_[d])) == 0, "For global best neighborhood all global attractors need to be equal, but this is not the case.");
}
}
}

std::vector<mpf_t*> GlobalBest::GetGlobalAttractorPosition(){
return arbitraryprecisioncalculation::vectoroperations::Clone(global_attractor_position_);
}
Expand Down
1 change: 0 additions & 1 deletion src/neighborhood/global_best.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class GlobalBest: public Neighborhood {
* @brief The destructor.
*/
~GlobalBest();
void SetGlobalAttractorPositions(std::vector<std::vector<mpf_t*> > global_attractors);
std::vector<mpf_t*> GetGlobalAttractorPosition();
std::vector<mpf_t*> GetGlobalAttractorPosition(int particle_id);
mpf_t* GetGlobalAttractorValue();
Expand Down
9 changes: 0 additions & 9 deletions src/neighborhood/neighborhood.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ class Neighborhood{
*/
virtual ~Neighborhood();
/**
* @brief Sets the global attractors according to the given vector of global attractor positions.
*
* There should be exactly one global attractor position for each particle,
* because, depending on the topology, each particle can have a different global attractor.
*
* @param global_attractors The vector of global attractor positions.
*/
virtual void SetGlobalAttractorPositions(std::vector<std::vector<mpf_t*> > global_attractors) = 0;
/**
* @brief Returns the position of the global attractor for the given particle.
*
* @param p The particle.
Expand Down

0 comments on commit e17d0d0

Please sign in to comment.