| 1 | package net.bmahe.genetics4j.core.spec.mutation; | |
| 2 | ||
| 3 | import org.apache.commons.lang3.Validate; | |
| 4 | import org.immutables.value.Value; | |
| 5 | ||
| 6 | @Value.Immutable | |
| 7 | public abstract class SwapMutation implements MutationPolicy { | |
| 8 | ||
| 9 | @Value.Parameter | |
| 10 | public abstract double populationMutationProbability(); | |
| 11 | ||
| 12 | @Value.Parameter | |
| 13 | public abstract int numSwap(); | |
| 14 | ||
| 15 | @Value.Parameter | |
| 16 | public abstract boolean isNumSwapFixed(); | |
| 17 | ||
| 18 | @Value.Check | |
| 19 | protected void check() { | |
| 20 | Validate.inclusiveBetween(0.0, 1.0, populationMutationProbability()); | |
| 21 | Validate.isTrue(numSwap() > 0); | |
| 22 | } | |
| 23 | ||
| 24 | /** | |
| 25 | * Construct a new immutable {@code SwapMutation} instance. | |
| 26 | * | |
| 27 | * @param populationMutationProbability The value for the {@code populationMutationProbability} attribute | |
| 28 | * @param numSwap The value for the {@code numSwap} attribute | |
| 29 | * @param isNumSwapFixed Whether the number of swap is fixed or taken randomly between 1 and | |
| 30 | * {@code numSwap} | |
| 31 | * @return An immutable SwapMutation instance | |
| 32 | */ | |
| 33 | public static SwapMutation of(double populationMutationProbability, int numSwap, boolean isNumSwapFixed) { | |
| 34 |
2
1. of : replaced return value with null for net/bmahe/genetics4j/core/spec/mutation/SwapMutation::of → KILLED 2. of : removed call to net/bmahe/genetics4j/core/spec/mutation/ImmutableSwapMutation::of → KILLED |
return ImmutableSwapMutation.of(populationMutationProbability, numSwap, isNumSwapFixed); |
| 35 | } | |
| 36 | ||
| 37 | /** | |
| 38 | * Construct a new immutable {@code SwapMutation} instance. | |
| 39 | * | |
| 40 | * @param populationMutationProbability The value for the {@code populationMutationProbability} attribute | |
| 41 | * @param numSwap The value for the {@code numSwap} attribute | |
| 42 | * @return An immutable SwapMutation instance | |
| 43 | */ | |
| 44 | public static SwapMutation ofFixedNumSwap(double populationMutationProbability, int numSwap) { | |
| 45 |
3
1. ofFixedNumSwap : Substituted 1 with 0 → NO_COVERAGE 2. ofFixedNumSwap : replaced return value with null for net/bmahe/genetics4j/core/spec/mutation/SwapMutation::ofFixedNumSwap → NO_COVERAGE 3. ofFixedNumSwap : removed call to net/bmahe/genetics4j/core/spec/mutation/ImmutableSwapMutation::of → NO_COVERAGE |
return ImmutableSwapMutation.of(populationMutationProbability, numSwap, true); |
| 46 | } | |
| 47 | ||
| 48 | } | |
Mutations | ||
| 34 |
1.1 2.2 |
|
| 45 |
1.1 2.2 3.3 |