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 3971fab196 - Show all commits

View File

@ -12,13 +12,13 @@ module Tables
private
def cohesion_penalty
table.map { |guest| guest.affinity_group_list.first }.combination(2).sum do |a, b|
table.map { |guest| guest.affinity_group_list.first }.tally.to_a.combination(2).sum do |(a, count_a), (b, count_b)|
distance = AffinityGroupsHierarchy.instance.distance(a, b)
next 1 if distance.nil?
next count_a * count_b if distance.nil?
next 0 if distance.zero?
Rational(distance, distance + 1)
count_a * count_b * Rational(distance, distance + 1)
end
end
end