Class: Spea2
- Inherits:
-
AlgorithmBase
- Object
- AlgorithmBase
- Spea2
- Includes:
- Breed, PhenotypicTruncation
- Defined in:
- ../algorithm/spea2.rb
Instance Attribute Summary (collapse)
-
- (Object) max_archive_size
Returns the value of attribute max_archive_size.
-
- (Object) shorten_archive_individual
Returns the value of attribute shorten_archive_individual.
Attributes included from PhenotypicTruncation
#duplicate_elimination, #shorten_individual
Attributes included from Breed
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) max_archive_size
Returns the value of attribute max_archive_size
37 38 39 |
# File '../algorithm/spea2.rb', line 37 def max_archive_size @max_archive_size end |
- (Object) shorten_archive_individual
Returns the value of attribute shorten_archive_individual
37 38 39 |
# File '../algorithm/spea2.rb', line 37 def shorten_archive_individual @shorten_archive_individual end |
Instance Method Details
- (Object) setup(config)
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File '../algorithm/spea2.rb', line 39 def setup config super @ranker = @selection.ranker @ranker.shorten_individual = @shorten_archive_individual @archive, @population = @store.load @archive = [] if @archive.nil? @population = [] if @population.nil? @report << "loaded #{@population.size} population individuals" @report << "creating #{@population_size - @population.size} population individuals" init_population( @population, @population_size ) @report << "loaded #{@archive.size} archive individuals" @report.next return @report end |
- (Object) step
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 |
# File '../algorithm/spea2.rb', line 64 def step @report.next @report << "--------- step #{@steps += 1}" combined = @population.clone combined.concat @archive @ranker.population = combined @archive = @ranker.environmental_selection @max_archive_size if @duplicate_elimination @cross, @injections, @mutate = 0, 0, 0 sizes = [] @population = [] while @population.size < @population_size @selection.population = @archive.clone new_populaton = breed_by_selector_no_report( @selection, @population_size ) @population.concat new_populaton @population = eliminate_duplicates @population sizes << @population.size end @report['eliminated_sizes'] << sizes @report['numof_crossovers'] << @cross @report['numof_injections'] << @injections @report['numof_mutations'] << @mutate @report['time_eval'] << @time_eval @report['numof_evaluations'] << @evaluator.jobs_processed if defined? @evaluator else @selection.population = @archive @population = breed_by_selector( @selection, @population_size ) end @report.report @archive return @report end |
- (Object) teardown
58 59 60 61 62 |
# File '../algorithm/spea2.rb', line 58 def teardown @report << "--------- finished:" @store.save [@archive, @population] return @report end |