1 | package net.bmahe.genetics4j.core.replacement; | |
2 | ||
3 | import java.util.List; | |
4 | import java.util.Objects; | |
5 | ||
6 | import org.apache.commons.lang3.Validate; | |
7 | ||
8 | import net.bmahe.genetics4j.core.Genotype; | |
9 | import net.bmahe.genetics4j.core.Population; | |
10 | import net.bmahe.genetics4j.core.selection.Selector; | |
11 | import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; | |
12 | import net.bmahe.genetics4j.core.spec.replacement.GenerationalReplacement; | |
13 | ||
14 | public class GenerationalReplacementImpl<T extends Comparable<T>> implements ReplacementStrategyImplementor<T> { | |
15 | ||
16 | private final GenerationalReplacement generationalReplacementSpec; | |
17 | private final Selector<T> offspringSelector; | |
18 | ||
19 | public GenerationalReplacementImpl(final GenerationalReplacement _elistismSpec, | |
20 | final Selector<T> _offspringSelector) { | |
21 | Objects.requireNonNull(_elistismSpec); | |
22 | ||
23 |
1
1. <init> : Removed assignment to member variable generationalReplacementSpec → NO_COVERAGE |
this.generationalReplacementSpec = _elistismSpec; |
24 |
1
1. <init> : Removed assignment to member variable offspringSelector → NO_COVERAGE |
this.offspringSelector = _offspringSelector; |
25 | } | |
26 | ||
27 | @Override | |
28 | public Population<T> select(final AbstractEAConfiguration<T> eaConfiguration, final long generation, | |
29 | final int numIndividuals, final List<Genotype> population, final List<T> populationScores, | |
30 | final List<Genotype> offsprings, final List<T> offspringScores) { | |
31 | Objects.requireNonNull(eaConfiguration); | |
32 | Validate.isTrue(generation >= 0); | |
33 | Validate.isTrue(numIndividuals > 0); | |
34 | Objects.requireNonNull(population); | |
35 | Objects.requireNonNull(populationScores); | |
36 | Validate.isTrue(population.size() == populationScores.size()); | |
37 | Objects.requireNonNull(offsprings); | |
38 | Objects.requireNonNull(offspringScores); | |
39 | Validate.isTrue(offsprings.size() == offspringScores.size()); | |
40 | ||
41 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::<init> → NO_COVERAGE |
final Population<T> selected = new Population<>(); |
42 | ||
43 | final Population<T> selectedOffspring = offspringSelector | |
44 |
1
1. select : removed call to net/bmahe/genetics4j/core/selection/Selector::select → NO_COVERAGE |
.select(eaConfiguration, generation, numIndividuals, offsprings, offspringScores); |
45 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::addAll → NO_COVERAGE |
selected.addAll(selectedOffspring); |
46 | ||
47 |
1
1. select : replaced return value with null for net/bmahe/genetics4j/core/replacement/GenerationalReplacementImpl::select → NO_COVERAGE |
return selected; |
48 | } | |
49 | } | |
Mutations | ||
23 |
1.1 |
|
24 |
1.1 |
|
41 |
1.1 |
|
44 |
1.1 |
|
45 |
1.1 |
|
47 |
1.1 |