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