Class: EvoSynth::Evolvers::RoundRobinCoevolutionary

Inherits:
Object
  • Object
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

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) ⇒ RoundRobinCoevolutionary

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

#subevolversObject (readonly)

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_solutionObject



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_generationObject



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_resultObject



63
64
65
# File 'lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb', line 63

def return_result
  @populations
end

#to_sObject



47
48
49
# File 'lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb', line 47

def to_s
  "cooperative coevolutionary algorithm"
end

#worst_solutionObject



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