diff --git a/src/algorithms/stochastic/tabu_search.rb b/src/algorithms/stochastic/tabu_search.rb index 349b3196..fc4ff5f7 100644 --- a/src/algorithms/stochastic/tabu_search.rb +++ b/src/algorithms/stochastic/tabu_search.rb @@ -74,7 +74,7 @@ def search(cities, tabu_list_size, candidate_list_size, max_iter) current = best_candidate best = best_candidate if best_candidate[:cost] < best[:cost] best_candidate_edges.each {|edge| tabu_list.push(edge)} - tabu_list.pop while tabu_list.size > tabu_list_size + tabu_list.shift while tabu_list.size > tabu_list_size end puts " > iteration #{(iter+1)}, best=#{best[:cost]}" end @@ -99,4 +99,4 @@ def search(cities, tabu_list_size, candidate_list_size, max_iter) # execute the algorithm best = search(berlin52, tabu_list_size, max_candidates, max_iter) puts "Done. Best Solution: c=#{best[:cost]}, v=#{best[:vector].inspect}" -end \ No newline at end of file +end