Class: FeldtRuby::Optimize::RadiusLimitedPopulationSampler
- Inherits:
-
PopulationSampler
- Object
- PopulationSampler
- FeldtRuby::Optimize::RadiusLimitedPopulationSampler
- Defined in:
- lib/feldtruby/optimize/optimizer.rb
Overview
This implements a “trivial geography” similar to Spector and Kline (2006) by first sampling an individual randomly and then selecting additional individuals for the same tournament within a certain deme of limited size for the sub-sequent individuals in the population. The version we implement here is from:
I. Harvey, "The Microbial Genetic Algorithm", in Advances in Artificial Life
Darwin Meets von Neumann, Springer, 2011.
Instance Method Summary collapse
-
#initialize(optimizer, options = FeldtRuby::Optimize::DefaultOptimizationOptions) ⇒ RadiusLimitedPopulationSampler
constructor
A new instance of RadiusLimitedPopulationSampler.
- #sample_population_indices_without_replacement(numSamples) ⇒ Object
Methods inherited from PopulationSampler
#initialize_all_indices, #sample_indices_without_replacement
Constructor Details
#initialize(optimizer, options = FeldtRuby::Optimize::DefaultOptimizationOptions) ⇒ RadiusLimitedPopulationSampler
Returns a new instance of RadiusLimitedPopulationSampler.
156 157 158 159 |
# File 'lib/feldtruby/optimize/optimizer.rb', line 156 def initialize(optimizer, = FeldtRuby::Optimize::DefaultOptimizationOptions) super @radius = [:samplerRadius] end |
Instance Method Details
#sample_population_indices_without_replacement(numSamples) ⇒ Object
161 162 163 164 165 166 167 168 |
# File 'lib/feldtruby/optimize/optimizer.rb', line 161 def sample_population_indices_without_replacement(numSamples) i = rand(@population_size) indices = (i..(i+@radius)).to_a if (i+@radius) >= @population_size indices.map! {|i| i % @population_size} end sample_indices_without_replacement numSamples, indices end |