Compare commits

..

12 Commits

Author SHA1 Message Date
5dce77c29d Merge pull request 'Define a benchmark to measure the VNS performance and prevent redundant hierarchy calculations' (#298) from benchmark into main
All checks were successful
Run unit tests / rubocop (push) Has been skipped
Run unit tests / copyright_notice (push) Has been skipped
Run unit tests / check-licenses (push) Has been skipped
Run unit tests / unit_tests (push) Successful in 54s
Run unit tests / build-static-assets (push) Successful in 9m27s
Reviewed-on: #298
2025-07-18 14:26:10 +00:00
03e09c74a0 Rubocop fixes
All checks were successful
Run unit tests / copyright_notice (pull_request) Successful in 54s
Run unit tests / check-licenses (pull_request) Successful in 1m14s
Run unit tests / rubocop (pull_request) Successful in 1m24s
Run unit tests / unit_tests (pull_request) Successful in 4m10s
Run unit tests / build-static-assets (pull_request) Successful in 12m27s
2025-07-18 16:09:28 +02:00
da51a073cc Define a benchmark to measure the VNS performance and prevent redundant hierarchy calculations
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
2025-07-18 16:05:02 +02:00
1953ba9d7f Merge pull request 'Update dependency redis to v5.4.1' (#297) from renovate/redis-5.x-lockfile into main
All checks were successful
Run unit tests / rubocop (push) Has been skipped
Run unit tests / check-licenses (push) Has been skipped
Run unit tests / copyright_notice (push) Has been skipped
Run unit tests / unit_tests (push) Successful in 1m20s
Run unit tests / build-static-assets (push) Successful in 9m34s
Reviewed-on: #297
2025-07-18 12:15:14 +00:00
Renovate Bot
bea90af59d Update dependency redis to v5.4.1
All checks were successful
Run unit tests / rubocop (pull_request) Successful in 6m14s
Run unit tests / copyright_notice (pull_request) Successful in 7m19s
Run unit tests / check-licenses (pull_request) Successful in 8m28s
Run unit tests / unit_tests (pull_request) Successful in 16m8s
Run unit tests / build-static-assets (pull_request) Successful in 40m14s
2025-07-18 02:06:51 +00:00
c1c90f4db1 Merge pull request 'Update dependency annotaterb to v4.17.0' (#296) from renovate/annotaterb-4.x-lockfile into main
All checks were successful
Run unit tests / rubocop (push) Has been skipped
Run unit tests / check-licenses (push) Has been skipped
Run unit tests / copyright_notice (push) Has been skipped
Run unit tests / unit_tests (push) Successful in 26m22s
Run unit tests / build-static-assets (push) Successful in 37m23s
2025-07-17 02:06:40 +00:00
Renovate Bot
bcddb802b7 Update dependency annotaterb to v4.17.0
All checks were successful
Run unit tests / rubocop (pull_request) Successful in 1m59s
Run unit tests / check-licenses (pull_request) Successful in 1m48s
Run unit tests / copyright_notice (pull_request) Successful in 2m37s
Run unit tests / unit_tests (pull_request) Successful in 14m31s
Run unit tests / build-static-assets (pull_request) Successful in 9m26s
2025-07-15 02:04:13 +00:00
edfb7227cf Merge pull request 'Update dependency solid_queue to v1.2.0' (#295) from renovate/solid_queue-1.x-lockfile into main
Some checks failed
Run unit tests / rubocop (push) Has been skipped
Run unit tests / check-licenses (push) Has been skipped
Run unit tests / copyright_notice (push) Has been skipped
Run unit tests / unit_tests (push) Successful in 14m46s
Run unit tests / build-static-assets (push) Failing after 7s
2025-07-15 02:04:00 +00:00
Renovate Bot
b20078a115 Update dependency solid_queue to v1.2.0
All checks were successful
Run unit tests / copyright_notice (pull_request) Successful in 1m41s
Run unit tests / rubocop (pull_request) Successful in 4m15s
Run unit tests / check-licenses (pull_request) Successful in 4m51s
Run unit tests / unit_tests (pull_request) Successful in 14m20s
Run unit tests / build-static-assets (pull_request) Successful in 14m8s
2025-07-12 02:06:34 +00:00
71562e8143 Merge pull request 'Update dependency rubocop to v1.78.0' (#294) from renovate/rubocop-1.x-lockfile into main
All checks were successful
Run unit tests / rubocop (push) Has been skipped
Run unit tests / check-licenses (push) Has been skipped
Run unit tests / copyright_notice (push) Has been skipped
Run unit tests / unit_tests (push) Successful in 1m39s
Run unit tests / build-static-assets (push) Successful in 10m22s
Reviewed-on: #294
2025-07-09 13:19:30 +00:00
Renovate Bot
6478760b8d Update dependency rubocop to v1.78.0
All checks were successful
Run unit tests / rubocop (pull_request) Successful in 2m11s
Run unit tests / check-licenses (pull_request) Successful in 1m39s
Run unit tests / copyright_notice (pull_request) Successful in 1m38s
Run unit tests / unit_tests (pull_request) Successful in 5m57s
Run unit tests / build-static-assets (pull_request) Successful in 8m54s
2025-07-09 02:04:57 +00:00
5cb4d14343 Merge pull request 'Define a worker process and endpoint to send invitations PDF via email' (#293) from qr-doc-background-job into main
All checks were successful
Run unit tests / rubocop (push) Has been skipped
Run unit tests / check-licenses (push) Has been skipped
Run unit tests / copyright_notice (push) Has been skipped
Run unit tests / unit_tests (push) Successful in 2m30s
Run unit tests / build-static-assets (push) Successful in 8m43s
Reviewed-on: #293
2025-07-08 17:37:09 +00:00
3 changed files with 46 additions and 15 deletions

View File

@ -76,7 +76,7 @@ GEM
rails (>= 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
annotaterb (4.16.0)
annotaterb (4.17.0)
activerecord (>= 6.0.0)
activesupport (>= 6.0.0)
ast (2.4.3)
@ -291,7 +291,7 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.3.0)
rdoc (6.14.1)
rdoc (6.14.2)
erb
psych (>= 4.0.0)
react-rails (3.2.1)
@ -300,7 +300,7 @@ GEM
execjs
railties (>= 3.2)
tilt
redis (5.4.0)
redis (5.4.1)
redis-client (>= 0.22.0)
redis-client (0.23.2)
connection_pool
@ -347,7 +347,7 @@ GEM
rswag-ui (2.16.0)
actionpack (>= 5.2, < 8.1)
railties (>= 5.2, < 8.1)
rubocop (1.77.0)
rubocop (1.78.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
@ -384,7 +384,7 @@ GEM
securerandom (0.4.1)
shoulda-matchers (6.5.0)
activesupport (>= 5.2.0)
solid_queue (1.1.5)
solid_queue (1.2.0)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
@ -497,7 +497,7 @@ CHECKSUMS
activesupport (8.0.2) sha256=8565cddba31b900cdc17682fd66ecd020441e3eef320a9930285394e8c07a45e
acts_as_tenant (1.0.1) sha256=6944e4d64533337938a8817a6b4ff9b11189c9dcc0b1333bb89f3821a4c14c53
addressable (2.8.7) sha256=462986537cf3735ab5f3c0f557f14155d778f4b43ea4f485a9deb9c8f7c58232
annotaterb (4.16.0) sha256=3ed087a925b306036139e4191b38044390bcfc4561adece8f779f9d5ee87ca3c
annotaterb (4.17.0) sha256=f0338f8aaadd5c47fa3deaccb560a54abcdde29aca6f69f4b94726ea9256b4bd
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
babel-source (5.8.35) sha256=79ef222a9dcb867ac2efa3b0da35b4bcb15a4bfa67b6b2dcbf1e9a29104498d9
babel-transpiler (0.7.0) sha256=4c06f4ad9e8e1cabe94f99e11df2f140bb72aca9ba067dbb49dc14d9b98d1570
@ -598,9 +598,9 @@ CHECKSUMS
railties (8.0.2) sha256=0d7c3f40c49ba74980f1bac1d4bb153a9331c5ee8a9631d89c7bf79db82e5cf9
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
rake (13.3.0) sha256=96f5092d786ff412c62fde76f793cc0541bd84d2eb579caa529aa8a059934493
rdoc (6.14.1) sha256=905efa796cd296ef252af4fb31fe41c073dee894de6aad715821f335c632516b
rdoc (6.14.2) sha256=9fdd44df130f856ae70cc9a264dfd659b9b40de369b16581f4ab746e42439226
react-rails (3.2.1) sha256=2235db0b240517596b1cb3e26177ab5bc64d3a56579b0415ee242b1691f81f64
redis (5.4.0) sha256=798900d869418a9fc3977f916578375b45c38247a556b61d58cba6bb02f7d06b
redis (5.4.1) sha256=b5e675b57ad22b15c9bcc765d5ac26f60b675408af916d31527af9bd5a81faae
redis-client (0.23.2) sha256=e33bab6682c8155cfef95e6dd296936bb9c2981a89fb578ace27a076fa2836fa
regexp_parser (2.10.0) sha256=cb6f0ddde88772cd64bff1dbbf68df66d376043fe2e66a9ef77fcb1b0c548c61
reline (0.6.1) sha256=1afcc9d7cb1029cdbe780d72f2f09251ce46d3780050f3ec39c3ccc6b60675fb
@ -617,7 +617,7 @@ CHECKSUMS
rswag-api (2.16.0) sha256=b653f7bd92e98be18b01ab4525d88950d7b0960e293a99f856b9efcee3ae6074
rswag-specs (2.16.0) sha256=8ba26085c408b0bd2ed21dc8015c80f417c7d34c63720ab7133c2549b5bd2a91
rswag-ui (2.16.0) sha256=a1f49e927dceda92e6e6e7c1000f1e217ee66c565f69e28131dc98b33cd3a04f
rubocop (1.77.0) sha256=1f360b4575ef7a124be27b0dfffa227a2b2d9420d22d4fd8bf179d702bcc88c0
rubocop (1.78.0) sha256=8b74a6f912eb4fd3e6878851f7f7f45dcad8c7185c34250d4f952b0ee80d6bc0
rubocop-ast (1.45.1) sha256=94042e49adc17f187ba037b33f941ba7398fede77cdf4bffafba95190a473a3e
rubocop-factory_bot (2.27.1) sha256=9d744b5916778c1848e5fe6777cc69855bd96548853554ec239ba9961b8573fe
rubocop-rails (2.32.0) sha256=9fcc623c8722fe71e835e99c4a18b740b5b0d3fb69915d7f0777f00794b30490
@ -628,7 +628,7 @@ CHECKSUMS
rubyzip (2.3.2) sha256=3f57e3935dc2255c414484fbf8d673b4909d8a6a57007ed754dde39342d2373f
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
shoulda-matchers (6.5.0) sha256=ef6b572b2bed1ac4aba6ab2c5ff345a24b6d055a93a3d1c3bfc86d9d499e3f44
solid_queue (1.1.5) sha256=bae0c9d76310f4953ebc57466f2e8c78703a0fbf4b89d25756c23c88f9b6df9b
solid_queue (1.2.0) sha256=482ac5305cbe91ebf845627caec493fda8545bf22b18205df01afb80999e28de
sprockets (4.2.1) sha256=951b13dd2f2fcae840a7184722689a803e0ff9d2702d902bd844b196da773f97
sprockets-rails (3.5.2) sha256=a9e88e6ce9f8c912d349aa5401509165ec42326baf9e942a85de4b76dbc4119e
stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06

View File

@ -14,17 +14,18 @@ module Tables
attr_accessor :tables, :min_per_table, :max_per_table, :hierarchy
def initialize(min_per_table:, max_per_table:)
def initialize(min_per_table:, max_per_table:, hierarchy: AffinityGroupsHierarchy.new)
@min_per_table = min_per_table
@max_per_table = max_per_table
@hierarchy = AffinityGroupsHierarchy.new
@hierarchy = hierarchy
@tables = []
end
def random_distribution(people)
def random_distribution(people, random: Random.new)
min_tables = (people.count * 1.0 / @max_per_table).ceil
max_tables = (people.count * 1.0 / @min_per_table).ceil
@tables = people.in_groups(rand(min_tables..max_tables), false)
table_size = random.rand(min_tables..max_tables)
@tables = people.in_groups(table_size, false)
.map { |group| Table.new(group) }
.each { |table| table.min_per_table = @min_per_table }
.each { |table| table.max_per_table = @max_per_table }
@ -41,7 +42,8 @@ module Tables
end
def deep_dup
self.class.new(min_per_table: @min_per_table, max_per_table: @max_per_table).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

29
lib/tasks/vns.rake Normal file
View File

@ -0,0 +1,29 @@
# frozen_string_literal: true
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(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 }
Rails.logger.info "Best solution found with discomfort: #{solution.discomfort}"
end
end
end