Recreate simulations whenever a guest changes their attendance #85

Merged
bustikiller merged 8 commits from simulations-lifecycle into main 2024-11-03 12:51:14 +00:00
2 changed files with 21 additions and 14 deletions
Showing only changes of commit 8d09fd733f - Show all commits

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
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