Class: FeldtRuby::Optimize::EliteArchive::GoalTopList

Inherits:
GlobalTopList show all
Defined in:
lib/feldtruby/optimize/elite_archive.rb

Instance Method Summary collapse

Methods inherited from GlobalTopList

#[], #add, #inspect, #length

Constructor Details

#initialize(maxSize, objective, goalIndex) ⇒ GoalTopList

Returns a new instance of GoalTopList.



62
63
64
65
# File 'lib/feldtruby/optimize/elite_archive.rb', line 62

def initialize(maxSize, objective, goalIndex)
  super(maxSize, objective)
  @index = goalIndex
end

Instance Method Details

#is_better_than?(candidate1, candidate2) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/feldtruby/optimize/elite_archive.rb', line 66

def is_better_than?(candidate1, candidate2)
  @objective.is_better_than_for_goal?(@index, candidate1, candidate2)
end

#sort_top_listObject



69
70
71
72
73
74
# File 'lib/feldtruby/optimize/elite_archive.rb', line 69

def sort_top_list
  @top_list.sort_by {|c| 
    qv = @objective.quality_of(c)
    qv.sub_quality(@index, true) # We want the sub quality value posed as a minimization goal regardless of whether it is a min or max goal
  }
end