1 | package net.bmahe.genetics4j.extras.evolutionlisteners; | |
2 | ||
3 | import java.io.IOException; | |
4 | import java.nio.charset.StandardCharsets; | |
5 | import java.nio.file.Path; | |
6 | import java.util.Comparator; | |
7 | import java.util.List; | |
8 | import java.util.Optional; | |
9 | import java.util.function.Function; | |
10 | import java.util.stream.Collectors; | |
11 | import java.util.stream.IntStream; | |
12 | import java.util.stream.Stream; | |
13 | ||
14 | import org.apache.commons.csv.CSVFormat; | |
15 | import org.apache.commons.csv.CSVPrinter; | |
16 | import org.apache.commons.lang3.Validate; | |
17 | import org.apache.logging.log4j.LogManager; | |
18 | import org.apache.logging.log4j.Logger; | |
19 | import org.immutables.value.Value; | |
20 | ||
21 | import net.bmahe.genetics4j.core.Genotype; | |
22 | import net.bmahe.genetics4j.core.evolutionlisteners.EvolutionListener; | |
23 | ||
24 | /** | |
25 | * Evolution Listener which writes the output of each generation to a CSV file | |
26 | * | |
27 | * @author bruno | |
28 | * | |
29 | * @param <T> Fitness type | |
30 | * @param <U> Data type written to the CSV | |
31 | */ | |
32 | @Value.Immutable | |
33 | public abstract class CSVEvolutionListener<T extends Comparable<T>, U> implements EvolutionListener<T> { | |
34 | final static public Logger logger = LogManager.getLogger(CSVEvolutionListener.class); | |
35 | ||
36 | public static final boolean DEFAULT_AUTO_FLUSH = true; | |
37 | ||
38 | private CSVPrinter csvPrinter; | |
39 | ||
40 | protected CSVPrinter openPrinter() { | |
41 | ||
42 |
2
1. openPrinter : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::columnExtractors → NO_COVERAGE 2. openPrinter : removed call to java/util/List::stream → NO_COVERAGE |
final List<String> headers = columnExtractors().stream() |
43 |
4
1. lambda$openPrinter$0 : replaced return value with "" for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::lambda$openPrinter$0 → NO_COVERAGE 2. lambda$openPrinter$0 : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/ColumnExtractor::header → NO_COVERAGE 3. openPrinter : replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE 4. openPrinter : removed call to java/util/stream/Stream::map → NO_COVERAGE |
.map(ce -> ce.header()) |
44 |
2
1. openPrinter : removed call to java/util/stream/Stream::collect → NO_COVERAGE 2. openPrinter : removed call to java/util/stream/Collectors::toUnmodifiableList → NO_COVERAGE |
.collect(Collectors.toUnmodifiableList()); |
45 | ||
46 | try { | |
47 |
4
1. openPrinter : replaced call to org/apache/commons/csv/CSVFormat::withAutoFlush with receiver → NO_COVERAGE 2. openPrinter : removed call to org/apache/commons/csv/CSVFormat::withAutoFlush → NO_COVERAGE 3. openPrinter : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::autoFlush → NO_COVERAGE 4. openPrinter : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::openPrinter → NO_COVERAGE |
return CSVFormat.DEFAULT.withAutoFlush(autoFlush()) |
48 |
5
1. openPrinter : removed call to java/util/List::size → NO_COVERAGE 2. openPrinter : replaced call to org/apache/commons/csv/CSVFormat::withHeader with receiver → NO_COVERAGE 3. openPrinter : removed call to java/util/List::toArray → NO_COVERAGE 4. openPrinter : replaced call to java/util/List::toArray with argument → NO_COVERAGE 5. openPrinter : removed call to org/apache/commons/csv/CSVFormat::withHeader → NO_COVERAGE |
.withHeader(headers.toArray(new String[headers.size()])) |
49 |
4
1. openPrinter : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::filename → NO_COVERAGE 2. openPrinter : removed call to java/nio/file/Path::of → NO_COVERAGE 3. openPrinter : removed call to org/apache/commons/csv/CSVFormat::print → NO_COVERAGE 4. openPrinter : Substituted 0 with 1 → NO_COVERAGE |
.print(Path.of(filename()), StandardCharsets.UTF_8); |
50 | } catch (IOException e) { | |
51 | logger.error("Could not open {}", filename(), e); | |
52 |
2
1. openPrinter : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::filename → NO_COVERAGE 2. openPrinter : removed call to java/lang/RuntimeException::<init> → NO_COVERAGE |
throw new RuntimeException("Could not open file " + filename(), e); |
53 | } | |
54 | ||
55 | } | |
56 | ||
57 | /** | |
58 | * Whether or not the CSV writer has auto flush enabled. Defaults to | |
59 | * {@value #DEFAULT_AUTO_FLUSH} | |
60 | * | |
61 | * @return | |
62 | */ | |
63 | @Value.Default | |
64 | public boolean autoFlush() { | |
65 |
2
1. autoFlush : replaced boolean return with false for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::autoFlush → NO_COVERAGE 2. autoFlush : Substituted 1 with 0 → NO_COVERAGE |
return DEFAULT_AUTO_FLUSH; |
66 | } | |
67 | ||
68 | /** | |
69 | * User defined function to provide some additional information when computing | |
70 | * the value to write. Defaults to null | |
71 | * | |
72 | * @return | |
73 | */ | |
74 | @Value.Default | |
75 | public GenerationFunction<T, U> evolutionContextSupplier() { | |
76 |
1
1. evolutionContextSupplier : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::evolutionContextSupplier → NO_COVERAGE |
return (generation, population, fitness, isDone) -> null; |
77 | } | |
78 | ||
79 | /** | |
80 | * How many generations to skip between each writes. Defaults to writing every | |
81 | * generations | |
82 | * | |
83 | * @return | |
84 | */ | |
85 | @Value.Default | |
86 | public int skipN() { | |
87 |
1
1. skipN : Substituted 0 with 1 → NO_COVERAGE |
return 0; |
88 | } | |
89 | ||
90 | /** | |
91 | * Users can supply an optional set of filters to control which individuals get | |
92 | * written and in which order. Default to have no impact. | |
93 | * | |
94 | * @return | |
95 | */ | |
96 | @Value.Default | |
97 | public Function<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> filter() { | |
98 |
2
1. lambda$filter$2 : replaced return value with Stream.empty for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::lambda$filter$2 → NO_COVERAGE 2. filter : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::filter → NO_COVERAGE |
return (stream) -> stream; |
99 | } | |
100 | ||
101 | /** | |
102 | * Destination file name for the CSV file | |
103 | * | |
104 | * @return | |
105 | */ | |
106 | @Value.Parameter | |
107 | public abstract String filename(); | |
108 | ||
109 | /** | |
110 | * List of Column Extractors. They specify how and what to write from each | |
111 | * individual at a given generation | |
112 | * | |
113 | * @return | |
114 | */ | |
115 | @Value.Parameter | |
116 | public abstract List<ColumnExtractor<T, U>> columnExtractors(); | |
117 | ||
118 | @Override | |
119 | public void onEvolution(final long generation, final List<Genotype> population, final List<T> fitness, | |
120 | final boolean isDone) { | |
121 | Validate.isTrue(generation >= 0); | |
122 | Validate.notNull(population); | |
123 | Validate.notNull(fitness); | |
124 | Validate.isTrue(population.size() > 0); | |
125 | Validate.isTrue(population.size() == fitness.size()); | |
126 | ||
127 |
14
1. onEvolution : Replaced long modulus with multiplication → NO_COVERAGE 2. onEvolution : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::skipN → NO_COVERAGE 3. onEvolution : Substituted 0 with 1 → NO_COVERAGE 4. onEvolution : removed conditional - replaced equality check with false → NO_COVERAGE 5. onEvolution : removed conditional - replaced equality check with true → NO_COVERAGE 6. onEvolution : removed conditional - replaced comparison check with false → NO_COVERAGE 7. onEvolution : removed conditional - replaced equality check with true → NO_COVERAGE 8. onEvolution : removed conditional - replaced comparison check with true → NO_COVERAGE 9. onEvolution : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::skipN → NO_COVERAGE 10. onEvolution : negated conditional → NO_COVERAGE 11. onEvolution : negated conditional → NO_COVERAGE 12. onEvolution : negated conditional → NO_COVERAGE 13. onEvolution : changed conditional boundary → NO_COVERAGE 14. onEvolution : removed conditional - replaced equality check with false → NO_COVERAGE |
if (isDone == false && skipN() > 0 && generation % skipN() != 0) { |
128 | return; | |
129 | } | |
130 | ||
131 |
3
1. onEvolution : removed conditional - replaced equality check with true → NO_COVERAGE 2. onEvolution : removed conditional - replaced equality check with false → NO_COVERAGE 3. onEvolution : negated conditional → NO_COVERAGE |
if (csvPrinter == null) { |
132 |
2
1. onEvolution : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::openPrinter → NO_COVERAGE 2. onEvolution : Removed assignment to member variable csvPrinter → NO_COVERAGE |
csvPrinter = openPrinter(); |
133 | } | |
134 | ||
135 | final Optional<U> context = Optional | |
136 |
3
1. onEvolution : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/GenerationFunction::apply → NO_COVERAGE 2. onEvolution : removed call to java/util/Optional::ofNullable → NO_COVERAGE 3. onEvolution : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::evolutionContextSupplier → NO_COVERAGE |
.ofNullable(evolutionContextSupplier().apply(generation, population, fitness, isDone)); |
137 | ||
138 |
3
1. onEvolution : Substituted 0 with 1 → NO_COVERAGE 2. onEvolution : removed call to java/util/List::size → NO_COVERAGE 3. onEvolution : removed call to java/util/stream/IntStream::range → NO_COVERAGE |
final var rawIndividualStream = IntStream.range(0, population.size()) |
139 |
1
1. onEvolution : removed call to java/util/stream/IntStream::boxed → NO_COVERAGE |
.boxed() |
140 |
4
1. onEvolution : removed call to java/util/stream/Stream::map → NO_COVERAGE 2. lambda$onEvolution$3 : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/EvolutionStep::of → NO_COVERAGE 3. onEvolution : replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE 4. lambda$onEvolution$3 : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::lambda$onEvolution$3 → NO_COVERAGE |
.map(individualIndex -> EvolutionStep.of(context, |
141 | generation, | |
142 |
1
1. lambda$onEvolution$3 : removed call to java/lang/Integer::intValue → NO_COVERAGE |
individualIndex, |
143 |
2
1. lambda$onEvolution$3 : removed call to java/lang/Integer::intValue → NO_COVERAGE 2. lambda$onEvolution$3 : removed call to java/util/List::get → NO_COVERAGE |
population.get(individualIndex), |
144 |
2
1. lambda$onEvolution$3 : removed call to java/lang/Integer::intValue → NO_COVERAGE 2. lambda$onEvolution$3 : removed call to java/util/List::get → NO_COVERAGE |
fitness.get(individualIndex), |
145 | isDone)); | |
146 | ||
147 |
3
1. onEvolution : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::filter → NO_COVERAGE 2. onEvolution : removed call to java/util/function/Function::apply → NO_COVERAGE 3. onEvolution : replaced call to java/util/function/Function::apply with argument → NO_COVERAGE |
final var filteredStream = filter().apply(rawIndividualStream); |
148 | ||
149 |
1
1. onEvolution : removed call to java/util/stream/Stream::forEach → NO_COVERAGE |
filteredStream.forEach(evolutionStep -> { |
150 |
2
1. lambda$onEvolution$6 : removed call to java/util/List::stream → NO_COVERAGE 2. lambda$onEvolution$6 : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::columnExtractors → NO_COVERAGE |
final List<Object> columnValues = columnExtractors().stream() |
151 |
4
1. lambda$onEvolution$4 : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/ColumnExtractor::columnExtractorFunction → NO_COVERAGE 2. lambda$onEvolution$4 : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::lambda$onEvolution$4 → NO_COVERAGE 3. lambda$onEvolution$6 : replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE 4. lambda$onEvolution$6 : removed call to java/util/stream/Stream::map → NO_COVERAGE |
.map(ce -> ce.columnExtractorFunction()) |
152 |
4
1. lambda$onEvolution$6 : replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE 2. lambda$onEvolution$5 : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/ColumnExtractorFunction::apply → NO_COVERAGE 3. lambda$onEvolution$6 : removed call to java/util/stream/Stream::map → NO_COVERAGE 4. lambda$onEvolution$5 : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::lambda$onEvolution$5 → NO_COVERAGE |
.map(cef -> cef.apply(evolutionStep)) |
153 |
2
1. lambda$onEvolution$6 : removed call to java/util/stream/Stream::collect → NO_COVERAGE 2. lambda$onEvolution$6 : removed call to java/util/stream/Collectors::toUnmodifiableList → NO_COVERAGE |
.collect(Collectors.toUnmodifiableList()); |
154 | ||
155 | try { | |
156 |
1
1. lambda$onEvolution$6 : removed call to org/apache/commons/csv/CSVPrinter::printRecord → NO_COVERAGE |
csvPrinter.printRecord(columnValues); |
157 | } catch (IOException e1) { | |
158 | logger.error("Could not write values: {}", columnValues, e1); | |
159 |
2
1. lambda$onEvolution$6 : removed call to java/lang/String::valueOf → NO_COVERAGE 2. lambda$onEvolution$6 : removed call to java/lang/RuntimeException::<init> → NO_COVERAGE |
throw new RuntimeException("Could not write values: " + columnValues, e1); |
160 | } | |
161 | }); | |
162 | ||
163 |
6
1. onEvolution : negated conditional → NO_COVERAGE 2. onEvolution : removed conditional - replaced equality check with false → NO_COVERAGE 3. onEvolution : removed conditional - replaced equality check with false → NO_COVERAGE 4. onEvolution : removed conditional - replaced equality check with true → NO_COVERAGE 5. onEvolution : removed conditional - replaced equality check with true → NO_COVERAGE 6. onEvolution : negated conditional → NO_COVERAGE |
if (isDone && csvPrinter != null) { |
164 | try { | |
165 |
2
1. onEvolution : removed call to org/apache/commons/csv/CSVPrinter::close → NO_COVERAGE 2. onEvolution : Substituted 1 with 0 → NO_COVERAGE |
csvPrinter.close(true); |
166 | } catch (IOException e) { | |
167 | logger.error("Could not close CSV printer for filename {}", filename(), e); | |
168 |
2
1. onEvolution : removed call to java/lang/RuntimeException::<init> → NO_COVERAGE 2. onEvolution : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::filename → NO_COVERAGE |
throw new RuntimeException("Could not close CSV printer for filename " + filename(), e); |
169 | } | |
170 | } | |
171 | } | |
172 | ||
173 | public static class Builder<T extends Comparable<T>, U> extends ImmutableCSVEvolutionListener.Builder<T, U> { | |
174 | } | |
175 | ||
176 | public static <T extends Comparable<T>, U> CSVEvolutionListener<T, U> of(String filename, | |
177 | List<ColumnExtractor<T, U>> columnExtractors) { | |
178 |
2
1. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/ImmutableCSVEvolutionListener::of → NO_COVERAGE 2. of : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::of → NO_COVERAGE |
return ImmutableCSVEvolutionListener.of(filename, (Iterable<? extends ColumnExtractor<T, U>>) columnExtractors); |
179 | } | |
180 | ||
181 | public static <T extends Comparable<T>, U> CSVEvolutionListener<T, U> of(String filename, | |
182 | Iterable<? extends ColumnExtractor<T, U>> columnExtractors) { | |
183 |
2
1. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/ImmutableCSVEvolutionListener::of → NO_COVERAGE 2. of : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::of → NO_COVERAGE |
return ImmutableCSVEvolutionListener.of(filename, columnExtractors); |
184 | } | |
185 | ||
186 | public static <T extends Comparable<T>, U> CSVEvolutionListener<T, U> of(final String filename, | |
187 | final GenerationFunction<T, U> evolutionContextSupplier, | |
188 | final Iterable<? extends ColumnExtractor<T, U>> columnExtractors) { | |
189 |
1
1. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::<init> → NO_COVERAGE |
var csvEvolutionListenerBuilder = new CSVEvolutionListener.Builder<T, U>(); |
190 | ||
191 |
2
1. of : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filename with receiver → NO_COVERAGE 2. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filename → NO_COVERAGE |
csvEvolutionListenerBuilder.filename(filename) |
192 |
2
1. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::evolutionContextSupplier → NO_COVERAGE 2. of : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::evolutionContextSupplier with receiver → NO_COVERAGE |
.evolutionContextSupplier(evolutionContextSupplier) |
193 |
2
1. of : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::addAllColumnExtractors with receiver → NO_COVERAGE 2. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::addAllColumnExtractors → NO_COVERAGE |
.addAllColumnExtractors(columnExtractors); |
194 | ||
195 |
2
1. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::build → NO_COVERAGE 2. of : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::of → NO_COVERAGE |
return csvEvolutionListenerBuilder.build(); |
196 | } | |
197 | ||
198 | public static <T extends Comparable<T>, U> CSVEvolutionListener<T, U> of(final String filename, | |
199 | final GenerationFunction<T, U> evolutionContextSupplier, | |
200 | final Iterable<? extends ColumnExtractor<T, U>> columnExtractors, final int skipN) { | |
201 |
1
1. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::<init> → NO_COVERAGE |
var csvEvolutionListenerBuilder = new CSVEvolutionListener.Builder<T, U>(); |
202 | ||
203 |
2
1. of : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filename with receiver → NO_COVERAGE 2. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filename → NO_COVERAGE |
csvEvolutionListenerBuilder.filename(filename) |
204 |
2
1. of : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::evolutionContextSupplier with receiver → NO_COVERAGE 2. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::evolutionContextSupplier → NO_COVERAGE |
.evolutionContextSupplier(evolutionContextSupplier) |
205 |
2
1. of : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::addAllColumnExtractors with receiver → NO_COVERAGE 2. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::addAllColumnExtractors → NO_COVERAGE |
.addAllColumnExtractors(columnExtractors) |
206 |
2
1. of : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::skipN with receiver → NO_COVERAGE 2. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::skipN → NO_COVERAGE |
.skipN(skipN); |
207 | ||
208 |
2
1. of : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::build → NO_COVERAGE 2. of : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::of → NO_COVERAGE |
return csvEvolutionListenerBuilder.build(); |
209 | } | |
210 | ||
211 | public static <T extends Comparable<T>, U> CSVEvolutionListener<T, U> ofTopN(final String filename, | |
212 | final GenerationFunction<T, U> evolutionContextSupplier, | |
213 | final Iterable<? extends ColumnExtractor<T, U>> columnExtractors, final Comparator<T> comparator, | |
214 | final int topN) { | |
215 |
1
1. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::<init> → NO_COVERAGE |
var csvEvolutionListenerBuilder = new CSVEvolutionListener.Builder<T, U>(); |
216 | ||
217 |
2
1. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filename → NO_COVERAGE 2. ofTopN : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filename with receiver → NO_COVERAGE |
csvEvolutionListenerBuilder.filename(filename) |
218 |
2
1. ofTopN : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::evolutionContextSupplier with receiver → NO_COVERAGE 2. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::evolutionContextSupplier → NO_COVERAGE |
.evolutionContextSupplier(evolutionContextSupplier) |
219 |
2
1. ofTopN : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::addAllColumnExtractors with receiver → NO_COVERAGE 2. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::addAllColumnExtractors → NO_COVERAGE |
.addAllColumnExtractors(columnExtractors) |
220 |
11
1. lambda$ofTopN$7 : replaced call to java/util/Comparator::reversed with receiver → NO_COVERAGE 2. lambda$ofTopN$8 : replaced return value with Stream.empty for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::lambda$ofTopN$8 → NO_COVERAGE 3. lambda$ofTopN$8 : removed call to java/util/stream/Stream::sorted → NO_COVERAGE 4. ofTopN : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filter with receiver → NO_COVERAGE 5. lambda$ofTopN$7 : removed call to java/util/Comparator::reversed → NO_COVERAGE 6. lambda$ofTopN$7 : replaced int return with 0 for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::lambda$ofTopN$7 → NO_COVERAGE 7. lambda$ofTopN$7 : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/EvolutionStep::fitness → NO_COVERAGE 8. lambda$ofTopN$7 : removed call to java/util/Comparator::compare → NO_COVERAGE 9. lambda$ofTopN$8 : replaced call to java/util/stream/Stream::sorted with receiver → NO_COVERAGE 10. lambda$ofTopN$7 : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/EvolutionStep::fitness → NO_COVERAGE 11. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filter → NO_COVERAGE |
.filter(stream -> stream.sorted((a, b) -> comparator.reversed().compare(a.fitness(), b.fitness())) |
221 |
2
1. lambda$ofTopN$8 : replaced call to java/util/stream/Stream::limit with receiver → NO_COVERAGE 2. lambda$ofTopN$8 : removed call to java/util/stream/Stream::limit → NO_COVERAGE |
.limit(topN)); |
222 | ||
223 |
2
1. ofTopN : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::ofTopN → NO_COVERAGE 2. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::build → NO_COVERAGE |
return csvEvolutionListenerBuilder.build(); |
224 | } | |
225 | ||
226 | public static <T extends Comparable<T>, U> CSVEvolutionListener<T, U> ofTopN(final String filename, | |
227 | final GenerationFunction<T, U> evolutionContextSupplier, | |
228 | final Iterable<? extends ColumnExtractor<T, U>> columnExtractors, final int topN) { | |
229 |
1
1. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::<init> → NO_COVERAGE |
var csvEvolutionListenerBuilder = new CSVEvolutionListener.Builder<T, U>(); |
230 | ||
231 |
2
1. ofTopN : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filename with receiver → NO_COVERAGE 2. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filename → NO_COVERAGE |
csvEvolutionListenerBuilder.filename(filename) |
232 |
2
1. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::evolutionContextSupplier → NO_COVERAGE 2. ofTopN : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::evolutionContextSupplier with receiver → NO_COVERAGE |
.evolutionContextSupplier(evolutionContextSupplier) |
233 |
2
1. ofTopN : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::addAllColumnExtractors with receiver → NO_COVERAGE 2. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::addAllColumnExtractors → NO_COVERAGE |
.addAllColumnExtractors(columnExtractors) |
234 |
8
1. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filter → NO_COVERAGE 2. lambda$ofTopN$9 : removed call to java/util/stream/Stream::limit → NO_COVERAGE 3. lambda$ofTopN$9 : replaced call to java/util/stream/Stream::limit with receiver → NO_COVERAGE 4. lambda$ofTopN$9 : replaced call to java/util/stream/Stream::sorted with receiver → NO_COVERAGE 5. lambda$ofTopN$9 : removed call to java/util/Comparator::comparing → NO_COVERAGE 6. lambda$ofTopN$9 : removed call to java/util/stream/Stream::sorted → NO_COVERAGE 7. lambda$ofTopN$9 : replaced return value with Stream.empty for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::lambda$ofTopN$9 → NO_COVERAGE 8. ofTopN : replaced call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::filter with receiver → NO_COVERAGE |
.filter(stream -> stream.sorted(Comparator.comparing(EvolutionStep::fitness)).limit(topN)); |
235 | ||
236 |
2
1. ofTopN : replaced return value with null for net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener::ofTopN → NO_COVERAGE 2. ofTopN : removed call to net/bmahe/genetics4j/extras/evolutionlisteners/CSVEvolutionListener$Builder::build → NO_COVERAGE |
return csvEvolutionListenerBuilder.build(); |
237 | } | |
238 | } | |
Mutations | ||
42 |
1.1 2.2 |
|
43 |
1.1 2.2 3.3 4.4 |
|
44 |
1.1 2.2 |
|
47 |
1.1 2.2 3.3 4.4 |
|
48 |
1.1 2.2 3.3 4.4 5.5 |
|
49 |
1.1 2.2 3.3 4.4 |
|
52 |
1.1 2.2 |
|
65 |
1.1 2.2 |
|
76 |
1.1 |
|
87 |
1.1 |
|
98 |
1.1 2.2 |
|
127 |
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 14.14 |
|
131 |
1.1 2.2 3.3 |
|
132 |
1.1 2.2 |
|
136 |
1.1 2.2 3.3 |
|
138 |
1.1 2.2 3.3 |
|
139 |
1.1 |
|
140 |
1.1 2.2 3.3 4.4 |
|
142 |
1.1 |
|
143 |
1.1 2.2 |
|
144 |
1.1 2.2 |
|
147 |
1.1 2.2 3.3 |
|
149 |
1.1 |
|
150 |
1.1 2.2 |
|
151 |
1.1 2.2 3.3 4.4 |
|
152 |
1.1 2.2 3.3 4.4 |
|
153 |
1.1 2.2 |
|
156 |
1.1 |
|
159 |
1.1 2.2 |
|
163 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
165 |
1.1 2.2 |
|
168 |
1.1 2.2 |
|
178 |
1.1 2.2 |
|
183 |
1.1 2.2 |
|
189 |
1.1 |
|
191 |
1.1 2.2 |
|
192 |
1.1 2.2 |
|
193 |
1.1 2.2 |
|
195 |
1.1 2.2 |
|
201 |
1.1 |
|
203 |
1.1 2.2 |
|
204 |
1.1 2.2 |
|
205 |
1.1 2.2 |
|
206 |
1.1 2.2 |
|
208 |
1.1 2.2 |
|
215 |
1.1 |
|
217 |
1.1 2.2 |
|
218 |
1.1 2.2 |
|
219 |
1.1 2.2 |
|
220 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 |
|
221 |
1.1 2.2 |
|
223 |
1.1 2.2 |
|
229 |
1.1 |
|
231 |
1.1 2.2 |
|
232 |
1.1 2.2 |
|
233 |
1.1 2.2 |
|
234 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
236 |
1.1 2.2 |