diff --git a/app/services/tables/distribution.rb b/app/services/tables/distribution.rb index a361a26..4751cf8 100644 --- a/app/services/tables/distribution.rb +++ b/app/services/tables/distribution.rb @@ -42,7 +42,8 @@ module Tables end def deep_dup - self.class.new(min_per_table: @min_per_table, max_per_table: @max_per_table, hierarchy: @hierarchy).tap do |new_distribution| + self.class.new(min_per_table: @min_per_table, max_per_table: @max_per_table, + hierarchy: @hierarchy).tap do |new_distribution| new_distribution.tables = @tables.map(&:dup) end end diff --git a/lib/tasks/vns.rake b/lib/tasks/vns.rake index 4178ee0..b8c7b3a 100644 --- a/lib/tasks/vns.rake +++ b/lib/tasks/vns.rake @@ -1,5 +1,7 @@ +# frozen_string_literal: true + namespace :vns do - desc "Benchmarks the efficiency of the VNS implementation" + desc 'Benchmarks the efficiency of the VNS implementation' task benchmark: :environment do ActsAsTenant.with_tenant(Wedding.first) do Rails.logger.info "There are #{Guest.potential.count} potential guests" @@ -12,14 +14,14 @@ namespace :vns do hierarchy = AffinityGroupsHierarchy.new initial_solution = Tables::Distribution.new(min_per_table: 8, max_per_table: 10, hierarchy:) - random = Random.new(561163) + random = Random.new(561_163) initial_solution.random_distribution(Guest.potential.shuffle(random:), random:) engine.initial_solution = initial_solution engine.target_function(&:discomfort) - solution = Rails.benchmark("VNS Benchmarking") {engine.run} + solution = Rails.benchmark('VNS Benchmarking') { engine.run } Rails.logger.info "Best solution found with discomfort: #{solution.discomfort}" end