Class: EvoSynth::Evolvers::Hillclimber
- Inherits:
-
Object
- Object
- EvoSynth::Evolvers::Hillclimber
show all
- Includes:
- Evolver
- Defined in:
- lib/evosynth/evolvers/basic/hillclimber.rb
Overview
BINÄRES-HILLCLIMBING (Weicker Page 49)
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
#initialize(profile) ⇒ Hillclimber
Returns a new instance of Hillclimber.
33
34
35
36
37
38
|
# File 'lib/evosynth/evolvers/basic/hillclimber.rb', line 33
def initialize(profile)
init_profile :individual, :mutation, :evaluator
use_profile profile
@evaluator.calculate_and_set_initial_fitness(@individual)
end
|
Instance Method Details
#best_solution ⇒ Object
44
45
46
|
# File 'lib/evosynth/evolvers/basic/hillclimber.rb', line 44
def best_solution
@individual
end
|
#next_generation ⇒ Object
56
57
58
59
60
|
# File 'lib/evosynth/evolvers/basic/hillclimber.rb', line 56
def next_generation
child = @mutation.mutate(@individual)
@evaluator.calculate_and_set_fitness(child)
@individual = child if child > @individual
end
|
#return_result ⇒ Object
52
53
54
|
# File 'lib/evosynth/evolvers/basic/hillclimber.rb', line 52
def return_result
@individual
end
|
#to_s ⇒ Object
40
41
42
|
# File 'lib/evosynth/evolvers/basic/hillclimber.rb', line 40
def to_s
"hillclimber <mutation: #{@mutation}, individual: #{@individual}>"
end
|
#worst_solution ⇒ Object
48
49
50
|
# File 'lib/evosynth/evolvers/basic/hillclimber.rb', line 48
def worst_solution
@individual
end
|