From 543b53d93858a548086113507b24a98010ac5a4c Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Tue, 22 Jul 2025 15:53:06 +0200 Subject: [PATCH] Initialize empty set of perturbations and add debug messages --- app/services/vns/engine.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/services/vns/engine.rb b/app/services/vns/engine.rb index 075ad1a..ff8758b 100644 --- a/app/services/vns/engine.rb +++ b/app/services/vns/engine.rb @@ -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