Compare commits
No commits in common. "ead48c2588c83d06b7b6f908a267c689c1519d73" and "ff0e0b69314d38cacf3ddb8941d009ebe3b79efa" have entirely different histories.
ead48c2588
...
ff0e0b6931
@ -29,7 +29,7 @@ module VNS
|
|||||||
@best_score = @target_function.call(@best_solution)
|
@best_score = @target_function.call(@best_solution)
|
||||||
|
|
||||||
self.class.sequence(@perturbations).each do |perturbation|
|
self.class.sequence(@perturbations).each do |perturbation|
|
||||||
optimize(perturbation)
|
optimize(perturbation.new(@best_solution))
|
||||||
end
|
end
|
||||||
|
|
||||||
@best_solution
|
@best_solution
|
||||||
@ -37,22 +37,15 @@ module VNS
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def optimize(perturbation_klass)
|
def optimize(perturbation)
|
||||||
loop do
|
perturbation.each do |alternative_solution|
|
||||||
optimized = false
|
|
||||||
|
|
||||||
perturbation_klass.new(@best_solution).each do |alternative_solution|
|
|
||||||
score = @target_function.call(alternative_solution)
|
score = @target_function.call(alternative_solution)
|
||||||
next if score >= @best_score
|
next if score >= @best_score
|
||||||
|
|
||||||
@best_solution = alternative_solution.deep_dup
|
@best_solution = alternative_solution.deep_dup
|
||||||
@best_score = score
|
@best_score = score
|
||||||
optimized = true
|
|
||||||
|
|
||||||
break
|
return optimize(perturbation.class.new(@best_solution))
|
||||||
end
|
|
||||||
|
|
||||||
return unless optimized
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user