Class: EvoSynth::Evolvers::PopulationHillclimber
- Inherits:
-
Object
- Object
- EvoSynth::Evolvers::PopulationHillclimber
show all
- Includes:
- Evolver
- Defined in:
- lib/evosynth/evolvers/basic/population_hillclimber.rb
Overview
POPULATIONSBASIERTES-BINÄRES-HILLCLIMBING (Weicker Page 65)
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 PopulationHillclimber.
33
34
35
36
37
38
|
# File 'lib/evosynth/evolvers/basic/population_hillclimber.rb', line 33
def initialize(profile)
init_profile :mutation, :population, :evaluator
use_profile profile
@population.each { |individual| @evaluator.calculate_and_set_initial_fitness(individual) }
end
|
Instance Method Details
#best_solution ⇒ Object
44
45
46
|
# File 'lib/evosynth/evolvers/basic/population_hillclimber.rb', line 44
def best_solution
@population.best
end
|
#mutate(individual) ⇒ Object
60
61
62
63
64
|
# File 'lib/evosynth/evolvers/basic/population_hillclimber.rb', line 60
def mutate(individual)
child = @mutation.mutate(individual)
@evaluator.calculate_and_set_fitness(child)
child > individual ? child : individual
end
|
#next_generation ⇒ Object
56
57
58
|
# File 'lib/evosynth/evolvers/basic/population_hillclimber.rb', line 56
def next_generation
@population.map! { |individual| mutate(individual) }
end
|
#return_result ⇒ Object
52
53
54
|
# File 'lib/evosynth/evolvers/basic/population_hillclimber.rb', line 52
def return_result
@population
end
|
#to_s ⇒ Object
40
41
42
|
# File 'lib/evosynth/evolvers/basic/population_hillclimber.rb', line 40
def to_s
"population based hillclimber <mutation: #{@mutation}>"
end
|
#worst_solution ⇒ Object
48
49
50
|
# File 'lib/evosynth/evolvers/basic/population_hillclimber.rb', line 48
def worst_solution
@population.worst
end
|