Compare commits

..

No commits in common. "ead48c2588c83d06b7b6f908a267c689c1519d73" and "ff0e0b69314d38cacf3ddb8941d009ebe3b79efa" have entirely different histories.

View File

@ -29,7 +29,7 @@ module VNS
@best_score = @target_function.call(@best_solution)
self.class.sequence(@perturbations).each do |perturbation|
optimize(perturbation)
optimize(perturbation.new(@best_solution))
end
@best_solution
@ -37,22 +37,15 @@ module VNS
private
def optimize(perturbation_klass)
loop do
optimized = false
def optimize(perturbation)
perturbation.each do |alternative_solution|
score = @target_function.call(alternative_solution)
next if score >= @best_score
perturbation_klass.new(@best_solution).each do |alternative_solution|
score = @target_function.call(alternative_solution)
next if score >= @best_score
@best_solution = alternative_solution.deep_dup
@best_score = score
@best_solution = alternative_solution.deep_dup
@best_score = score
optimized = true
break
end
return unless optimized
return optimize(perturbation.class.new(@best_solution))
end
end
end