Class: AlpsStrict
- Inherits:
-
AlgorithmBase
- Object
- AlgorithmBase
- AlpsStrict
- Includes:
- PhenotypicTruncation
- Defined in:
- ../algorithm/alps_strict.rb
Instance Attribute Summary (collapse)
-
- (Object) age_gap
Returns the value of attribute age_gap.
-
- (Object) aging_scheme
Returns the value of attribute aging_scheme.
-
- (Object) elite_size
Returns the value of attribute elite_size.
-
- (Object) join_size
Returns the value of attribute join_size.
-
- (Object) layer_diagnostic
Returns the value of attribute layer_diagnostic.
-
- (Object) max_layers
Returns the value of attribute max_layers.
Attributes included from PhenotypicTruncation
#duplicate_elimination, #shorten_individual
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
Instance Attribute Details
- (Object) age_gap
Returns the value of attribute age_gap
10 11 12 |
# File '../algorithm/alps_strict.rb', line 10 def age_gap @age_gap end |
- (Object) aging_scheme
Returns the value of attribute aging_scheme
10 11 12 |
# File '../algorithm/alps_strict.rb', line 10 def aging_scheme @aging_scheme end |
- (Object) elite_size
Returns the value of attribute elite_size
10 11 12 |
# File '../algorithm/alps_strict.rb', line 10 def elite_size @elite_size end |
- (Object) join_size
Returns the value of attribute join_size
10 11 12 |
# File '../algorithm/alps_strict.rb', line 10 def join_size @join_size end |
- (Object) layer_diagnostic
Returns the value of attribute layer_diagnostic
10 11 12 |
# File '../algorithm/alps_strict.rb', line 10 def layer_diagnostic @layer_diagnostic end |
- (Object) max_layers
Returns the value of attribute max_layers
10 11 12 |
# File '../algorithm/alps_strict.rb', line 10 def max_layers @max_layers end |
Instance Method Details
- (Object) setup(config)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File '../algorithm/alps_strict.rb', line 12 def setup config super @layer_size = @population_size.divmod( @max_layers ).first AlpsIndividual.age_gap @age_gap AlpsIndividual.aging_scheme @aging_scheme AlpsIndividual.layers @max_layers @report['age_limits'] << AlpsIndividual.age_limits.inspect @report['target_layer_size'] << @layer_size @layers = [] @dominance = Dominance.new @population = [] @parents_stats = [] @report.next return @report end |
- (Object) step
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File '../algorithm/alps_strict.rb', line 35 def step @report << "--------- step #{@steps}" if @steps.divmod(@age_gap).last == 0 @report << "--------- opening a new layer, layer[0] unshift" @layers.unshift init_population( [], @layer_size ) @steps += 1 @report.next return @report end # reporting @population = @layers.flatten @report.report @population # main breed new_layers = [] parents_counts = [] @layers.each_with_index do |unsorted, index| parents = index > 0 ? unsorted+@layers[index-1] : unsorted new_layers << breed( parents ) parents_counts << parents.size end @report['0_parents_sizes'] << parents_counts.inspect @parents_stats.concat parents_counts min, max, avg, n = Util.statistics @parents_stats @report['parents_stats'] << "min: #{min} max: #{max} avg: #{avg} n: #{n}" @report['1_new_layers_sizes'] << ( new_layers.map { |layer| layer.size } ).inspect # resort according layer index @layers = [] new_layers.flatten.each do |individual| index = individual.layer @layers << [] while index >= @layers.size @layers[index] << individual end @report['2_layers_separated_sizes'] << ( @layers.map { |layer| layer.size } ).inspect # join almost-empty layers joinings = [] layers = @layers @layers = [] layers.each do |layer| if not @layers.empty? and @layers.last.size < @join_size joinings << "#{layer.size} -> #{@layers.last.size}" @layers.last.concat layer else @layers << layer end end @report['3_joinings'] << joinings.inspect # layer diagnostic @report['4_layer_sizes'] << (@layers.map { |layer| layer.size }).inspect @layers.each_with_index do |layer,index| layer.first.objective_symbols.each do |objective| values = layer.map { |individual| individual.send(objective) } min, max, avg, n = Util.statistics values @report["layer_#{index}_#{objective}"] << "min: #{min} max: #{max} avg: #{avg} n: #{n}" end end if @layer_diagnostic @report['numof_evaluations'] << @evaluator.jobs_processed if defined? @evaluator @steps += 1 @report.next return @report end |