Class: Evopop::PopulationConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/evopop.rb

Overview

Defines the configuration to be available to all of Evopop

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePopulationConfig

Returns a new instance of PopulationConfig.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/evopop.rb', line 27

def initialize
  @average_fitness = []
  @population_size = 500
  @max_generations = 100
  @initial_range_min = -100
  @initial_range_max = 100
  @mutation_range_min = -10
  @mutation_range_max = 10
  @mutation_num = (0.10 * @population_size).to_i
  @dna_len = 1
  @crossover_params = { ordinal: (@dna_len / 2) }

  @crossover_function = Evopop::Crossover.method(:one_point)
  @fitness_function = proc do |dna|
    Math.sin(dna[0])
  end
end

Instance Attribute Details

#average_fitnessObject

Returns the value of attribute average_fitness.



22
23
24
# File 'lib/evopop.rb', line 22

def average_fitness
  @average_fitness
end

#crossover_functionObject

Returns the value of attribute crossover_function.



22
23
24
# File 'lib/evopop.rb', line 22

def crossover_function
  @crossover_function
end

#crossover_paramsObject

Returns the value of attribute crossover_params.



22
23
24
# File 'lib/evopop.rb', line 22

def crossover_params
  @crossover_params
end

#dna_lenObject

Returns the value of attribute dna_len.



22
23
24
# File 'lib/evopop.rb', line 22

def dna_len
  @dna_len
end

#fitness_functionObject

Returns the value of attribute fitness_function.



22
23
24
# File 'lib/evopop.rb', line 22

def fitness_function
  @fitness_function
end

#initial_range_maxObject

Returns the value of attribute initial_range_max.



22
23
24
# File 'lib/evopop.rb', line 22

def initial_range_max
  @initial_range_max
end

#initial_range_minObject

Returns the value of attribute initial_range_min.



22
23
24
# File 'lib/evopop.rb', line 22

def initial_range_min
  @initial_range_min
end

#max_generationsObject

Returns the value of attribute max_generations.



22
23
24
# File 'lib/evopop.rb', line 22

def max_generations
  @max_generations
end

#mutation_numObject

Returns the value of attribute mutation_num.



22
23
24
# File 'lib/evopop.rb', line 22

def mutation_num
  @mutation_num
end

#mutation_range_maxObject

Returns the value of attribute mutation_range_max.



22
23
24
# File 'lib/evopop.rb', line 22

def mutation_range_max
  @mutation_range_max
end

#mutation_range_minObject

Returns the value of attribute mutation_range_min.



22
23
24
# File 'lib/evopop.rb', line 22

def mutation_range_min
  @mutation_range_min
end

#population_sizeObject

Returns the value of attribute population_size.



22
23
24
# File 'lib/evopop.rb', line 22

def population_size
  @population_size
end