Class: EvoSynth::Evolvers::SelfAdaptiveES
- Inherits:
-
Object
- Object
- EvoSynth::Evolvers::SelfAdaptiveES
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
#generations_computed
Instance Method Summary
collapse
#init_profile, #use_profile
#run_until, #run_until_fitness_reached, #run_until_generations_reached
Constructor Details
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_solution ⇒ Object
55
56
57
|
# File 'lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb', line 55
def best_solution
@population.best
end
|
#next_generation ⇒ Object
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_result ⇒ Object
63
64
65
|
# File 'lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb', line 63
def return_result
@population
end
|
#to_s ⇒ Object
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_solution ⇒ Object
59
60
61
|
# File 'lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb', line 59
def worst_solution
@population.worst
end
|