Some checks failed
Run unit tests / copyright_notice (pull_request) Successful in 38s
Run unit tests / rubocop (pull_request) Failing after 58s
Run unit tests / check-licenses (pull_request) Successful in 1m0s
Run unit tests / unit_tests (pull_request) Successful in 1m14s
Run unit tests / build-static-assets (pull_request) Successful in 14m33s
28 lines
893 B
Ruby
28 lines
893 B
Ruby
namespace :vns do
|
|
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"
|
|
|
|
engine = VNS::Engine.new
|
|
|
|
engine.add_perturbation(Tables::Swap)
|
|
engine.add_perturbation(Tables::Shift)
|
|
|
|
hierarchy = AffinityGroupsHierarchy.new
|
|
initial_solution = Tables::Distribution.new(min_per_table: 8, max_per_table: 10, hierarchy:)
|
|
|
|
random = Random.new(561163)
|
|
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}
|
|
|
|
Rails.logger.info "Best solution found with discomfort: #{solution.discomfort}"
|
|
end
|
|
end
|
|
end
|