Class: Evopop::PopulationConfig
- Inherits:
-
Object
- Object
- Evopop::PopulationConfig
- Defined in:
- lib/evopop.rb
Overview
Defines the configuration to be available to all of Evopop
Instance Attribute Summary collapse
-
#average_fitness ⇒ Object
Returns the value of attribute average_fitness.
-
#crossover_function ⇒ Object
Returns the value of attribute crossover_function.
-
#crossover_params ⇒ Object
Returns the value of attribute crossover_params.
-
#dna_len ⇒ Object
Returns the value of attribute dna_len.
-
#fitness_function ⇒ Object
Returns the value of attribute fitness_function.
-
#initial_range_max ⇒ Object
Returns the value of attribute initial_range_max.
-
#initial_range_min ⇒ Object
Returns the value of attribute initial_range_min.
-
#max_generations ⇒ Object
Returns the value of attribute max_generations.
-
#mutation_num ⇒ Object
Returns the value of attribute mutation_num.
-
#mutation_range_max ⇒ Object
Returns the value of attribute mutation_range_max.
-
#mutation_range_min ⇒ Object
Returns the value of attribute mutation_range_min.
-
#population_size ⇒ Object
Returns the value of attribute population_size.
Instance Method Summary collapse
-
#initialize ⇒ PopulationConfig
constructor
A new instance of PopulationConfig.
Constructor Details
#initialize ⇒ PopulationConfig
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_fitness ⇒ Object
Returns the value of attribute average_fitness.
22 23 24 |
# File 'lib/evopop.rb', line 22 def average_fitness @average_fitness end |
#crossover_function ⇒ Object
Returns the value of attribute crossover_function.
22 23 24 |
# File 'lib/evopop.rb', line 22 def crossover_function @crossover_function end |
#crossover_params ⇒ Object
Returns the value of attribute crossover_params.
22 23 24 |
# File 'lib/evopop.rb', line 22 def crossover_params @crossover_params end |
#dna_len ⇒ Object
Returns the value of attribute dna_len.
22 23 24 |
# File 'lib/evopop.rb', line 22 def dna_len @dna_len end |
#fitness_function ⇒ Object
Returns the value of attribute fitness_function.
22 23 24 |
# File 'lib/evopop.rb', line 22 def fitness_function @fitness_function end |
#initial_range_max ⇒ Object
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_min ⇒ Object
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_generations ⇒ Object
Returns the value of attribute max_generations.
22 23 24 |
# File 'lib/evopop.rb', line 22 def max_generations @max_generations end |
#mutation_num ⇒ Object
Returns the value of attribute mutation_num.
22 23 24 |
# File 'lib/evopop.rb', line 22 def mutation_num @mutation_num end |
#mutation_range_max ⇒ Object
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_min ⇒ Object
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_size ⇒ Object
Returns the value of attribute population_size.
22 23 24 |
# File 'lib/evopop.rb', line 22 def population_size @population_size end |