class StableMatching::Roommate::PhaseIRunner
Public Class Methods
new(preference_table, opts = {})
click to toggle source
# File lib/stable-matching/roommate/phase_i_runner.rb, line 84 def initialize(preference_table, opts = {}) @preference_table = preference_table @logger = opts.fetch(:logger) end
Public Instance Methods
run()
click to toggle source
# File lib/stable-matching/roommate/phase_i_runner.rb, line 89 def run while @preference_table.unmatched.any? ensure_table_is_stable! member = @preference_table.unmatched.first top_choice = member.first_preference simulate_proposal(member, top_choice) end # Check once more since final iteration may have left the table unstable ensure_table_is_stable! end
Private Instance Methods
ensure_table_is_stable!()
click to toggle source
# File lib/stable-matching/roommate/phase_i_runner.rb, line 105 def ensure_table_is_stable! return true if @preference_table.stable? raise StableMatching::NoStableSolutionError, "No stable match found!" end