Define a job to generate table simulations

This commit is contained in:
Manuel Bustillo 2024-11-03 09:05:51 +01:00
parent 3be71406f8
commit 8d09fd733f
2 changed files with 21 additions and 14 deletions

View File

@ -0,0 +1,20 @@
class TableSimulatorJob < ApplicationJob
queue_as :default
def perform(*_args)
engine = VNS::Engine.new
engine.add_perturbation(Tables::Swap)
initial_solution = Tables::Distribution.new(min_per_table: 8, max_per_table: 10)
initial_solution.random_distribution(Guest.all.shuffle)
engine.initial_solution = initial_solution
engine.target_function(&:discomfort)
best_solution = engine.run
best_solution.save!
end
end

View File

@ -1,18 +1,5 @@
namespace :vns do namespace :vns do
task distribute_tables: :environment do task distribute_tables: :environment do
engine = VNS::Engine.new
engine.add_perturbation(Tables::Swap)
initial_solution = Tables::Distribution.new(min_per_table: 8, max_per_table: 10)
initial_solution.random_distribution(Guest.all.shuffle)
engine.initial_solution = initial_solution
engine.target_function(&:discomfort)
best_solution = engine.run
best_solution.save!
end end
end end