1 | package net.bmahe.genetics4j.moo.spea2.replacement; | |
2 | ||
3 | import java.util.ArrayList; | |
4 | import java.util.Collections; | |
5 | import java.util.Comparator; | |
6 | import java.util.HashMap; | |
7 | import java.util.List; | |
8 | import java.util.Map; | |
9 | import java.util.Map.Entry; | |
10 | import java.util.Set; | |
11 | import java.util.TreeSet; | |
12 | import java.util.function.BiFunction; | |
13 | import java.util.stream.Collectors; | |
14 | import java.util.stream.IntStream; | |
15 | ||
16 | import org.apache.commons.lang3.Validate; | |
17 | import org.apache.commons.lang3.time.DurationFormatUtils; | |
18 | import org.apache.commons.lang3.tuple.Pair; | |
19 | import org.apache.logging.log4j.LogManager; | |
20 | import org.apache.logging.log4j.Logger; | |
21 | ||
22 | import net.bmahe.genetics4j.core.Genotype; | |
23 | import net.bmahe.genetics4j.core.Population; | |
24 | import net.bmahe.genetics4j.core.replacement.ReplacementStrategyImplementor; | |
25 | import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; | |
26 | import net.bmahe.genetics4j.moo.spea2.spec.replacement.SPEA2Replacement; | |
27 | ||
28 | public class SPEA2ReplacementStrategyImplementor<T extends Comparable<T>> implements ReplacementStrategyImplementor<T> { | |
29 | final static public Logger logger = LogManager.getLogger(SPEA2ReplacementStrategyImplementor.class); | |
30 | ||
31 | private final SPEA2Replacement<T> spea2Replacement; | |
32 | ||
33 | public SPEA2ReplacementStrategyImplementor(final SPEA2Replacement<T> _spea2Replacement) { | |
34 |
1
1. <init> : Removed assignment to member variable spea2Replacement → NO_COVERAGE |
this.spea2Replacement = _spea2Replacement; |
35 | } | |
36 | ||
37 | protected double[] computeStrength(final Comparator<T> dominance, final Population<T> population) { | |
38 | Validate.notNull(dominance); | |
39 | Validate.notNull(population); | |
40 | Validate.isTrue(population.size() > 0); | |
41 | ||
42 |
1
1. computeStrength : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE |
final double[] strengths = new double[population.size()]; |
43 |
6
1. computeStrength : Substituted 0 with 1 → NO_COVERAGE 2. computeStrength : negated conditional → NO_COVERAGE 3. computeStrength : changed conditional boundary → NO_COVERAGE 4. computeStrength : removed conditional - replaced comparison check with true → NO_COVERAGE 5. computeStrength : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 6. computeStrength : removed conditional - replaced comparison check with false → NO_COVERAGE |
for (int i = 0; i < population.size(); i++) { |
44 |
1
1. computeStrength : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE |
final T fitness = population.getFitness(i); |
45 | ||
46 |
2
1. computeStrength : replaced call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::strength with argument → NO_COVERAGE 2. computeStrength : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::strength → NO_COVERAGE |
strengths[i] = SPEA2Utils.strength(dominance, i, fitness, population); |
47 | } | |
48 | ||
49 |
1
1. computeStrength : replaced return value with null for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeStrength → NO_COVERAGE |
return strengths; |
50 | } | |
51 | ||
52 | protected double[][] computeObjectiveDistances(final BiFunction<T, T, Double> distance, | |
53 | final Population<T> population) { | |
54 | Validate.notNull(distance); | |
55 | Validate.notNull(population); | |
56 | Validate.isTrue(population.size() > 0); | |
57 | ||
58 |
2
1. computeObjectiveDistances : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 2. computeObjectiveDistances : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE |
final double[][] distanceObjectives = new double[population.size()][population.size()]; |
59 | ||
60 |
6
1. computeObjectiveDistances : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 2. computeObjectiveDistances : negated conditional → NO_COVERAGE 3. computeObjectiveDistances : removed conditional - replaced comparison check with false → NO_COVERAGE 4. computeObjectiveDistances : changed conditional boundary → NO_COVERAGE 5. computeObjectiveDistances : removed conditional - replaced comparison check with true → NO_COVERAGE 6. computeObjectiveDistances : Substituted 0 with 1 → NO_COVERAGE |
for (int i = 0; i < population.size(); i++) { |
61 |
5
1. computeObjectiveDistances : changed conditional boundary → NO_COVERAGE 2. computeObjectiveDistances : removed conditional - replaced comparison check with true → NO_COVERAGE 3. computeObjectiveDistances : removed conditional - replaced comparison check with false → NO_COVERAGE 4. computeObjectiveDistances : Substituted 0 with 1 → NO_COVERAGE 5. computeObjectiveDistances : negated conditional → NO_COVERAGE |
for (int j = 0; j < i; j++) { |
62 |
4
1. computeObjectiveDistances : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE 2. computeObjectiveDistances : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE 3. computeObjectiveDistances : replaced call to java/util/function/BiFunction::apply with argument → NO_COVERAGE 4. computeObjectiveDistances : removed call to java/util/function/BiFunction::apply → NO_COVERAGE |
final Double distanceMeasure = distance.apply(population.getFitness(i), population.getFitness(j)); |
63 |
1
1. computeObjectiveDistances : removed call to java/lang/Double::doubleValue → NO_COVERAGE |
distanceObjectives[i][j] = distanceMeasure; |
64 |
1
1. computeObjectiveDistances : removed call to java/lang/Double::doubleValue → NO_COVERAGE |
distanceObjectives[j][i] = distanceMeasure; |
65 | } | |
66 | ||
67 |
1
1. computeObjectiveDistances : Substituted 0.0 with 1.0 → NO_COVERAGE |
distanceObjectives[i][i] = 0.0; |
68 | } | |
69 |
1
1. computeObjectiveDistances : replaced return value with null for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeObjectiveDistances → NO_COVERAGE |
return distanceObjectives; |
70 | } | |
71 | ||
72 | protected double[] computeRawFitness(final Comparator<T> dominance, final double[] strengths, | |
73 | final Population<T> population) { | |
74 | Validate.notNull(dominance); | |
75 | Validate.notNull(strengths); | |
76 | Validate.notNull(population); | |
77 | Validate.isTrue(population.size() == strengths.length); | |
78 | Validate.isTrue(population.size() > 0); | |
79 | ||
80 |
1
1. computeRawFitness : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE |
final double[] rawFitness = new double[population.size()]; |
81 |
6
1. computeRawFitness : Substituted 0 with 1 → NO_COVERAGE 2. computeRawFitness : removed conditional - replaced comparison check with false → NO_COVERAGE 3. computeRawFitness : removed conditional - replaced comparison check with true → NO_COVERAGE 4. computeRawFitness : negated conditional → NO_COVERAGE 5. computeRawFitness : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 6. computeRawFitness : changed conditional boundary → NO_COVERAGE |
for (int i = 0; i < population.size(); i++) { |
82 |
1
1. computeRawFitness : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE |
final T fitness = population.getFitness(i); |
83 | ||
84 |
2
1. computeRawFitness : replaced call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::rawFitness with argument → NO_COVERAGE 2. computeRawFitness : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::rawFitness → NO_COVERAGE |
rawFitness[i] = SPEA2Utils.rawFitness(dominance, strengths, i, fitness, population); |
85 | } | |
86 | ||
87 |
1
1. computeRawFitness : replaced return value with null for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeRawFitness → NO_COVERAGE |
return rawFitness; |
88 | } | |
89 | ||
90 | protected List<List<Pair<Integer, Double>>> computeSortedDistances(final double[][] distanceObjectives, | |
91 | final Population<T> population) { | |
92 | Validate.notNull(distanceObjectives); | |
93 | Validate.notNull(population); | |
94 | Validate.isTrue(population.size() == distanceObjectives.length); // won't test all the rows | |
95 | Validate.isTrue(population.size() > 0); | |
96 | ||
97 |
1
1. computeSortedDistances : removed call to java/util/ArrayList::<init> → NO_COVERAGE |
final List<List<Pair<Integer, Double>>> distances = new ArrayList<>(); |
98 |
6
1. computeSortedDistances : removed conditional - replaced comparison check with true → NO_COVERAGE 2. computeSortedDistances : changed conditional boundary → NO_COVERAGE 3. computeSortedDistances : Substituted 0 with 1 → NO_COVERAGE 4. computeSortedDistances : negated conditional → NO_COVERAGE 5. computeSortedDistances : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 6. computeSortedDistances : removed conditional - replaced comparison check with false → NO_COVERAGE |
for (int i = 0; i < population.size(); i++) { |
99 |
1
1. computeSortedDistances : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE |
final T fitness = population.getFitness(i); |
100 | ||
101 | final List<Pair<Integer, Double>> kthDistances = SPEA2Utils | |
102 |
1
1. computeSortedDistances : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::kthDistances → NO_COVERAGE |
.kthDistances(distanceObjectives, i, fitness, population); |
103 |
1
1. computeSortedDistances : removed call to java/util/List::add → NO_COVERAGE |
distances.add(kthDistances); |
104 | ||
105 | } | |
106 |
1
1. computeSortedDistances : replaced return value with Collections.emptyList for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeSortedDistances → NO_COVERAGE |
return distances; |
107 | } | |
108 | ||
109 | protected double[] computeDensity(final List<List<Pair<Integer, Double>>> distances, final int k, | |
110 | final Population<T> population) { | |
111 | Validate.notNull(distances); | |
112 | Validate.isTrue(population.size() == distances.size()); | |
113 | Validate.isTrue(k > 0); | |
114 | Validate.notNull(population); | |
115 | Validate.isTrue(population.size() > 0); | |
116 | ||
117 |
1
1. computeDensity : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE |
final double[] density = new double[population.size()]; |
118 |
6
1. computeDensity : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 2. computeDensity : removed conditional - replaced comparison check with true → NO_COVERAGE 3. computeDensity : negated conditional → NO_COVERAGE 4. computeDensity : removed conditional - replaced comparison check with false → NO_COVERAGE 5. computeDensity : Substituted 0 with 1 → NO_COVERAGE 6. computeDensity : changed conditional boundary → NO_COVERAGE |
for (int i = 0; i < population.size(); i++) { |
119 |
2
1. computeDensity : Substituted 1.0 with 2.0 → NO_COVERAGE 2. computeDensity : removed call to java/util/List::get → NO_COVERAGE |
density[i] = 1.0d / (distances.get(i) |
120 |
1
1. computeDensity : removed call to java/util/List::get → NO_COVERAGE |
.get(k) |
121 |
5
1. computeDensity : Replaced double division with multiplication → NO_COVERAGE 2. computeDensity : Replaced double addition with subtraction → NO_COVERAGE 3. computeDensity : removed call to java/lang/Double::doubleValue → NO_COVERAGE 4. computeDensity : Substituted 2.0 with 1.0 → NO_COVERAGE 5. computeDensity : removed call to org/apache/commons/lang3/tuple/Pair::getRight → NO_COVERAGE |
.getRight() + 2); |
122 | } | |
123 | ||
124 |
1
1. computeDensity : replaced return value with null for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeDensity → NO_COVERAGE |
return density; |
125 | } | |
126 | ||
127 | protected double[] computeFinalFitness(final double[] rawFitness, final double[] density, | |
128 | final Population<T> population) { | |
129 | Validate.notNull(rawFitness); | |
130 | Validate.notNull(density); | |
131 | Validate.isTrue(rawFitness.length == density.length); | |
132 | Validate.notNull(population); | |
133 | Validate.isTrue(population.size() > 0); | |
134 | Validate.isTrue(population.size() == density.length); | |
135 | ||
136 |
1
1. computeFinalFitness : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE |
final double[] finalFitness = new double[population.size()]; |
137 |
6
1. computeFinalFitness : Substituted 0 with 1 → NO_COVERAGE 2. computeFinalFitness : changed conditional boundary → NO_COVERAGE 3. computeFinalFitness : removed conditional - replaced comparison check with false → NO_COVERAGE 4. computeFinalFitness : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 5. computeFinalFitness : removed conditional - replaced comparison check with true → NO_COVERAGE 6. computeFinalFitness : negated conditional → NO_COVERAGE |
for (int i = 0; i < population.size(); i++) { |
138 |
1
1. computeFinalFitness : Replaced double addition with subtraction → NO_COVERAGE |
finalFitness[i] = rawFitness[i] + density[i]; |
139 | } | |
140 | ||
141 |
1
1. computeFinalFitness : replaced return value with null for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeFinalFitness → NO_COVERAGE |
return finalFitness; |
142 | } | |
143 | ||
144 | protected int skipNull(final List<Pair<Integer, Double>> distances, final int i) { | |
145 | Validate.notNull(distances); | |
146 | Validate.isTrue(i >= 0); | |
147 | Validate.isTrue(i <= distances.size()); | |
148 | ||
149 | int j = i; | |
150 | ||
151 |
9
1. skipNull : removed conditional - replaced comparison check with false → NO_COVERAGE 2. skipNull : removed conditional - replaced comparison check with true → NO_COVERAGE 3. skipNull : negated conditional → NO_COVERAGE 4. skipNull : removed conditional - replaced equality check with true → NO_COVERAGE 5. skipNull : removed conditional - replaced equality check with false → NO_COVERAGE 6. skipNull : removed call to java/util/List::size → NO_COVERAGE 7. skipNull : negated conditional → NO_COVERAGE 8. skipNull : removed call to java/util/List::get → NO_COVERAGE 9. skipNull : changed conditional boundary → NO_COVERAGE |
while (j < distances.size() && distances.get(j) == null) { |
152 | j++; | |
153 | } | |
154 | ||
155 |
1
1. skipNull : replaced int return with 0 for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::skipNull → NO_COVERAGE |
return j; |
156 | } | |
157 | ||
158 | protected List<Integer> computeAdditionalIndividuals(final Set<Integer> selectedIndex, final double[] rawFitness, | |
159 | final Population<T> population, final int numIndividuals) { | |
160 | Validate.notNull(selectedIndex); | |
161 | Validate.notNull(rawFitness); | |
162 | Validate.notNull(population); | |
163 | Validate.isTrue(rawFitness.length == population.size()); | |
164 | Validate.isTrue(numIndividuals >= selectedIndex.size()); | |
165 | ||
166 |
4
1. computeAdditionalIndividuals : negated conditional → NO_COVERAGE 2. computeAdditionalIndividuals : removed call to java/util/Set::size → NO_COVERAGE 3. computeAdditionalIndividuals : removed conditional - replaced equality check with true → NO_COVERAGE 4. computeAdditionalIndividuals : removed conditional - replaced equality check with false → NO_COVERAGE |
if (numIndividuals == selectedIndex.size()) { |
167 |
1
1. computeAdditionalIndividuals : removed call to java/util/Collections::emptyList → NO_COVERAGE |
return Collections.emptyList(); |
168 | } | |
169 | ||
170 |
3
1. computeAdditionalIndividuals : removed call to java/util/stream/IntStream::range → NO_COVERAGE 2. computeAdditionalIndividuals : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 3. computeAdditionalIndividuals : Substituted 0 with 1 → NO_COVERAGE |
final List<Integer> additionalIndividuals = IntStream.range(0, population.size()) |
171 |
1
1. computeAdditionalIndividuals : removed call to java/util/stream/IntStream::boxed → NO_COVERAGE |
.boxed() |
172 |
9
1. lambda$computeAdditionalIndividuals$0 : negated conditional → NO_COVERAGE 2. lambda$computeAdditionalIndividuals$0 : replaced boolean return with true for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::lambda$computeAdditionalIndividuals$0 → NO_COVERAGE 3. lambda$computeAdditionalIndividuals$0 : removed conditional - replaced equality check with false → NO_COVERAGE 4. lambda$computeAdditionalIndividuals$0 : removed call to java/util/Set::contains → NO_COVERAGE 5. lambda$computeAdditionalIndividuals$0 : Substituted 0 with 1 → NO_COVERAGE 6. computeAdditionalIndividuals : removed call to java/util/stream/Stream::filter → NO_COVERAGE 7. lambda$computeAdditionalIndividuals$0 : Substituted 1 with 0 → NO_COVERAGE 8. lambda$computeAdditionalIndividuals$0 : removed conditional - replaced equality check with true → NO_COVERAGE 9. computeAdditionalIndividuals : replaced call to java/util/stream/Stream::filter with receiver → NO_COVERAGE |
.filter((i) -> selectedIndex.contains(i) == false) |
173 |
6
1. lambda$computeAdditionalIndividuals$1 : removed call to java/lang/Integer::intValue → NO_COVERAGE 2. lambda$computeAdditionalIndividuals$1 : replaced int return with 0 for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::lambda$computeAdditionalIndividuals$1 → NO_COVERAGE 3. lambda$computeAdditionalIndividuals$1 : removed call to java/lang/Double::compare → NO_COVERAGE 4. computeAdditionalIndividuals : replaced call to java/util/stream/Stream::sorted with receiver → NO_COVERAGE 5. computeAdditionalIndividuals : removed call to java/util/stream/Stream::sorted → NO_COVERAGE 6. lambda$computeAdditionalIndividuals$1 : removed call to java/lang/Integer::intValue → NO_COVERAGE |
.sorted((a, b) -> Double.compare(rawFitness[a], rawFitness[b])) |
174 |
4
1. computeAdditionalIndividuals : removed call to java/util/Set::size → NO_COVERAGE 2. computeAdditionalIndividuals : replaced call to java/util/stream/Stream::limit with receiver → NO_COVERAGE 3. computeAdditionalIndividuals : removed call to java/util/stream/Stream::limit → NO_COVERAGE 4. computeAdditionalIndividuals : Replaced integer subtraction with addition → NO_COVERAGE |
.limit(numIndividuals - selectedIndex.size()) |
175 |
2
1. computeAdditionalIndividuals : removed call to java/util/stream/Stream::collect → NO_COVERAGE 2. computeAdditionalIndividuals : removed call to java/util/stream/Collectors::toList → NO_COVERAGE |
.collect(Collectors.toList()); |
176 | ||
177 |
1
1. computeAdditionalIndividuals : replaced return value with Collections.emptyList for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeAdditionalIndividuals → NO_COVERAGE |
return additionalIndividuals; |
178 | } | |
179 | ||
180 | protected void truncatePopulation(final List<List<Pair<Integer, Double>>> distances, final Population<T> population, | |
181 | final int numIndividuals, final Set<Integer> selectedIndex) { | |
182 | ||
183 |
1
1. truncatePopulation : removed call to java/util/HashMap::<init> → NO_COVERAGE |
final Map<Integer, List<Pair<Integer, Double>>> selectedDistances = new HashMap<>(); |
184 |
1
1. truncatePopulation : removed call to java/util/HashMap::<init> → NO_COVERAGE |
final Map<Integer, Map<Integer, Integer>> selectedDistancesIndex = new HashMap<>(); |
185 | ||
186 | /** | |
187 | * The goal here is two fold: | |
188 | * - Build selectedDistances, which is a map of individual index -> ordered list | |
189 | * of nearest neighbors, with only the individuals from selectedIndex. This will | |
190 | * prevent the unnecessary processing of ignored individuals | |
191 | * | |
192 | * - Build an inverted index selectedDistancesIndex so that we know where to | |
193 | * delete entries in selectedDistances whenever an individual has been removed | |
194 | * The index is in the form: individual -> key in selectedDistance -> Which | |
195 | * position in the nearest neighbors | |
196 | */ | |
197 |
1
1. truncatePopulation : removed call to java/lang/Integer::intValue → NO_COVERAGE |
for (final int index : selectedIndex) { |
198 | ||
199 |
1
1. truncatePopulation : removed call to java/util/List::get → NO_COVERAGE |
final List<Pair<Integer, Double>> kthDistances = distances.get(index) |
200 |
1
1. truncatePopulation : removed call to java/util/List::stream → NO_COVERAGE |
.stream() |
201 |
6
1. lambda$truncatePopulation$2 : removed call to org/apache/commons/lang3/tuple/Pair::getLeft → NO_COVERAGE 2. lambda$truncatePopulation$2 : removed call to java/util/Set::contains → NO_COVERAGE 3. truncatePopulation : removed call to java/util/stream/Stream::filter → NO_COVERAGE 4. truncatePopulation : replaced call to java/util/stream/Stream::filter with receiver → NO_COVERAGE 5. lambda$truncatePopulation$2 : replaced boolean return with false for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::lambda$truncatePopulation$2 → NO_COVERAGE 6. lambda$truncatePopulation$2 : replaced boolean return with true for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::lambda$truncatePopulation$2 → NO_COVERAGE |
.filter(p -> selectedIndex.contains(p.getLeft())) |
202 |
2
1. truncatePopulation : removed call to java/util/stream/Stream::collect → NO_COVERAGE 2. truncatePopulation : removed call to java/util/stream/Collectors::toList → NO_COVERAGE |
.collect(Collectors.toList()); |
203 | ||
204 | Validate.isTrue(kthDistances.size() == selectedIndex.size()); | |
205 |
3
1. truncatePopulation : removed call to java/lang/Integer::valueOf → NO_COVERAGE 2. truncatePopulation : replaced call to java/util/Map::put with argument → NO_COVERAGE 3. truncatePopulation : removed call to java/util/Map::put → NO_COVERAGE |
selectedDistances.put(index, kthDistances); |
206 | ||
207 |
6
1. truncatePopulation : removed conditional - replaced comparison check with true → NO_COVERAGE 2. truncatePopulation : removed conditional - replaced comparison check with false → NO_COVERAGE 3. truncatePopulation : removed call to java/util/List::size → NO_COVERAGE 4. truncatePopulation : negated conditional → NO_COVERAGE 5. truncatePopulation : Substituted 0 with 1 → NO_COVERAGE 6. truncatePopulation : changed conditional boundary → NO_COVERAGE |
for (int i = 0; i < kthDistances.size(); i++) { |
208 |
1
1. truncatePopulation : removed call to java/util/List::get → NO_COVERAGE |
final Pair<Integer, Double> pair = kthDistances.get(i); |
209 | ||
210 |
5
1. truncatePopulation : negated conditional → NO_COVERAGE 2. truncatePopulation : removed call to java/util/Map::containsKey → NO_COVERAGE 3. truncatePopulation : removed call to org/apache/commons/lang3/tuple/Pair::getKey → NO_COVERAGE 4. truncatePopulation : removed conditional - replaced equality check with true → NO_COVERAGE 5. truncatePopulation : removed conditional - replaced equality check with false → NO_COVERAGE |
if (selectedDistancesIndex.containsKey(pair.getKey()) == false) { |
211 |
4
1. truncatePopulation : removed call to org/apache/commons/lang3/tuple/Pair::getKey → NO_COVERAGE 2. truncatePopulation : removed call to java/util/HashMap::<init> → NO_COVERAGE 3. truncatePopulation : replaced call to java/util/Map::put with argument → NO_COVERAGE 4. truncatePopulation : removed call to java/util/Map::put → NO_COVERAGE |
selectedDistancesIndex.put(pair.getKey(), new HashMap<>()); |
212 | } | |
213 | ||
214 |
3
1. truncatePopulation : replaced call to java/util/Map::get with argument → NO_COVERAGE 2. truncatePopulation : removed call to java/util/Map::get → NO_COVERAGE 3. truncatePopulation : removed call to org/apache/commons/lang3/tuple/Pair::getKey → NO_COVERAGE |
selectedDistancesIndex.get(pair.getKey()) |
215 |
4
1. truncatePopulation : replaced call to java/util/Map::put with argument → NO_COVERAGE 2. truncatePopulation : removed call to java/util/Map::put → NO_COVERAGE 3. truncatePopulation : removed call to java/lang/Integer::valueOf → NO_COVERAGE 4. truncatePopulation : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
.put(index, i); |
216 | } | |
217 | } | |
218 | ||
219 |
5
1. truncatePopulation : changed conditional boundary → NO_COVERAGE 2. truncatePopulation : removed conditional - replaced comparison check with false → NO_COVERAGE 3. truncatePopulation : removed conditional - replaced comparison check with true → NO_COVERAGE 4. truncatePopulation : negated conditional → NO_COVERAGE 5. truncatePopulation : removed call to java/util/Set::size → NO_COVERAGE |
while (selectedIndex.size() > numIndividuals) { |
220 | ||
221 |
1
1. truncatePopulation : Substituted -1 with 0 → NO_COVERAGE |
int minIndex = -1; |
222 | List<Pair<Integer, Double>> minDistances = null; | |
223 |
1
1. truncatePopulation : removed call to java/lang/Integer::intValue → NO_COVERAGE |
for (final int candidateIndex : selectedIndex) { |
224 | ||
225 |
4
1. truncatePopulation : removed conditional - replaced comparison check with true → NO_COVERAGE 2. truncatePopulation : removed conditional - replaced comparison check with false → NO_COVERAGE 3. truncatePopulation : negated conditional → NO_COVERAGE 4. truncatePopulation : changed conditional boundary → NO_COVERAGE |
if (minIndex < 0) { |
226 | minIndex = candidateIndex; | |
227 |
3
1. truncatePopulation : replaced call to java/util/Map::get with argument → NO_COVERAGE 2. truncatePopulation : removed call to java/util/Map::get → NO_COVERAGE 3. truncatePopulation : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
minDistances = selectedDistances.get(candidateIndex); |
228 | } else { | |
229 |
3
1. truncatePopulation : removed call to java/lang/Integer::valueOf → NO_COVERAGE 2. truncatePopulation : replaced call to java/util/Map::get with argument → NO_COVERAGE 3. truncatePopulation : removed call to java/util/Map::get → NO_COVERAGE |
final List<Pair<Integer, Double>> distancesCandidate = selectedDistances.get(candidateIndex); |
230 | Validate.isTrue(minDistances.size() == distancesCandidate.size()); | |
231 | ||
232 |
1
1. truncatePopulation : Substituted 0 with 1 → NO_COVERAGE |
int result = 0; |
233 |
3
1. truncatePopulation : replaced call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::skipNull with argument → NO_COVERAGE 2. truncatePopulation : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::skipNull → NO_COVERAGE 3. truncatePopulation : Substituted 0 with 1 → NO_COVERAGE |
int j = skipNull(minDistances, 0); |
234 |
3
1. truncatePopulation : Substituted 0 with 1 → NO_COVERAGE 2. truncatePopulation : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::skipNull → NO_COVERAGE 3. truncatePopulation : replaced call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::skipNull with argument → NO_COVERAGE |
int l = skipNull(distancesCandidate, 0); |
235 | ||
236 |
13
1. truncatePopulation : changed conditional boundary → NO_COVERAGE 2. truncatePopulation : removed conditional - replaced comparison check with false → NO_COVERAGE 3. truncatePopulation : removed call to java/util/List::size → NO_COVERAGE 4. truncatePopulation : removed conditional - replaced comparison check with true → NO_COVERAGE 5. truncatePopulation : negated conditional → NO_COVERAGE 6. truncatePopulation : removed call to java/util/List::size → NO_COVERAGE 7. truncatePopulation : removed conditional - replaced comparison check with true → NO_COVERAGE 8. truncatePopulation : negated conditional → NO_COVERAGE 9. truncatePopulation : negated conditional → NO_COVERAGE 10. truncatePopulation : removed conditional - replaced equality check with false → NO_COVERAGE 11. truncatePopulation : removed conditional - replaced equality check with true → NO_COVERAGE 12. truncatePopulation : changed conditional boundary → NO_COVERAGE 13. truncatePopulation : removed conditional - replaced comparison check with false → NO_COVERAGE |
while (result == 0 && j < minDistances.size() && l < distancesCandidate.size()) { |
237 | ||
238 |
2
1. truncatePopulation : removed call to java/lang/Double::compare → NO_COVERAGE 2. truncatePopulation : removed call to java/util/List::get → NO_COVERAGE |
result = Double.compare(minDistances.get(j) |
239 |
2
1. truncatePopulation : removed call to java/lang/Double::doubleValue → NO_COVERAGE 2. truncatePopulation : removed call to org/apache/commons/lang3/tuple/Pair::getRight → NO_COVERAGE |
.getRight(), |
240 |
1
1. truncatePopulation : removed call to java/util/List::get → NO_COVERAGE |
distancesCandidate.get(l) |
241 |
2
1. truncatePopulation : removed call to java/lang/Double::doubleValue → NO_COVERAGE 2. truncatePopulation : removed call to org/apache/commons/lang3/tuple/Pair::getRight → NO_COVERAGE |
.getRight()); |
242 | ||
243 |
2
1. truncatePopulation : Removed increment 1 → NO_COVERAGE 2. truncatePopulation : Changed increment from 1 to -1 → NO_COVERAGE |
j++; |
244 |
2
1. truncatePopulation : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::skipNull → NO_COVERAGE 2. truncatePopulation : replaced call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::skipNull with argument → NO_COVERAGE |
j = skipNull(minDistances, j); |
245 | ||
246 |
2
1. truncatePopulation : Removed increment 1 → NO_COVERAGE 2. truncatePopulation : Changed increment from 1 to -1 → NO_COVERAGE |
l++; |
247 |
2
1. truncatePopulation : replaced call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::skipNull with argument → NO_COVERAGE 2. truncatePopulation : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::skipNull → NO_COVERAGE |
l = skipNull(distancesCandidate, l); |
248 | } | |
249 | ||
250 |
4
1. truncatePopulation : removed conditional - replaced comparison check with false → NO_COVERAGE 2. truncatePopulation : changed conditional boundary → NO_COVERAGE 3. truncatePopulation : removed conditional - replaced comparison check with true → NO_COVERAGE 4. truncatePopulation : negated conditional → NO_COVERAGE |
if (result > 0) { |
251 | minIndex = candidateIndex; | |
252 | minDistances = distancesCandidate; | |
253 | } | |
254 | } | |
255 | } | |
256 | ||
257 | /** | |
258 | * We cannot just remove it. We have to set the entry to 'null' as to not mess | |
259 | * up the positions recorded in selectedDistancesIndex. | |
260 | */ | |
261 |
3
1. truncatePopulation : replaced call to java/util/Map::get with argument → NO_COVERAGE 2. truncatePopulation : removed call to java/util/Map::get → NO_COVERAGE 3. truncatePopulation : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
final Map<Integer, Integer> reverseIndex = selectedDistancesIndex.get(minIndex); |
262 |
1
1. truncatePopulation : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (Entry<Integer, Integer> entry : reverseIndex.entrySet()) { |
263 |
3
1. truncatePopulation : replaced call to java/util/Map::get with argument → NO_COVERAGE 2. truncatePopulation : removed call to java/util/Map::get → NO_COVERAGE 3. truncatePopulation : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final List<Pair<Integer, Double>> distancesToClean = selectedDistances.get(entry.getKey()); |
264 |
4
1. truncatePopulation : replaced call to java/util/List::set with argument → NO_COVERAGE 2. truncatePopulation : removed call to java/util/List::set → NO_COVERAGE 3. truncatePopulation : removed call to java/lang/Integer::intValue → NO_COVERAGE 4. truncatePopulation : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
distancesToClean.set((int) entry.getValue(), null); |
265 | } | |
266 |
1
1. truncatePopulation : removed call to java/util/Map::values → NO_COVERAGE |
for (Map<Integer, Integer> map : selectedDistancesIndex.values()) { |
267 |
3
1. truncatePopulation : removed call to java/util/Map::remove → NO_COVERAGE 2. truncatePopulation : removed call to java/lang/Integer::valueOf → NO_COVERAGE 3. truncatePopulation : replaced call to java/util/Map::remove with argument → NO_COVERAGE |
map.remove(minIndex); |
268 | } | |
269 | ||
270 |
3
1. truncatePopulation : replaced call to java/util/Map::remove with argument → NO_COVERAGE 2. truncatePopulation : removed call to java/util/Map::remove → NO_COVERAGE 3. truncatePopulation : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
selectedDistancesIndex.remove(minIndex); |
271 |
3
1. truncatePopulation : removed call to java/util/Map::remove → NO_COVERAGE 2. truncatePopulation : removed call to java/lang/Integer::valueOf → NO_COVERAGE 3. truncatePopulation : replaced call to java/util/Map::remove with argument → NO_COVERAGE |
selectedDistances.remove(minIndex); |
272 |
2
1. truncatePopulation : removed call to java/util/Set::remove → NO_COVERAGE 2. truncatePopulation : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
selectedIndex.remove(minIndex); |
273 | } | |
274 | ||
275 | } | |
276 | ||
277 | protected Set<Integer> environmentalSelection(final List<List<Pair<Integer, Double>>> distances, | |
278 | final double[] rawFitness, final double[] finalFitness, final Population<T> population, | |
279 | final int numIndividuals) { | |
280 | ||
281 |
3
1. environmentalSelection : removed call to java/util/stream/IntStream::range → NO_COVERAGE 2. environmentalSelection : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 3. environmentalSelection : Substituted 0 with 1 → NO_COVERAGE |
final Set<Integer> selectedIndex = IntStream.range(0, population.size()) |
282 |
1
1. environmentalSelection : removed call to java/util/stream/IntStream::boxed → NO_COVERAGE |
.boxed() |
283 |
11
1. lambda$environmentalSelection$3 : Substituted 1.0 with 2.0 → NO_COVERAGE 2. lambda$environmentalSelection$3 : replaced boolean return with true for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::lambda$environmentalSelection$3 → NO_COVERAGE 3. lambda$environmentalSelection$3 : removed call to java/lang/Integer::intValue → NO_COVERAGE 4. lambda$environmentalSelection$3 : negated conditional → NO_COVERAGE 5. lambda$environmentalSelection$3 : Substituted 1 with 0 → NO_COVERAGE 6. lambda$environmentalSelection$3 : removed conditional - replaced comparison check with false → NO_COVERAGE 7. lambda$environmentalSelection$3 : changed conditional boundary → NO_COVERAGE 8. environmentalSelection : removed call to java/util/stream/Stream::filter → NO_COVERAGE 9. environmentalSelection : replaced call to java/util/stream/Stream::filter with receiver → NO_COVERAGE 10. lambda$environmentalSelection$3 : removed conditional - replaced comparison check with true → NO_COVERAGE 11. lambda$environmentalSelection$3 : Substituted 0 with 1 → NO_COVERAGE |
.filter((i) -> finalFitness[i] < 1) |
284 |
2
1. environmentalSelection : removed call to java/util/stream/Stream::collect → NO_COVERAGE 2. environmentalSelection : removed call to java/util/stream/Collectors::toSet → NO_COVERAGE |
.collect(Collectors.toSet()); |
285 | ||
286 | logger.trace("Selected index size: {}", selectedIndex.size()); | |
287 | ||
288 |
5
1. environmentalSelection : changed conditional boundary → NO_COVERAGE 2. environmentalSelection : removed conditional - replaced comparison check with false → NO_COVERAGE 3. environmentalSelection : negated conditional → NO_COVERAGE 4. environmentalSelection : removed call to java/util/Set::size → NO_COVERAGE 5. environmentalSelection : removed conditional - replaced comparison check with true → NO_COVERAGE |
if (selectedIndex.size() < numIndividuals) { |
289 | ||
290 |
1
1. environmentalSelection : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeAdditionalIndividuals → NO_COVERAGE |
final List<Integer> additionalIndividuals = computeAdditionalIndividuals(selectedIndex, |
291 | rawFitness, | |
292 | population, | |
293 | numIndividuals); | |
294 | ||
295 | logger.trace("Adding {} additional individuals", additionalIndividuals.size()); | |
296 |
1
1. environmentalSelection : removed call to java/util/Set::addAll → NO_COVERAGE |
selectedIndex.addAll(additionalIndividuals); |
297 | } | |
298 | ||
299 |
5
1. environmentalSelection : negated conditional → NO_COVERAGE 2. environmentalSelection : changed conditional boundary → NO_COVERAGE 3. environmentalSelection : removed call to java/util/Set::size → NO_COVERAGE 4. environmentalSelection : removed conditional - replaced comparison check with true → NO_COVERAGE 5. environmentalSelection : removed conditional - replaced comparison check with false → NO_COVERAGE |
if (selectedIndex.size() > numIndividuals) { |
300 | logger.trace("Need to remove {} individuals", selectedIndex.size() - numIndividuals); | |
301 | ||
302 |
1
1. environmentalSelection : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::truncatePopulation → NO_COVERAGE |
truncatePopulation(distances, population, numIndividuals, selectedIndex); |
303 | } | |
304 | ||
305 |
1
1. environmentalSelection : replaced return value with Collections.emptySet for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::environmentalSelection → NO_COVERAGE |
return selectedIndex; |
306 | } | |
307 | ||
308 | @Override | |
309 | public Population<T> select(final AbstractEAConfiguration<T> eaConfiguration, final int numIndividuals, | |
310 | final List<Genotype> population, final List<T> populationScores, final List<Genotype> offsprings, | |
311 | final List<T> offspringScores) { | |
312 | Validate.notNull(eaConfiguration); | |
313 | Validate.isTrue(numIndividuals > 0); | |
314 | Validate.notNull(population); | |
315 | Validate.notNull(populationScores); | |
316 | Validate.isTrue(population.size() == populationScores.size()); | |
317 | Validate.notNull(offsprings); | |
318 | Validate.notNull(offspringScores); | |
319 | Validate.isTrue(offsprings.size() == offspringScores.size()); | |
320 | ||
321 |
1
1. select : removed call to java/lang/System::nanoTime → NO_COVERAGE |
final long startTimeNanos = System.nanoTime(); |
322 | logger.debug("Starting with requested {} individuals - {} population - {} offsprings", | |
323 |
1
1. select : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
numIndividuals, |
324 |
2
1. select : removed call to java/lang/Integer::valueOf → NO_COVERAGE 2. select : removed call to java/util/List::size → NO_COVERAGE |
population.size(), |
325 |
2
1. select : removed call to java/lang/Integer::valueOf → NO_COVERAGE 2. select : removed call to java/util/List::size → NO_COVERAGE |
offsprings.size()); |
326 | ||
327 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::<init> → NO_COVERAGE |
final Population<T> archive = new Population<>(population, populationScores); |
328 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::<init> → NO_COVERAGE |
final Population<T> offspringPopulation = new Population<>(offsprings, offspringScores); |
329 | ||
330 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::<init> → NO_COVERAGE |
final Population<T> combinedPopulation = new Population<>(); |
331 |
1
1. select : removed call to net/bmahe/genetics4j/moo/spea2/spec/replacement/SPEA2Replacement::deduplicate → NO_COVERAGE |
if (spea2Replacement.deduplicate() |
332 |
4
1. select : removed conditional - replaced equality check with false → NO_COVERAGE 2. select : removed call to java/util/Optional::isPresent → NO_COVERAGE 3. select : removed conditional - replaced equality check with true → NO_COVERAGE 4. select : negated conditional → NO_COVERAGE |
.isPresent()) { |
333 |
1
1. select : removed call to net/bmahe/genetics4j/moo/spea2/spec/replacement/SPEA2Replacement::deduplicate → NO_COVERAGE |
final Comparator<Genotype> individualDeduplicator = spea2Replacement.deduplicate() |
334 |
1
1. select : removed call to java/util/Optional::get → NO_COVERAGE |
.get(); |
335 |
1
1. select : removed call to java/util/TreeSet::<init> → NO_COVERAGE |
final Set<Genotype> seenGenotype = new TreeSet<>(individualDeduplicator); |
336 | ||
337 |
6
1. select : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 2. select : negated conditional → NO_COVERAGE 3. select : removed conditional - replaced comparison check with true → NO_COVERAGE 4. select : removed conditional - replaced comparison check with false → NO_COVERAGE 5. select : changed conditional boundary → NO_COVERAGE 6. select : Substituted 0 with 1 → NO_COVERAGE |
for (int i = 0; i < archive.size(); i++) { |
338 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::getGenotype → NO_COVERAGE |
final Genotype genotype = archive.getGenotype(i); |
339 | ||
340 |
4
1. select : removed call to java/util/Set::add → NO_COVERAGE 2. select : negated conditional → NO_COVERAGE 3. select : removed conditional - replaced equality check with true → NO_COVERAGE 4. select : removed conditional - replaced equality check with false → NO_COVERAGE |
if (seenGenotype.add(genotype)) { |
341 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE |
final T fitness = archive.getFitness(i); |
342 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::add → NO_COVERAGE |
combinedPopulation.add(genotype, fitness); |
343 | } | |
344 | } | |
345 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE |
final int ingestedFromArchive = combinedPopulation.size(); |
346 | logger.debug("Ingested {} individuals from the archive out of the {} available", | |
347 |
1
1. select : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
ingestedFromArchive, |
348 |
2
1. select : removed call to java/lang/Integer::valueOf → NO_COVERAGE 2. select : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE |
archive.size()); |
349 | ||
350 |
6
1. select : removed conditional - replaced comparison check with true → NO_COVERAGE 2. select : changed conditional boundary → NO_COVERAGE 3. select : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 4. select : removed conditional - replaced comparison check with false → NO_COVERAGE 5. select : negated conditional → NO_COVERAGE 6. select : Substituted 0 with 1 → NO_COVERAGE |
for (int i = 0; i < offspringPopulation.size(); i++) { |
351 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::getGenotype → NO_COVERAGE |
final Genotype genotype = offspringPopulation.getGenotype(i); |
352 | ||
353 |
4
1. select : removed conditional - replaced equality check with false → NO_COVERAGE 2. select : removed call to java/util/Set::add → NO_COVERAGE 3. select : removed conditional - replaced equality check with true → NO_COVERAGE 4. select : negated conditional → NO_COVERAGE |
if (seenGenotype.add(genotype)) { |
354 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE |
final T fitness = offspringPopulation.getFitness(i); |
355 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::add → NO_COVERAGE |
combinedPopulation.add(genotype, fitness); |
356 | } | |
357 | } | |
358 | if (logger.isDebugEnabled()) { | |
359 | logger.debug("Ingested {} individuals from the offsprings out of the {} available", | |
360 |
3
1. select : Replaced integer subtraction with addition → NO_COVERAGE 2. select : removed call to java/lang/Integer::valueOf → NO_COVERAGE 3. select : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE |
combinedPopulation.size() - ingestedFromArchive, |
361 |
2
1. select : removed call to java/lang/Integer::valueOf → NO_COVERAGE 2. select : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE |
offspringPopulation.size()); |
362 | } | |
363 | ||
364 | } else { | |
365 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::addAll → NO_COVERAGE |
combinedPopulation.addAll(archive); |
366 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::addAll → NO_COVERAGE |
combinedPopulation.addAll(offspringPopulation); |
367 | } | |
368 | ||
369 |
6
1. select : Changed switch default to be first case → NO_COVERAGE 2. select : RemoveSwitch 1 (case value 2) → NO_COVERAGE 3. select : RemoveSwitch 0 (case value 1) → NO_COVERAGE 4. select : removed call to java/lang/MatchException::<init> → NO_COVERAGE 5. select : removed call to net/bmahe/genetics4j/core/spec/Optimization::ordinal → NO_COVERAGE 6. select : removed call to net/bmahe/genetics4j/core/spec/AbstractEAConfiguration::optimization → NO_COVERAGE |
final Comparator<T> dominance = switch (eaConfiguration.optimization()) { |
370 |
1
1. select : removed call to net/bmahe/genetics4j/moo/spea2/spec/replacement/SPEA2Replacement::dominance → NO_COVERAGE |
case MAXIMIZE -> spea2Replacement.dominance(); |
371 |
1
1. select : removed call to net/bmahe/genetics4j/moo/spea2/spec/replacement/SPEA2Replacement::dominance → NO_COVERAGE |
case MINIMIZE -> spea2Replacement.dominance() |
372 |
2
1. select : removed call to java/util/Comparator::reversed → NO_COVERAGE 2. select : replaced call to java/util/Comparator::reversed with receiver → NO_COVERAGE |
.reversed(); |
373 | }; | |
374 | ||
375 |
1
1. select : removed call to net/bmahe/genetics4j/moo/spea2/spec/replacement/SPEA2Replacement::k → NO_COVERAGE |
final int k = spea2Replacement.k() |
376 |
7
1. lambda$select$4 : replaced call to java/lang/Math::sqrt with argument → NO_COVERAGE 2. select : removed call to java/util/Optional::orElseGet → NO_COVERAGE 3. select : removed call to java/lang/Integer::intValue → NO_COVERAGE 4. lambda$select$4 : replaced Integer return value with 0 for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::lambda$select$4 → NO_COVERAGE 5. lambda$select$4 : removed call to java/lang/Math::sqrt → NO_COVERAGE 6. lambda$select$4 : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 7. lambda$select$4 : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
.orElseGet(() -> (int) Math.sqrt(combinedPopulation.size())); |
377 | logger.trace("Using k={}", k); | |
378 | Validate.isTrue(k > 0); | |
379 | ||
380 | ///////////////// Fitness computation ////////////////////// | |
381 |
1
1. select : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeStrength → NO_COVERAGE |
final double[] strengths = computeStrength(dominance, combinedPopulation); |
382 | ||
383 |
2
1. select : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeObjectiveDistances → NO_COVERAGE 2. select : removed call to net/bmahe/genetics4j/moo/spea2/spec/replacement/SPEA2Replacement::distance → NO_COVERAGE |
final double[][] distanceObjectives = computeObjectiveDistances(spea2Replacement.distance(), combinedPopulation); |
384 | ||
385 |
2
1. select : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeRawFitness → NO_COVERAGE 2. select : replaced call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeRawFitness with argument → NO_COVERAGE |
final double[] rawFitness = computeRawFitness(dominance, strengths, combinedPopulation); |
386 | ||
387 |
1
1. select : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeSortedDistances → NO_COVERAGE |
final List<List<Pair<Integer, Double>>> distances = computeSortedDistances(distanceObjectives, |
388 | combinedPopulation); | |
389 | ||
390 |
1
1. select : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeDensity → NO_COVERAGE |
final double[] density = computeDensity(distances, k, combinedPopulation); |
391 | ||
392 |
2
1. select : replaced call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeFinalFitness with argument → NO_COVERAGE 2. select : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::computeFinalFitness → NO_COVERAGE |
final double[] finalFitness = computeFinalFitness(rawFitness, density, combinedPopulation); |
393 | ||
394 | ///////////////// Environmental Selection ////////////////// | |
395 | ||
396 |
1
1. select : removed call to net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::environmentalSelection → NO_COVERAGE |
final Set<Integer> selectedIndex = environmentalSelection(distances, |
397 | rawFitness, | |
398 | finalFitness, | |
399 | combinedPopulation, | |
400 | numIndividuals); | |
401 | ||
402 |
1
1. select : removed call to net/bmahe/genetics4j/core/Population::<init> → NO_COVERAGE |
final Population<T> newPopulation = new Population<>(); |
403 |
1
1. select : removed call to java/lang/Integer::intValue → NO_COVERAGE |
for (final int i : selectedIndex) { |
404 |
3
1. select : removed call to net/bmahe/genetics4j/core/Population::getGenotype → NO_COVERAGE 2. select : removed call to net/bmahe/genetics4j/core/Population::add → NO_COVERAGE 3. select : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE |
newPopulation.add(combinedPopulation.getGenotype(i), combinedPopulation.getFitness(i)); |
405 | } | |
406 | ||
407 |
1
1. select : removed call to java/lang/System::nanoTime → NO_COVERAGE |
final long endTimeNanos = System.nanoTime(); |
408 | if (logger.isDebugEnabled()) { | |
409 | logger.debug("Finished with {} new population - Computation time: {}", | |
410 |
5
1. select : removed call to java/lang/Integer::valueOf → NO_COVERAGE 2. select : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE 3. select : Substituted 1000000 with 1000001 → NO_COVERAGE 4. select : Replaced long subtraction with addition → NO_COVERAGE 5. select : Replaced long division with multiplication → NO_COVERAGE |
newPopulation.size(), |
411 |
1
1. select : removed call to org/apache/commons/lang3/time/DurationFormatUtils::formatDurationHMS → NO_COVERAGE |
DurationFormatUtils.formatDurationHMS((endTimeNanos - startTimeNanos) / 1_000_000)); |
412 | } | |
413 | ||
414 |
1
1. select : replaced return value with null for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2ReplacementStrategyImplementor::select → NO_COVERAGE |
return newPopulation; |
415 | } | |
416 | } | |
Mutations | ||
34 |
1.1 |
|
42 |
1.1 |
|
43 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
44 |
1.1 |
|
46 |
1.1 2.2 |
|
49 |
1.1 |
|
58 |
1.1 2.2 |
|
60 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
61 |
1.1 2.2 3.3 4.4 5.5 |
|
62 |
1.1 2.2 3.3 4.4 |
|
63 |
1.1 |
|
64 |
1.1 |
|
67 |
1.1 |
|
69 |
1.1 |
|
80 |
1.1 |
|
81 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
82 |
1.1 |
|
84 |
1.1 2.2 |
|
87 |
1.1 |
|
97 |
1.1 |
|
98 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
99 |
1.1 |
|
102 |
1.1 |
|
103 |
1.1 |
|
106 |
1.1 |
|
117 |
1.1 |
|
118 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
119 |
1.1 2.2 |
|
120 |
1.1 |
|
121 |
1.1 2.2 3.3 4.4 5.5 |
|
124 |
1.1 |
|
136 |
1.1 |
|
137 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
138 |
1.1 |
|
141 |
1.1 |
|
151 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
155 |
1.1 |
|
166 |
1.1 2.2 3.3 4.4 |
|
167 |
1.1 |
|
170 |
1.1 2.2 3.3 |
|
171 |
1.1 |
|
172 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
173 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
174 |
1.1 2.2 3.3 4.4 |
|
175 |
1.1 2.2 |
|
177 |
1.1 |
|
183 |
1.1 |
|
184 |
1.1 |
|
197 |
1.1 |
|
199 |
1.1 |
|
200 |
1.1 |
|
201 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
202 |
1.1 2.2 |
|
205 |
1.1 2.2 3.3 |
|
207 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
208 |
1.1 |
|
210 |
1.1 2.2 3.3 4.4 5.5 |
|
211 |
1.1 2.2 3.3 4.4 |
|
214 |
1.1 2.2 3.3 |
|
215 |
1.1 2.2 3.3 4.4 |
|
219 |
1.1 2.2 3.3 4.4 5.5 |
|
221 |
1.1 |
|
223 |
1.1 |
|
225 |
1.1 2.2 3.3 4.4 |
|
227 |
1.1 2.2 3.3 |
|
229 |
1.1 2.2 3.3 |
|
232 |
1.1 |
|
233 |
1.1 2.2 3.3 |
|
234 |
1.1 2.2 3.3 |
|
236 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 13.13 |
|
238 |
1.1 2.2 |
|
239 |
1.1 2.2 |
|
240 |
1.1 |
|
241 |
1.1 2.2 |
|
243 |
1.1 2.2 |
|
244 |
1.1 2.2 |
|
246 |
1.1 2.2 |
|
247 |
1.1 2.2 |
|
250 |
1.1 2.2 3.3 4.4 |
|
261 |
1.1 2.2 3.3 |
|
262 |
1.1 |
|
263 |
1.1 2.2 3.3 |
|
264 |
1.1 2.2 3.3 4.4 |
|
266 |
1.1 |
|
267 |
1.1 2.2 3.3 |
|
270 |
1.1 2.2 3.3 |
|
271 |
1.1 2.2 3.3 |
|
272 |
1.1 2.2 |
|
281 |
1.1 2.2 3.3 |
|
282 |
1.1 |
|
283 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 |
|
284 |
1.1 2.2 |
|
288 |
1.1 2.2 3.3 4.4 5.5 |
|
290 |
1.1 |
|
296 |
1.1 |
|
299 |
1.1 2.2 3.3 4.4 5.5 |
|
302 |
1.1 |
|
305 |
1.1 |
|
321 |
1.1 |
|
323 |
1.1 |
|
324 |
1.1 2.2 |
|
325 |
1.1 2.2 |
|
327 |
1.1 |
|
328 |
1.1 |
|
330 |
1.1 |
|
331 |
1.1 |
|
332 |
1.1 2.2 3.3 4.4 |
|
333 |
1.1 |
|
334 |
1.1 |
|
335 |
1.1 |
|
337 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
338 |
1.1 |
|
340 |
1.1 2.2 3.3 4.4 |
|
341 |
1.1 |
|
342 |
1.1 |
|
345 |
1.1 |
|
347 |
1.1 |
|
348 |
1.1 2.2 |
|
350 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
351 |
1.1 |
|
353 |
1.1 2.2 3.3 4.4 |
|
354 |
1.1 |
|
355 |
1.1 |
|
360 |
1.1 2.2 3.3 |
|
361 |
1.1 2.2 |
|
365 |
1.1 |
|
366 |
1.1 |
|
369 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
370 |
1.1 |
|
371 |
1.1 |
|
372 |
1.1 2.2 |
|
375 |
1.1 |
|
376 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
381 |
1.1 |
|
383 |
1.1 2.2 |
|
385 |
1.1 2.2 |
|
387 |
1.1 |
|
390 |
1.1 |
|
392 |
1.1 2.2 |
|
396 |
1.1 |
|
402 |
1.1 |
|
403 |
1.1 |
|
404 |
1.1 2.2 3.3 |
|
407 |
1.1 |
|
410 |
1.1 2.2 3.3 4.4 5.5 |
|
411 |
1.1 |
|
414 |
1.1 |