Initialize empty set of perturbations and add debug messages
This commit is contained in:
parent
e1a5e4f73e
commit
543b53d938
@ -20,6 +20,11 @@ module VNS
|
||||
@optimizations << klass
|
||||
end
|
||||
|
||||
def add_perturbation(klass)
|
||||
@perturbations ||= Set.new
|
||||
@perturbations << klass
|
||||
end
|
||||
|
||||
attr_writer :initial_solution
|
||||
|
||||
def run
|
||||
@ -27,13 +32,18 @@ module VNS
|
||||
raise 'No optimizations defined' unless @optimizations
|
||||
raise 'No initial solution defined' unless @initial_solution
|
||||
|
||||
@perturbations ||= Set.new
|
||||
|
||||
@best_solution = @initial_solution
|
||||
@best_score = @target_function.call(@best_solution)
|
||||
|
||||
self.class.sequence(@optimizations).each do |optimization|
|
||||
optimize(optimization)
|
||||
Rails.logger.debug { "Finished optimization phase: #{optimization.name}" }
|
||||
end
|
||||
|
||||
Rails.logger.debug { "Finished all optimization phases" }
|
||||
|
||||
@best_solution
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user