Class: SteadyState
- Inherits:
-
AlgorithmBase
show all
- Includes:
- Breed
- Defined in:
- ../algorithm/steady_state.rb
Instance Attribute Summary
Attributes included from Breed
#inject
#init, #population_size, #probabilities, #termination
Instance Method Summary
(collapse)
#finished?, #teardown
Instance Method Details
- (Object) setup(config)
9
10
11
12
13
14
15
16
17
18
19
20
|
# File '../algorithm/steady_state.rb', line 9
def setup config
super
@replacement = @cfg['replacement_rank'].nil? ?
@cfg.factory('replacement') :
@cfg.factory('replacement', @cfg.factory('replacement_rank') )
@population = load_or_init( @store, @population_size )
@report.next
return @report
end
|
- (Object) step
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File '../algorithm/steady_state.rb', line 22
def step
@report.next
@report << "--------- step #{@steps += 1}"
@report.report @population
@cross, @injections, @mutate = 0, 0, 0
@population_size.times do
@selection.population = @population
individual = breed_individual @selection
bad = @replacement.select_one @population
@population.delete bad
@population << individual
end
@report['numof_crossovers'] << @cross
@report['numof_injections'] << @injections
@report['numof_mutations'] << @mutate
return @report
end
|