Initial version of VNS algorithm #8
@ -46,6 +46,26 @@ module Tables
|
|||||||
it { expect(calculator.send(:cohesion_penalty)).to eq(Rational(3, 4)) }
|
it { expect(calculator.send(:cohesion_penalty)).to eq(Rational(3, 4)) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the table contains three guests' do
|
||||||
|
let(:table) do
|
||||||
|
[
|
||||||
|
create(:guest, affinity_group_list: ['family']),
|
||||||
|
create(:guest, affinity_group_list: ['friends']),
|
||||||
|
create(:guest, affinity_group_list: ['work'])
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(AffinityGroupsHierarchy.instance).to receive(:distance).with('family', 'friends').and_return(nil)
|
||||||
|
allow(AffinityGroupsHierarchy.instance).to receive(:distance).with('friends', 'work').and_return(1)
|
||||||
|
allow(AffinityGroupsHierarchy.instance).to receive(:distance).with('family', 'work').and_return(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns the sum of the penalties for each pair of guests' do
|
||||||
|
expect(calculator.send(:cohesion_penalty)).to eq(1 + Rational(1, 2) + Rational(2, 3))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user