Define a job to generate table simulations
This commit is contained in:
parent
8d83c63fa6
commit
1f919644a3
20
app/jobs/table_simulator_job.rb
Normal file
20
app/jobs/table_simulator_job.rb
Normal 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
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user