Skip to content

Commit

Permalink
fixed segmentation faults in ACSAntColony implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas.hammerl committed Aug 13, 2008
1 parent 1d737b1 commit 18441f2
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 3 deletions.
Binary file modified acotreewidth/trunk/lib/libaco.a
Binary file not shown.
3 changes: 2 additions & 1 deletion acotsp/trunk/include/liblocalsearch/localsearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Neighbourhood {
virtual std::vector<unsigned int> get_solution() = 0;
virtual bool has_next_neighbour_solution() = 0;
virtual const std::vector<unsigned int> &next_neighbour_solution() = 0;
virtual void reset();
};

class TwoOptNeighbourhood : public Neighbourhood {
Expand Down Expand Up @@ -70,5 +71,5 @@ class IterativeLocalSearch {
PerturbationFunction *perturbation_func_;
public:
IterativeLocalSearch(LocalSearch *local_search, PerturbationFunction *perturbation_func);
void run(int iterations=5);
void run(int iterations_without_improve=100, int ls_iteration_without_improve=10);
};
Binary file modified acotsp/trunk/lib/libaco.a
Binary file not shown.
Binary file modified acotsp/trunk/lib/liblocalsearch.a
Binary file not shown.
4 changes: 2 additions & 2 deletions libaco/trunk/src/ants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void ACSAnt::construct_pseudorandom_proportional_solution(OptimizationProblem &o
//local pheromone update
for(unsigned int i=0;i<tour->size();i++) {
if(i==0) {
((ACSPheromoneMatrix &) pheromones).local_pheromone_update(tour->size(), (*tour)[i]);
((ACSPheromoneMatrix &) pheromones).local_pheromone_update(pheromones.size()-1, (*tour)[i]);
} else {
((ACSPheromoneMatrix &) pheromones).local_pheromone_update((*tour)[i-1], (*tour)[i]);
}
Expand Down Expand Up @@ -508,7 +508,7 @@ void ACSAntColony::update_pheromones() {
std::vector<unsigned int> vertices = best_so_far_->get_vertices();
for(unsigned int i=0;i<vertices.size();i++) {
if(i==0) {
pheromones_->evaporate(vertices.size(), vertices[i]);
pheromones_->evaporate(pheromones_->size()-1, vertices[i]);
} else {
pheromones_->evaporate(vertices[i-1], vertices[i]);
}
Expand Down

0 comments on commit 18441f2

Please sign in to comment.