Class: FeldtRuby::Optimize::Archive::GoalTopList
- Inherits:
-
GlobalTopList
- Object
- GlobalTopList
- FeldtRuby::Optimize::Archive::GoalTopList
- Defined in:
- lib/feldtruby/optimize/archive.rb
Instance Method Summary collapse
-
#data_to_json_hash ⇒ Object
We add additional data about which goal/objective we are a top list for.
-
#initialize(maxSize, objective, goalIndex) ⇒ GoalTopList
constructor
A new instance of GoalTopList.
- #is_better_than?(candidate1, candidate2) ⇒ Boolean
- #sort_top_list ⇒ Object
Methods inherited from GlobalTopList
#[], #add, #delete_candidates, #each, #inspect, #length, #to_json
Constructor Details
#initialize(maxSize, objective, goalIndex) ⇒ GoalTopList
Returns a new instance of GoalTopList.
224 225 226 227 |
# File 'lib/feldtruby/optimize/archive.rb', line 224 def initialize(maxSize, objective, goalIndex) super(maxSize, objective) @index = goalIndex end |
Instance Method Details
#data_to_json_hash ⇒ Object
We add additional data about which goal/objective we are a top list for.
239 240 241 242 243 244 |
# File 'lib/feldtruby/optimize/archive.rb', line 239 def data_to_json_hash h = super() h['objective_index'] = @index h['objective_name'] = @objective.goal_methods[@index] h end |
#is_better_than?(candidate1, candidate2) ⇒ Boolean
228 229 230 |
# File 'lib/feldtruby/optimize/archive.rb', line 228 def is_better_than?(candidate1, candidate2) @objective.is_better_than_for_goal?(@index, candidate1, candidate2) end |
#sort_top_list ⇒ Object
231 232 233 234 235 236 |
# File 'lib/feldtruby/optimize/archive.rb', line 231 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 |