module Tables class DiscomfortCalculator private attr_reader :table def initialize(table) @table = table end def calculate cohesion_penalty end private def cohesion_penalty table.map { |guest| guest.affinity_group_list.first }.combination(2).sum do |a, b| distance = AffinityGroupsHierarchy.instance.distance(a, b) next 1 if distance.nil? next 0 if distance.zero? Rational(distance, distance + 1) end end end end