class Doughnut::PopulationFactory

Public Class Methods

new(list_of_assets) click to toggle source
# File lib/doughnut/monte_carlo/population_factory.rb, line 5
def initialize(list_of_assets)
  @num_genomes = 10
  @list_of_assets = list_of_assets
end

Public Instance Methods

build_random_population() click to toggle source
# File lib/doughnut/monte_carlo/population_factory.rb, line 10
def build_random_population
  Array.new(@num_genomes, random_genome)
end

Private Instance Methods

gene_fractions() click to toggle source
# File lib/doughnut/monte_carlo/population_factory.rb, line 23
def gene_fractions
  fracs = Array.new(@list_of_assets.length, rand)
  s = fracs.sum
  fracs.map { |x| x/s }
end
random_genome() click to toggle source
# File lib/doughnut/monte_carlo/population_factory.rb, line 16
def random_genome
  output = []
  @list_of_assets.each_with_index do |asset, indx|
    output << asset.merge!({fraction: gene_fractions[indx]})
  end
end