Class: Generational

Inherits:
AlgorithmBase show all
Includes:
Breed, Elitism, PhenotypicTruncation
Defined in:
../algorithm/generational.rb

Instance Attribute Summary

Attributes included from PhenotypicTruncation

#duplicate_elimination, #shorten_individual

Attributes included from Breed

#inject

Attributes included from Elitism

#elite_size

Attributes inherited from AlgorithmBase

#init, #population_size, #probabilities, #termination

Instance Method Summary (collapse)

Methods included from PhenotypicTruncation

#eliminate_duplicates, #phenotypic_truncation

Methods inherited from AlgorithmBase

#finished?, #teardown

Instance Method Details

- (Object) setup(config)



13
14
15
16
17
18
19
# File '../algorithm/generational.rb', line 13

def setup config
  super
  @population = load_or_init( @store, @population_size )   
  init_elitism @population_size
  @report.next    
  return @report    
end

- (Object) step



21
22
23
24
25
26
27
28
29
30
31
32
33
# File '../algorithm/generational.rb', line 21

def step
  @report.next    
  @report << "--------- step #{@steps += 1}" 
  @report.report @population 

  parent_population = @selection.select( @population_size - @elite_size, @population )
  new_population = breed_population( parent_population, @population_size - @elite_size )
  new_population.concat elite( @population )
  new_population = eliminate_duplicates new_population if @duplicate_elimination
  @population = new_population

  return @report
end