Class: EvoSynth::Evolvers::SelfAdaptiveES

Inherits:
Object
  • Object
show all
Includes:
Evolver
Defined in:
lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb

Overview

ES-SELBSTADAPTIV (Weicker Page 135)

Constant Summary collapse

DEFAULT_CHILD_FACTOR =
5
DEFAULT_MUTATION =
EvoSynth::Mutations::SelfAdaptiveGaussMutation.new
DEFAULT_PARENT_SELECTION =
EvoSynth::Selections::RandomSelection.new
DEFAULT_ENV_SELECTION =
EvoSynth::Selections::SelectBest.new

Instance Attribute Summary

Attributes included from RunnableEvolver

#generations_computed

Instance Method Summary collapse

Methods included from ProfileUsingEvolver

#init_profile, #use_profile

Methods included from RunnableEvolver

#run_until, #run_until_fitness_reached, #run_until_generations_reached

Constructor Details

#initialize(profile) ⇒ SelfAdaptiveES

Returns a new instance of SelfAdaptiveES.


38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb', line 38

def initialize(profile)
  init_profile :population,
      :evaluator,
      :child_factor      => DEFAULT_CHILD_FACTOR,
      :mutation        => DEFAULT_MUTATION,
      :enviromental_selection => DEFAULT_ENV_SELECTION,
      :parent_selection    => DEFAULT_PARENT_SELECTION

  use_profile profile

  @population.each { |individual| @evaluator.calculate_and_set_initial_fitness(individual) }
end

Instance Method Details

#best_solutionObject


55
56
57
# File 'lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb', line 55

def best_solution
  @population.best
end

#next_generationObject


67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb', line 67

def next_generation
  child_population = EvoSynth::Population.new

  (@child_factor * @population.size).times do
    parent = @parent_selection.select(@population, 1).first
    child = @mutation.mutate(parent)
    @evaluator.calculate_and_set_fitness(child)
    child_population << child
  end

  @population = @enviromental_selection.select(child_population, @population.size)
end

#return_resultObject


63
64
65
# File 'lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb', line 63

def return_result
  @population
end

#to_sObject


51
52
53
# File 'lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb', line 51

def to_s
  "selfadaptive ES <mutation: #{@mutation}, parent selection: #{@parent_selection}, parent selection: #{@parent_selection}, enviromental selection: #{@enviromental_selection}>"
end

#worst_solutionObject


59
60
61
# File 'lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb', line 59

def worst_solution
  @population.worst
end