class Algorithms::Greedy::Engine
Public Class Methods
new(solution)
click to toggle source
# File lib/algorithms/greedy.rb, line 16 def initialize(solution) @initial_solution = solution @solutions_history = [@initial_solution] end
Public Instance Methods
best_solution()
click to toggle source
# File lib/algorithms/greedy.rb, line 27 def best_solution @solutions_history[-1] end
run(iterations)
click to toggle source
# File lib/algorithms/greedy.rb, line 21 def run(iterations) iterations.times do @solutions_history << @solutions_history[-1].next_solutions.max_by { |solution| solution.score } end end