Class: FeldtRuby::Optimize::EliteArchive
- Defined in:
- lib/feldtruby/optimize/elite_archive.rb
Overview
This keeps a record of the best/elite candidate solutions found during an optimization search. It keeps separate top lists per goal being optimized as well as for the aggregate quality value (fitness) itself. The top lists are all sorted to allow for fast checks and insertion.
Defined Under Namespace
Classes: GlobalTopList, GoalTopList
Constant Summary collapse
- DefaultParams =
{ :NumTopPerGoal => 10, :NumTopAggregate => 25 }
Instance Attribute Summary collapse
-
#best ⇒ Object
readonly
Returns the value of attribute best.
-
#objective ⇒ Object
readonly
Returns the value of attribute objective.
-
#top_per_goal ⇒ Object
readonly
Returns the value of attribute top_per_goal.
Instance Method Summary collapse
- #add(candidate) ⇒ Object
- #init_top_lists ⇒ Object
-
#initialize(objective, options = DefaultParams.clone) ⇒ EliteArchive
constructor
A new instance of EliteArchive.
Constructor Details
#initialize(objective, options = DefaultParams.clone) ⇒ EliteArchive
Returns a new instance of EliteArchive.
17 18 19 20 21 |
# File 'lib/feldtruby/optimize/elite_archive.rb', line 17 def initialize(objective, = DefaultParams.clone) @objective = objective = init_top_lists end |
Instance Attribute Details
#best ⇒ Object (readonly)
Returns the value of attribute best.
15 16 17 |
# File 'lib/feldtruby/optimize/elite_archive.rb', line 15 def best @best end |
#objective ⇒ Object (readonly)
Returns the value of attribute objective.
15 16 17 |
# File 'lib/feldtruby/optimize/elite_archive.rb', line 15 def objective @objective end |
#top_per_goal ⇒ Object (readonly)
Returns the value of attribute top_per_goal.
15 16 17 |
# File 'lib/feldtruby/optimize/elite_archive.rb', line 15 def top_per_goal @top_per_goal end |
Instance Method Details
#add(candidate) ⇒ Object
85 86 87 88 |
# File 'lib/feldtruby/optimize/elite_archive.rb', line 85 def add(candidate) @best.add candidate @top_per_goal.each {|tl| tl.add(candidate)} end |
#init_top_lists ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/feldtruby/optimize/elite_archive.rb', line 77 def init_top_lists @top_per_goal = Array.new @objective.num_goals.times do |i| @top_per_goal << GoalTopList.new([:NumTopPerGoal], @objective, i) end @best = GlobalTopList.new([:NumTopAggregate], @objective) end |