|
1
|
|
package net.bmahe.genetics4j.core.mutation; |
|
2
|
|
|
|
3
|
|
import java.util.Objects; |
|
4
|
|
import java.util.random.RandomGenerator; |
|
5
|
|
|
|
6
|
|
import org.apache.commons.lang3.Validate; |
|
7
|
|
|
|
8
|
|
import net.bmahe.genetics4j.core.Genotype; |
|
9
|
|
import net.bmahe.genetics4j.core.spec.mutation.RepeatedMutation; |
|
10
|
|
|
|
11
|
|
/** |
|
12
|
|
* Applies a child mutator repeatedly, passing each mutation result to the next invocation. |
|
13
|
|
*/ |
|
14
|
|
public class RepeatedMutator implements Mutator { |
|
15
|
|
|
|
16
|
|
private final RandomGenerator randomGenerator; |
|
17
|
|
private final RepeatedMutation repeatedMutation; |
|
18
|
|
private final Mutator childMutator; |
|
19
|
|
|
|
20
|
|
public RepeatedMutator(final RandomGenerator _randomGenerator, |
|
21
|
|
final RepeatedMutation _repeatedMutation, |
|
22
|
|
final Mutator _childMutator) { |
|
23
|
|
this.randomGenerator = Objects.requireNonNull(_randomGenerator); |
|
24
|
|
this.repeatedMutation = Objects.requireNonNull(_repeatedMutation); |
|
25
|
|
this.childMutator = Objects.requireNonNull(_childMutator); |
|
26
|
|
} |
|
27
|
|
|
|
28
|
|
@Override |
|
29
|
|
public Genotype mutate(final long generation, final Genotype original) { |
|
30
|
|
Validate.isTrue(generation >= 0); |
|
31
|
|
Objects.requireNonNull(original); |
|
32
|
|
|
|
33
|
1
1. mutate : removed call to net/bmahe/genetics4j/core/mutation/RepeatedMutator::numberOfRepetitions → KILLED
|
final int numRepetitions = numberOfRepetitions(); |
|
34
|
|
Genotype mutated = original; |
|
35
|
5
1. mutate : removed conditional - replaced comparison check with true → TIMED_OUT
2. mutate : removed conditional - replaced comparison check with false → KILLED
3. mutate : Substituted 0 with 1 → KILLED
4. mutate : changed conditional boundary → KILLED
5. mutate : negated conditional → KILLED
|
for (int i = 0; i < numRepetitions; i++) { |
|
36
|
2
1. mutate : removed call to net/bmahe/genetics4j/core/mutation/Mutator::mutate → KILLED
2. mutate : replaced call to net/bmahe/genetics4j/core/mutation/Mutator::mutate with argument → KILLED
|
mutated = childMutator.mutate(generation, mutated); |
|
37
|
|
} |
|
38
|
|
|
|
39
|
1
1. mutate : replaced return value with null for net/bmahe/genetics4j/core/mutation/RepeatedMutator::mutate → KILLED
|
return mutated; |
|
40
|
|
} |
|
41
|
|
|
|
42
|
|
private int numberOfRepetitions() { |
|
43
|
1
1. numberOfRepetitions : removed call to net/bmahe/genetics4j/core/spec/mutation/RepeatedMutation::minRepetitions → KILLED
|
final int minRepetitions = repeatedMutation.minRepetitions(); |
|
44
|
1
1. numberOfRepetitions : removed call to net/bmahe/genetics4j/core/spec/mutation/RepeatedMutation::maxRepetitions → KILLED
|
final int maxRepetitions = repeatedMutation.maxRepetitions(); |
|
45
|
3
1. numberOfRepetitions : negated conditional → KILLED
2. numberOfRepetitions : removed conditional - replaced equality check with true → KILLED
3. numberOfRepetitions : removed conditional - replaced equality check with false → KILLED
|
if (minRepetitions == maxRepetitions) { |
|
46
|
1
1. numberOfRepetitions : replaced int return with 0 for net/bmahe/genetics4j/core/mutation/RepeatedMutator::numberOfRepetitions → KILLED
|
return minRepetitions; |
|
47
|
|
} |
|
48
|
|
|
|
49
|
5
1. numberOfRepetitions : Replaced long addition with subtraction → KILLED
2. numberOfRepetitions : removed call to java/util/random/RandomGenerator::nextLong → KILLED
3. numberOfRepetitions : replaced int return with 0 for net/bmahe/genetics4j/core/mutation/RepeatedMutator::numberOfRepetitions → KILLED
4. numberOfRepetitions : replaced call to java/util/random/RandomGenerator::nextLong with argument → KILLED
5. numberOfRepetitions : Substituted 1 with 2 → KILLED
|
return (int) randomGenerator.nextLong(minRepetitions, (long) maxRepetitions + 1L); |
|
50
|
|
} |
|
51
|
|
} |
| | Mutations |
| 33 |
|
1.1 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] removed call to net/bmahe/genetics4j/core/mutation/RepeatedMutator::numberOfRepetitions → KILLED
|
| 35 |
|
1.1 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] removed conditional - replaced comparison check with false → KILLED
2.2 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] Substituted 0 with 1 → KILLED
3.3 Location : mutate Killed by : none removed conditional - replaced comparison check with true → TIMED_OUT
4.4 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] changed conditional boundary → KILLED
5.5 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] negated conditional → KILLED
|
| 36 |
|
1.1 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] removed call to net/bmahe/genetics4j/core/mutation/Mutator::mutate → KILLED
2.2 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] replaced call to net/bmahe/genetics4j/core/mutation/Mutator::mutate with argument → KILLED
|
| 39 |
|
1.1 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] replaced return value with null for net/bmahe/genetics4j/core/mutation/RepeatedMutator::mutate → KILLED
|
| 43 |
|
1.1 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] removed call to net/bmahe/genetics4j/core/spec/mutation/RepeatedMutation::minRepetitions → KILLED
|
| 44 |
|
1.1 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] removed call to net/bmahe/genetics4j/core/spec/mutation/RepeatedMutation::maxRepetitions → KILLED
|
| 45 |
|
1.1 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] negated conditional → KILLED
2.2 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] removed conditional - replaced equality check with true → KILLED
3.3 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:fixedRepetitionsAreChainedWithoutRandomSampling()] removed conditional - replaced equality check with false → KILLED
|
| 46 |
|
1.1 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:fixedRepetitionsAreChainedWithoutRandomSampling()] replaced int return with 0 for net/bmahe/genetics4j/core/mutation/RepeatedMutator::numberOfRepetitions → KILLED
|
| 49 |
|
1.1 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] Replaced long addition with subtraction → KILLED
2.2 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] removed call to java/util/random/RandomGenerator::nextLong → KILLED
3.3 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] replaced int return with 0 for net/bmahe/genetics4j/core/mutation/RepeatedMutator::numberOfRepetitions → KILLED
4.4 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] replaced call to java/util/random/RandomGenerator::nextLong with argument → KILLED
5.5 Location : numberOfRepetitions Killed by : net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.RepeatedMutatorTest]/[method:variableRepetitionsAreSampledForEveryGenotype()] Substituted 1 with 2 → KILLED
|