1 | package net.bmahe.genetics4j.core.termination; | |
2 | ||
3 | import java.time.Duration; | |
4 | import java.time.temporal.ChronoUnit; | |
5 | import java.util.Arrays; | |
6 | import java.util.Comparator; | |
7 | import java.util.List; | |
8 | import java.util.Optional; | |
9 | ||
10 | import org.apache.commons.lang3.Validate; | |
11 | ||
12 | import net.bmahe.genetics4j.core.Genotype; | |
13 | import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; | |
14 | ||
15 | /** | |
16 | * Utility class providing factory methods for creating common termination conditions in evolutionary algorithms. | |
17 | * | |
18 | * <p>Terminations provides a comprehensive set of pre-built termination criteria that can be used individually | |
19 | * or combined to create complex stopping conditions for evolutionary algorithms. Each method returns a | |
20 | * {@link Termination} instance that encapsulates the specific logic for determining when evolution should stop. | |
21 | * | |
22 | * <p>Available termination criteria include: | |
23 | * <ul> | |
24 | * <li><strong>Generation-based</strong>: Stop after a maximum number of generations</li> | |
25 | * <li><strong>Time-based</strong>: Stop after a specified duration has elapsed</li> | |
26 | * <li><strong>Fitness-based</strong>: Stop when fitness reaches certain thresholds</li> | |
27 | * <li><strong>Convergence-based</strong>: Stop when fitness stops improving for a period</li> | |
28 | * <li><strong>Logical combinations</strong>: Combine multiple criteria with AND/OR logic</li> | |
29 | * </ul> | |
30 | * | |
31 | * <p>Termination criteria can be combined to create sophisticated stopping conditions: | |
32 | * <pre>{@code | |
33 | * // Stop after 100 generations OR when fitness reaches 0.95 OR after 5 minutes | |
34 | * Termination<Double> complexTermination = Terminations.or( | |
35 | * Terminations.ofMaxGeneration(100), | |
36 | * Terminations.ofFitnessAtLeast(0.95), | |
37 | * Terminations.ofMaxTime(Duration.ofMinutes(5)) | |
38 | * ); | |
39 | * | |
40 | * // Stop only when BOTH conditions are met: good fitness AND stable evolution | |
41 | * Termination<Double> conservativeTermination = Terminations.and( | |
42 | * Terminations.ofFitnessAtLeast(0.9), | |
43 | * Terminations.ofStableFitness(20) | |
44 | * ); | |
45 | * | |
46 | * // Simple generation limit for quick experiments | |
47 | * Termination<Double> simpleTermination = Terminations.ofMaxGeneration(50); | |
48 | * }</pre> | |
49 | * | |
50 | * <p>Common usage patterns: | |
51 | * <ul> | |
52 | * <li><strong>Development and testing</strong>: Use generation limits for quick experimentation</li> | |
53 | * <li><strong>Production systems</strong>: Combine time limits with fitness criteria for reliability</li> | |
54 | * <li><strong>Research applications</strong>: Use convergence detection to study algorithm behavior</li> | |
55 | * <li><strong>Resource-constrained environments</strong>: Use time-based limits for predictable execution</li> | |
56 | * </ul> | |
57 | * | |
58 | * <p>Design considerations: | |
59 | * <ul> | |
60 | * <li><strong>Performance</strong>: Termination checks are called frequently; implementations are optimized</li> | |
61 | * <li><strong>Thread safety</strong>: Some termination criteria maintain internal state safely</li> | |
62 | * <li><strong>Flexibility</strong>: All criteria can be combined using logical operators</li> | |
63 | * <li><strong>Reliability</strong>: Include fallback termination criteria to prevent infinite loops</li> | |
64 | * </ul> | |
65 | * | |
66 | * @see Termination | |
67 | * @see net.bmahe.genetics4j.core.EASystem | |
68 | * @see net.bmahe.genetics4j.core.spec.EAExecutionContext | |
69 | */ | |
70 | public class Terminations { | |
71 | ||
72 | /** | |
73 | * Creates a termination condition that stops evolution after a specified number of generations. | |
74 | * | |
75 | * <p>This is the most common termination criterion, providing a simple upper bound on the | |
76 | * number of evolutionary cycles. The algorithm will terminate when the generation counter | |
77 | * reaches or exceeds the specified maximum. | |
78 | * | |
79 | * @param <T> the type of fitness values in the evolutionary algorithm | |
80 | * @param maxGeneration the maximum number of generations to run (must be positive) | |
81 | * @return a termination condition that stops after the specified number of generations | |
82 | * @throws IllegalArgumentException if maxGeneration is not positive | |
83 | */ | |
84 | public static <T extends Comparable<T>> Termination<T> ofMaxGeneration(final long maxGeneration) { | |
85 | Validate.isTrue(maxGeneration > 0); | |
86 | ||
87 |
3
1. ofMaxGeneration : replaced return value with null for net/bmahe/genetics4j/core/termination/Terminations::ofMaxGeneration → KILLED 2. ofMaxGeneration : removed call to net/bmahe/genetics4j/core/termination/Terminations$1::<init> → KILLED 3. <init> : Removed assignment to member variable val$maxGeneration → KILLED |
return new Termination<T>() { |
88 | ||
89 | @Override | |
90 | public boolean isDone(final AbstractEAConfiguration<T> eaConfiguration, final long generation, | |
91 | final List<Genotype> population, final List<T> fitness) { | |
92 | Validate.isTrue(generation >= 0); | |
93 | ||
94 |
7
1. isDone : Substituted 1 with 0 → KILLED 2. isDone : changed conditional boundary → KILLED 3. isDone : negated conditional → KILLED 4. isDone : Substituted 0 with 1 → KILLED 5. isDone : removed conditional - replaced comparison check with true → KILLED 6. isDone : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$1::isDone → KILLED 7. isDone : removed conditional - replaced comparison check with false → KILLED |
return generation >= maxGeneration; |
95 | } | |
96 | }; | |
97 | } | |
98 | ||
99 | /** | |
100 | * Creates a termination condition that stops evolution after a specified time duration. | |
101 | * | |
102 | * <p>This time-based termination is useful for ensuring predictable execution times, | |
103 | * especially in production environments or when computational resources are limited. | |
104 | * The timer starts on the first evaluation and stops when the elapsed time exceeds | |
105 | * the specified duration. | |
106 | * | |
107 | * @param <T> the type of fitness values in the evolutionary algorithm | |
108 | * @param duration the maximum time to run the algorithm | |
109 | * @return a termination condition that stops after the specified duration | |
110 | * @throws IllegalArgumentException if duration is null | |
111 | */ | |
112 | public static <T extends Comparable<T>> Termination<T> ofMaxTime(final Duration duration) { | |
113 | Validate.notNull(duration); | |
114 | ||
115 |
3
1. <init> : Removed assignment to member variable val$duration → NO_COVERAGE 2. ofMaxTime : replaced return value with null for net/bmahe/genetics4j/core/termination/Terminations::ofMaxTime → NO_COVERAGE 3. ofMaxTime : removed call to net/bmahe/genetics4j/core/termination/Terminations$2::<init> → NO_COVERAGE |
return new Termination<T>() { |
116 | ||
117 |
2
1. <init> : Removed assignment to member variable durationNanos → NO_COVERAGE 2. <init> : removed call to java/time/Duration::get → NO_COVERAGE |
private final long durationNanos = duration.get(ChronoUnit.NANOS); |
118 |
1
1. <init> : Removed assignment to member variable startTime → NO_COVERAGE |
private Long startTime = null; |
119 | ||
120 | @Override | |
121 | public boolean isDone(final AbstractEAConfiguration<T> eaConfiguration, final long generation, | |
122 | final List<Genotype> population, final List<T> fitness) { | |
123 | Validate.isTrue(generation >= 0); | |
124 | ||
125 |
1
1. isDone : removed call to java/lang/System::nanoTime → NO_COVERAGE |
final long nowNanos = System.nanoTime(); |
126 | ||
127 |
3
1. isDone : negated conditional → NO_COVERAGE 2. isDone : removed conditional - replaced equality check with false → NO_COVERAGE 3. isDone : removed conditional - replaced equality check with true → NO_COVERAGE |
if (startTime == null) { |
128 |
2
1. isDone : Removed assignment to member variable startTime → NO_COVERAGE 2. isDone : removed call to java/lang/Long::valueOf → NO_COVERAGE |
startTime = nowNanos; |
129 | } | |
130 | ||
131 |
9
1. isDone : Substituted 1 with 0 → NO_COVERAGE 2. isDone : removed conditional - replaced comparison check with true → NO_COVERAGE 3. isDone : negated conditional → NO_COVERAGE 4. isDone : changed conditional boundary → NO_COVERAGE 5. isDone : Substituted 0 with 1 → NO_COVERAGE 6. isDone : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$2::isDone → NO_COVERAGE 7. isDone : removed call to java/lang/Long::longValue → NO_COVERAGE 8. isDone : Replaced long subtraction with addition → NO_COVERAGE 9. isDone : removed conditional - replaced comparison check with false → NO_COVERAGE |
return nowNanos - startTime >= durationNanos; |
132 | } | |
133 | }; | |
134 | } | |
135 | ||
136 | /** | |
137 | * Creates a termination condition that requires ALL specified conditions to be met. | |
138 | * | |
139 | * <p>This logical AND operation creates a conservative termination strategy where | |
140 | * evolution continues until every provided termination criterion is satisfied. | |
141 | * Useful for ensuring multiple quality conditions are met before stopping. | |
142 | * | |
143 | * @param <T> the type of fitness values in the evolutionary algorithm | |
144 | * @param terminations the termination conditions that must all be satisfied | |
145 | * @return a termination condition that stops only when all conditions are met | |
146 | * @throws IllegalArgumentException if terminations is null or empty | |
147 | */ | |
148 | @SafeVarargs | |
149 | public static <T extends Comparable<T>> Termination<T> and(final Termination<T>... terminations) { | |
150 | Validate.notNull(terminations); | |
151 | Validate.isTrue(terminations.length > 0); | |
152 | ||
153 |
3
1. <init> : Removed assignment to member variable val$terminations → NO_COVERAGE 2. and : removed call to net/bmahe/genetics4j/core/termination/Terminations$3::<init> → NO_COVERAGE 3. and : replaced return value with null for net/bmahe/genetics4j/core/termination/Terminations::and → NO_COVERAGE |
return new Termination<T>() { |
154 | ||
155 | @Override | |
156 | public boolean isDone(final AbstractEAConfiguration<T> eaConfiguration, final long generation, | |
157 | final List<Genotype> population, final List<T> fitness) { | |
158 |
3
1. isDone : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$3::isDone → NO_COVERAGE 2. isDone : removed call to java/util/Arrays::stream → NO_COVERAGE 3. isDone : replaced boolean return with false for net/bmahe/genetics4j/core/termination/Terminations$3::isDone → NO_COVERAGE |
return Arrays.stream(terminations) |
159 |
4
1. isDone : removed call to java/util/stream/Stream::allMatch → NO_COVERAGE 2. lambda$isDone$0 : replaced boolean return with false for net/bmahe/genetics4j/core/termination/Terminations$3::lambda$isDone$0 → NO_COVERAGE 3. lambda$isDone$0 : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$3::lambda$isDone$0 → NO_COVERAGE 4. lambda$isDone$0 : removed call to net/bmahe/genetics4j/core/termination/Termination::isDone → NO_COVERAGE |
.allMatch((termination) -> termination.isDone(eaConfiguration, generation, population, fitness)); |
160 | } | |
161 | ||
162 | }; | |
163 | } | |
164 | ||
165 | /** | |
166 | * Creates a termination condition that stops when ANY of the specified conditions is met. | |
167 | * | |
168 | * <p>This logical OR operation creates a flexible termination strategy where | |
169 | * evolution stops as soon as any one of the provided criteria is satisfied. | |
170 | * Commonly used to provide multiple stopping conditions like time limits, | |
171 | * generation limits, or fitness thresholds. | |
172 | * | |
173 | * @param <T> the type of fitness values in the evolutionary algorithm | |
174 | * @param terminations the termination conditions, any of which can trigger stopping | |
175 | * @return a termination condition that stops when any condition is met | |
176 | * @throws IllegalArgumentException if terminations is null or empty | |
177 | */ | |
178 | @SafeVarargs | |
179 | public static <T extends Comparable<T>> Termination<T> or(final Termination<T>... terminations) { | |
180 | Validate.notNull(terminations); | |
181 | Validate.isTrue(terminations.length > 0); | |
182 | ||
183 |
3
1. or : removed call to net/bmahe/genetics4j/core/termination/Terminations$4::<init> → NO_COVERAGE 2. or : replaced return value with null for net/bmahe/genetics4j/core/termination/Terminations::or → NO_COVERAGE 3. <init> : Removed assignment to member variable val$terminations → NO_COVERAGE |
return new Termination<T>() { |
184 | ||
185 | @Override | |
186 | public boolean isDone(final AbstractEAConfiguration<T> eaConfiguration, final long generation, | |
187 | final List<Genotype> population, final List<T> fitness) { | |
188 |
3
1. isDone : replaced boolean return with false for net/bmahe/genetics4j/core/termination/Terminations$4::isDone → NO_COVERAGE 2. isDone : removed call to java/util/Arrays::stream → NO_COVERAGE 3. isDone : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$4::isDone → NO_COVERAGE |
return Arrays.stream(terminations) |
189 |
4
1. lambda$isDone$0 : removed call to net/bmahe/genetics4j/core/termination/Termination::isDone → NO_COVERAGE 2. lambda$isDone$0 : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$4::lambda$isDone$0 → NO_COVERAGE 3. isDone : removed call to java/util/stream/Stream::anyMatch → NO_COVERAGE 4. lambda$isDone$0 : replaced boolean return with false for net/bmahe/genetics4j/core/termination/Terminations$4::lambda$isDone$0 → NO_COVERAGE |
.anyMatch((termination) -> termination.isDone(eaConfiguration, generation, population, fitness)); |
190 | } | |
191 | ||
192 | }; | |
193 | } | |
194 | ||
195 | /** | |
196 | * Creates a termination condition that stops when any individual reaches a minimum fitness threshold. | |
197 | * | |
198 | * <p>This fitness-based termination is useful for maximization problems where you want | |
199 | * to stop as soon as a solution of acceptable quality is found. The condition is satisfied | |
200 | * when any individual in the population has a fitness value greater than or equal to the threshold. | |
201 | * | |
202 | * @param <T> the type of fitness values in the evolutionary algorithm | |
203 | * @param threshold the minimum fitness value required to trigger termination | |
204 | * @return a termination condition that stops when fitness reaches the threshold | |
205 | * @throws IllegalArgumentException if threshold is null | |
206 | */ | |
207 | public static <T extends Comparable<T>> Termination<T> ofFitnessAtLeast(final T threshold) { | |
208 | Validate.notNull(threshold); | |
209 |
3
1. ofFitnessAtLeast : removed call to net/bmahe/genetics4j/core/termination/Terminations$5::<init> → NO_COVERAGE 2. ofFitnessAtLeast : replaced return value with null for net/bmahe/genetics4j/core/termination/Terminations::ofFitnessAtLeast → NO_COVERAGE 3. <init> : Removed assignment to member variable val$threshold → NO_COVERAGE |
return new Termination<T>() { |
210 | ||
211 | @Override | |
212 | public boolean isDone(final AbstractEAConfiguration<T> eaConfiguration, final long generation, | |
213 | final List<Genotype> population, final List<T> fitness) { | |
214 | Validate.isTrue(generation >= 0); | |
215 | ||
216 |
3
1. isDone : removed call to java/util/List::stream → NO_COVERAGE 2. isDone : replaced boolean return with false for net/bmahe/genetics4j/core/termination/Terminations$5::isDone → NO_COVERAGE 3. isDone : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$5::isDone → NO_COVERAGE |
return fitness.stream() |
217 |
9
1. lambda$isDone$0 : removed conditional - replaced comparison check with false → NO_COVERAGE 2. lambda$isDone$0 : removed call to java/lang/Comparable::compareTo → NO_COVERAGE 3. lambda$isDone$0 : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$5::lambda$isDone$0 → NO_COVERAGE 4. isDone : removed call to java/util/stream/Stream::anyMatch → NO_COVERAGE 5. lambda$isDone$0 : Substituted 1 with 0 → NO_COVERAGE 6. lambda$isDone$0 : changed conditional boundary → NO_COVERAGE 7. lambda$isDone$0 : removed conditional - replaced comparison check with true → NO_COVERAGE 8. lambda$isDone$0 : negated conditional → NO_COVERAGE 9. lambda$isDone$0 : Substituted 0 with 1 → NO_COVERAGE |
.anyMatch((fitnessValue) -> threshold.compareTo(fitnessValue) <= 0); |
218 | } | |
219 | }; | |
220 | } | |
221 | ||
222 | /** | |
223 | * Creates a termination condition that stops when any individual reaches a maximum fitness threshold. | |
224 | * | |
225 | * <p>This fitness-based termination is useful for minimization problems where you want | |
226 | * to stop as soon as a solution of acceptable quality is found. The condition is satisfied | |
227 | * when any individual in the population has a fitness value less than or equal to the threshold. | |
228 | * | |
229 | * @param <T> the type of fitness values in the evolutionary algorithm | |
230 | * @param threshold the maximum fitness value required to trigger termination | |
231 | * @return a termination condition that stops when fitness reaches the threshold | |
232 | * @throws IllegalArgumentException if threshold is null | |
233 | */ | |
234 | public static <T extends Comparable<T>> Termination<T> ofFitnessAtMost(final T threshold) { | |
235 | Validate.notNull(threshold); | |
236 |
3
1. <init> : Removed assignment to member variable val$threshold → NO_COVERAGE 2. ofFitnessAtMost : replaced return value with null for net/bmahe/genetics4j/core/termination/Terminations::ofFitnessAtMost → NO_COVERAGE 3. ofFitnessAtMost : removed call to net/bmahe/genetics4j/core/termination/Terminations$6::<init> → NO_COVERAGE |
return new Termination<T>() { |
237 | ||
238 | @Override | |
239 | public boolean isDone(final AbstractEAConfiguration<T> eaConfiguration, final long generation, | |
240 | final List<Genotype> population, final List<T> fitness) { | |
241 | Validate.isTrue(generation >= 0); | |
242 | ||
243 |
3
1. isDone : removed call to java/util/List::stream → NO_COVERAGE 2. isDone : replaced boolean return with false for net/bmahe/genetics4j/core/termination/Terminations$6::isDone → NO_COVERAGE 3. isDone : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$6::isDone → NO_COVERAGE |
return fitness.stream() |
244 |
9
1. lambda$isDone$0 : Substituted 0 with 1 → NO_COVERAGE 2. lambda$isDone$0 : removed call to java/lang/Comparable::compareTo → NO_COVERAGE 3. lambda$isDone$0 : removed conditional - replaced comparison check with false → NO_COVERAGE 4. lambda$isDone$0 : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$6::lambda$isDone$0 → NO_COVERAGE 5. isDone : removed call to java/util/stream/Stream::anyMatch → NO_COVERAGE 6. lambda$isDone$0 : changed conditional boundary → NO_COVERAGE 7. lambda$isDone$0 : Substituted 1 with 0 → NO_COVERAGE 8. lambda$isDone$0 : removed conditional - replaced comparison check with true → NO_COVERAGE 9. lambda$isDone$0 : negated conditional → NO_COVERAGE |
.anyMatch((fitnessValue) -> threshold.compareTo(fitnessValue) >= 0); |
245 | } | |
246 | }; | |
247 | } | |
248 | ||
249 | /** | |
250 | * Creates a termination condition that stops when fitness stops improving for a specified number of generations. | |
251 | * | |
252 | * <p>This convergence-based termination detects when the evolutionary algorithm has reached | |
253 | * a stable state where further evolution is unlikely to yield significant improvements. | |
254 | * It tracks the best fitness value and stops evolution if no improvement is observed | |
255 | * for the specified number of consecutive generations. | |
256 | * | |
257 | * <p>This termination criterion is particularly useful for: | |
258 | * <ul> | |
259 | * <li>Preventing unnecessary computation when the algorithm has converged</li> | |
260 | * <li>Automatically adapting to problem difficulty</li> | |
261 | * <li>Research applications studying convergence behavior</li> | |
262 | * </ul> | |
263 | * | |
264 | * @param <T> the type of fitness values in the evolutionary algorithm | |
265 | * @param stableGenerationsCount the number of generations without improvement required to trigger termination | |
266 | * @return a termination condition that stops when fitness plateaus | |
267 | * @throws IllegalArgumentException if stableGenerationsCount is not positive | |
268 | */ | |
269 | public static <T extends Comparable<T>> Termination<T> ofStableFitness(final int stableGenerationsCount) { | |
270 | Validate.isTrue(stableGenerationsCount > 0); | |
271 | ||
272 |
3
1. <init> : Removed assignment to member variable val$stableGenerationsCount → KILLED 2. ofStableFitness : removed call to net/bmahe/genetics4j/core/termination/Terminations$7::<init> → KILLED 3. ofStableFitness : replaced return value with null for net/bmahe/genetics4j/core/termination/Terminations::ofStableFitness → KILLED |
return new Termination<T>() { |
273 | ||
274 |
2
1. <init> : Removed assignment to member variable lastImprovedGeneration → KILLED 2. <init> : Substituted -1 with 0 → KILLED |
private long lastImprovedGeneration = -1; |
275 |
1
1. <init> : Removed assignment to member variable lastBestFitness → SURVIVED |
private T lastBestFitness = null; |
276 | ||
277 | @Override | |
278 | public boolean isDone(final AbstractEAConfiguration<T> eaConfiguration, final long generation, | |
279 | final List<Genotype> population, final List<T> fitness) { | |
280 | Validate.isTrue(generation >= 0); | |
281 | ||
282 |
1
1. isDone : removed call to net/bmahe/genetics4j/core/spec/AbstractEAConfiguration::fitnessComparator → KILLED |
final Comparator<T> fitnessComparator = eaConfiguration.fitnessComparator(); |
283 | ||
284 |
1
1. isDone : removed call to java/util/List::stream → KILLED |
final Optional<T> bestFitnessOpt = fitness.stream() |
285 |
1
1. isDone : removed call to java/util/stream/Stream::max → KILLED |
.max(fitnessComparator); |
286 | ||
287 |
5
1. isDone : changed conditional boundary → KILLED 2. isDone : Substituted 0 with 1 → KILLED 3. isDone : negated conditional → KILLED 4. isDone : removed conditional - replaced comparison check with true → KILLED 5. isDone : removed conditional - replaced comparison check with false → KILLED |
if (lastImprovedGeneration < 0 |
288 |
12
1. isDone : Substituted 0 with 1 → SURVIVED 2. lambda$isDone$0 : negated conditional → KILLED 3. lambda$isDone$0 : removed conditional - replaced comparison check with true → KILLED 4. lambda$isDone$0 : Substituted 0 with 1 → KILLED 5. lambda$isDone$0 : changed conditional boundary → KILLED 6. isDone : replaced call to java/util/Optional::map with receiver → KILLED 7. lambda$isDone$0 : removed call to java/util/Comparator::compare → KILLED 8. lambda$isDone$0 : Substituted 1 with 0 → KILLED 9. isDone : removed call to java/util/Optional::map → KILLED 10. lambda$isDone$0 : removed conditional - replaced comparison check with false → KILLED 11. lambda$isDone$0 : replaced Boolean return with True for net/bmahe/genetics4j/core/termination/Terminations$7::lambda$isDone$0 → KILLED 12. lambda$isDone$0 : removed call to java/lang/Boolean::valueOf → KILLED |
|| bestFitnessOpt.map(bestFitness -> fitnessComparator.compare(bestFitness, lastBestFitness) > 0) |
289 |
7
1. isDone : removed call to java/lang/Boolean::valueOf → SURVIVED 2. isDone : removed conditional - replaced equality check with false → KILLED 3. isDone : removed call to java/lang/Boolean::booleanValue → KILLED 4. isDone : replaced call to java/util/Optional::orElse with argument → KILLED 5. isDone : removed call to java/util/Optional::orElse → KILLED 6. isDone : negated conditional → KILLED 7. isDone : removed conditional - replaced equality check with true → KILLED |
.orElse(false)) { |
290 |
1
1. isDone : Removed assignment to member variable lastImprovedGeneration → KILLED |
lastImprovedGeneration = generation; |
291 |
2
1. isDone : Removed assignment to member variable lastBestFitness → KILLED 2. isDone : removed call to java/util/Optional::get → KILLED |
lastBestFitness = bestFitnessOpt.get(); |
292 | } | |
293 | ||
294 |
5
1. isDone : removed conditional - replaced comparison check with false → KILLED 2. isDone : removed conditional - replaced comparison check with true → KILLED 3. isDone : changed conditional boundary → KILLED 4. isDone : negated conditional → KILLED 5. isDone : Replaced long subtraction with addition → KILLED |
if (generation - lastImprovedGeneration > stableGenerationsCount) { |
295 |
2
1. isDone : replaced boolean return with false for net/bmahe/genetics4j/core/termination/Terminations$7::isDone → KILLED 2. isDone : Substituted 1 with 0 → KILLED |
return true; |
296 | } | |
297 |
2
1. isDone : replaced boolean return with true for net/bmahe/genetics4j/core/termination/Terminations$7::isDone → KILLED 2. isDone : Substituted 0 with 1 → KILLED |
return false; |
298 | } | |
299 | }; | |
300 | } | |
301 | } | |
Mutations | ||
87 |
1.1 2.2 3.3 |
|
94 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
115 |
1.1 2.2 3.3 |
|
117 |
1.1 2.2 |
|
118 |
1.1 |
|
125 |
1.1 |
|
127 |
1.1 2.2 3.3 |
|
128 |
1.1 2.2 |
|
131 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
153 |
1.1 2.2 3.3 |
|
158 |
1.1 2.2 3.3 |
|
159 |
1.1 2.2 3.3 4.4 |
|
183 |
1.1 2.2 3.3 |
|
188 |
1.1 2.2 3.3 |
|
189 |
1.1 2.2 3.3 4.4 |
|
209 |
1.1 2.2 3.3 |
|
216 |
1.1 2.2 3.3 |
|
217 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
236 |
1.1 2.2 3.3 |
|
243 |
1.1 2.2 3.3 |
|
244 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
272 |
1.1 2.2 3.3 |
|
274 |
1.1 2.2 |
|
275 |
1.1 |
|
282 |
1.1 |
|
284 |
1.1 |
|
285 |
1.1 |
|
287 |
1.1 2.2 3.3 4.4 5.5 |
|
288 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 |
|
289 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
290 |
1.1 |
|
291 |
1.1 2.2 |
|
294 |
1.1 2.2 3.3 4.4 5.5 |
|
295 |
1.1 2.2 |
|
297 |
1.1 2.2 |