| 1 | package net.bmahe.genetics4j.core.spec.replacement; | |
| 2 | ||
| 3 | import org.apache.commons.lang3.Validate; | |
| 4 | import org.immutables.value.Value; | |
| 5 | ||
| 6 | import net.bmahe.genetics4j.core.spec.selection.SelectionPolicy; | |
| 7 | ||
| 8 | /** | |
| 9 | * Delete N Last | |
| 10 | * <p>This replacement strategy deletes the N weakest individuals and replace them with the best offsprings | |
| 11 | * | |
| 12 | */ | |
| 13 | @Value.Immutable | |
| 14 | public interface DeleteNLast extends ReplacementStrategy { | |
| 15 | ||
| 16 | static final double DEFAULT_WEAK_RATIO = 0.05; | |
| 17 | ||
| 18 | /** | |
| 19 | * How many weakest individuals to consider for replacement | |
| 20 | * | |
| 21 | * @return | |
| 22 | */ | |
| 23 | @Value.Default | |
| 24 | @Value.Parameter | |
| 25 | default double weakRatio() { | |
| 26 |
2
1. weakRatio : replaced double return with 0.0d for net/bmahe/genetics4j/core/spec/replacement/DeleteNLast::weakRatio → NO_COVERAGE 2. weakRatio : Substituted 0.05 with 1.0 → NO_COVERAGE |
return DEFAULT_WEAK_RATIO; |
| 27 | } | |
| 28 | ||
| 29 | /** | |
| 30 | * Describe which offsprings to select for the next generation | |
| 31 | * | |
| 32 | * @return | |
| 33 | */ | |
| 34 | @Value.Parameter | |
| 35 | public abstract SelectionPolicy offspringSelectionPolicy(); | |
| 36 | ||
| 37 | @Value.Check | |
| 38 | default void check() { | |
| 39 | Validate.inclusiveBetween(0.0, 1.0, weakRatio()); | |
| 40 | } | |
| 41 | ||
| 42 | class Builder extends ImmutableDeleteNLast.Builder { | |
| 43 | } | |
| 44 | ||
| 45 | static Builder builder() { | |
| 46 |
2
1. builder : removed call to net/bmahe/genetics4j/core/spec/replacement/DeleteNLast$Builder::<init> → KILLED 2. builder : replaced return value with null for net/bmahe/genetics4j/core/spec/replacement/DeleteNLast::builder → KILLED |
return new Builder(); |
| 47 | } | |
| 48 | ||
| 49 | static DeleteNLast of(final double weakRatio, final SelectionPolicy selectionPolicy) { | |
| 50 |
7
1. of : removed call to net/bmahe/genetics4j/core/spec/replacement/DeleteNLast$Builder::build → KILLED 2. of : removed call to net/bmahe/genetics4j/core/spec/replacement/DeleteNLast$Builder::offspringSelectionPolicy → KILLED 3. of : replaced call to net/bmahe/genetics4j/core/spec/replacement/DeleteNLast$Builder::weakRatio with receiver → KILLED 4. of : replaced call to net/bmahe/genetics4j/core/spec/replacement/DeleteNLast$Builder::offspringSelectionPolicy with receiver → KILLED 5. of : replaced return value with null for net/bmahe/genetics4j/core/spec/replacement/DeleteNLast::of → KILLED 6. of : removed call to net/bmahe/genetics4j/core/spec/replacement/DeleteNLast$Builder::weakRatio → KILLED 7. of : removed call to net/bmahe/genetics4j/core/spec/replacement/DeleteNLast::builder → KILLED |
return builder().weakRatio(weakRatio).offspringSelectionPolicy(selectionPolicy).build(); |
| 51 | } | |
| 52 | } | |
Mutations | ||
| 26 |
1.1 2.2 |
|
| 46 |
1.1 2.2 |
|
| 50 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |