swap-candidates #26
@ -7,7 +7,7 @@ module Tables
|
|||||||
|
|
||||||
def each
|
def each
|
||||||
@initial_solution.tables.combination(2) do |table_a, table_b|
|
@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_solution = @initial_solution.dup
|
||||||
|
|
||||||
new_table_a = table_a.dup
|
new_table_a = table_a.dup
|
||||||
|
@ -5,20 +5,17 @@ module Tables
|
|||||||
|
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
super
|
super
|
||||||
reset
|
|
||||||
@id = SecureRandom.uuid
|
@id = SecureRandom.uuid
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset
|
|
||||||
original_discomfort = @discomfort
|
|
||||||
@discomfort = nil
|
|
||||||
original_discomfort
|
|
||||||
end
|
|
||||||
|
|
||||||
def discomfort
|
def discomfort
|
||||||
@discomfort ||= DiscomfortCalculator.new(self).calculate
|
@discomfort ||= DiscomfortCalculator.new(self).calculate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def swap_candidates
|
||||||
|
@swap_candidates ||= uniq { |person| person.affinity_group_list.first }
|
||||||
|
end
|
||||||
|
|
||||||
def dup
|
def dup
|
||||||
super.tap do |new_table|
|
super.tap do |new_table|
|
||||||
new_table.discomfort = nil
|
new_table.discomfort = nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user