Class: EvoSynth::Evolvers::RoundRobinCoevolutionary
- Inherits:
-
Object
- Object
- EvoSynth::Evolvers::RoundRobinCoevolutionary
show all
- Includes:
- Evolver
- Defined in:
- lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb
Overview
based on CCGA-1/2 (Mitchell A. Potter and Kenneth A. De Jong)
Constant Summary
collapse
- DEFAULT_SUBEVOLVERS_CREATOR =
->(profile) { evolver = EvoSynth::Evolvers::GeneticAlgorithm.new(profile);
EvoSynth::Evolvers.add_weak_elistism(evolver); evolver }
Instance Attribute Summary collapse
#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 RoundRobinCoevolutionary.
38
39
40
41
42
43
44
45
|
# File 'lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb', line 38
def initialize(profile)
init_profile :populations,
:subevolvers_creator => DEFAULT_SUBEVOLVERS_CREATOR
use_profile profile
initialize_sub_evolvers(profile)
@next_index = 0
end
|
Instance Attribute Details
#subevolvers ⇒ Object
Returns the value of attribute subevolvers.
33
34
35
|
# File 'lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb', line 33
def subevolvers
@subevolvers
end
|
Instance Method Details
#best_solution ⇒ Object
51
52
53
54
55
|
# File 'lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb', line 51
def best_solution
best = []
@populations.each { |pop| best << pop.best }
best
end
|
#next_generation ⇒ Object
67
68
69
70
|
# File 'lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb', line 67
def next_generation
@subevolvers[@next_index].next_generation
@next_index = (@next_index + 1) % @populations.size
end
|
#return_result ⇒ Object
63
64
65
|
# File 'lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb', line 63
def return_result
@populations
end
|
#to_s ⇒ Object
47
48
49
|
# File 'lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb', line 47
def to_s
"cooperative coevolutionary algorithm"
end
|
#worst_solution ⇒ Object
57
58
59
60
61
|
# File 'lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb', line 57
def worst_solution
worst = []
@populations.each { |pop| worst << pop.worst }
worst
end
|