Reduce the swap candidates per table to one per group
This commit is contained in:
parent
5f50c1fe11
commit
093970b2af
@ -7,7 +7,7 @@ module Tables
|
||||
|
||||
def each
|
||||
@initial_solution.tables.combination(2) do |table_a, table_b|
|
||||
table_a.product(table_b).each do |(person_a, person_b)|
|
||||
table_a.swap_candidates.product(table_b.swap_candidates).each do |(person_a, person_b)|
|
||||
new_solution = @initial_solution.dup
|
||||
|
||||
new_table_a = table_a.dup
|
||||
|
@ -5,20 +5,17 @@ module Tables
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
reset
|
||||
@id = SecureRandom.uuid
|
||||
end
|
||||
|
||||
def reset
|
||||
original_discomfort = @discomfort
|
||||
@discomfort = nil
|
||||
original_discomfort
|
||||
end
|
||||
|
||||
def discomfort
|
||||
@discomfort ||= DiscomfortCalculator.new(self).calculate
|
||||
end
|
||||
|
||||
def swap_candidates
|
||||
@swap_candidates ||= uniq { |person| person.affinity_group_list.first }
|
||||
end
|
||||
|
||||
def dup
|
||||
super.tap do |new_table|
|
||||
new_table.discomfort = nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user