Initial version of VNS algorithm #8

Merged
bustikiller merged 20 commits from vns into main 2024-08-01 18:27:42 +00:00
Showing only changes of commit c0aea23954 - Show all commits

View File

@ -100,20 +100,31 @@ module Tables
end end
end end
context 'when the table contains four guests of two split groups' do context 'when the table contains four guests of two evenly split groups' do
let(:table) do let(:table) do
[ [
create(:guest, affinity_group_list: ['family']), create_list(:guest, 2, affinity_group_list: ['family']),
create(:guest, affinity_group_list: ['family']), create_list(:guest, 2, affinity_group_list: ['friends'])
create(:guest, affinity_group_list: ['friends']), ].flatten
create(:guest, affinity_group_list: ['friends'])
]
end end
it 'returns the sum of the penalties for each pair of guests' do it 'returns the sum of the penalties for each pair of guests' do
expect(calculator.send(:cohesion_penalty)).to eq(4) expect(calculator.send(:cohesion_penalty)).to eq(4)
end end
end end
context 'when the table contains six guests of two unevenly split groups' do
let(:table) do
[
create_list(:guest, 2, affinity_group_list: ['family']),
create_list(:guest, 4, affinity_group_list: ['friends'])
].flatten
end
it 'returns the sum of the penalties for each pair of guests' do
expect(calculator.send(:cohesion_penalty)).to eq(8)
end
end
end end
end end
end end