|
1
|
|
package net.bmahe.genetics4j.core.mutation; |
|
2
|
|
|
|
3
|
|
import java.util.List; |
|
4
|
|
import java.util.Objects; |
|
5
|
|
import java.util.random.RandomGenerator; |
|
6
|
|
import java.util.stream.Collectors; |
|
7
|
|
|
|
8
|
|
import org.apache.commons.lang3.Validate; |
|
9
|
|
|
|
10
|
|
import net.bmahe.genetics4j.core.Genotype; |
|
11
|
|
import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; |
|
12
|
|
import net.bmahe.genetics4j.core.spec.AbstractEAExecutionContext; |
|
13
|
|
import net.bmahe.genetics4j.core.spec.mutation.MultiMutations; |
|
14
|
|
import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy; |
|
15
|
|
|
|
16
|
|
public class MultiMutationsPolicyHandler<T extends Comparable<T>> implements MutationPolicyHandler<T> { |
|
17
|
|
|
|
18
|
|
private final RandomGenerator randomGenerator; |
|
19
|
|
|
|
20
|
|
public MultiMutationsPolicyHandler(final RandomGenerator _randomGenerator) { |
|
21
|
|
Objects.requireNonNull(_randomGenerator); |
|
22
|
|
|
|
23
|
1
1. <init> : Removed assignment to member variable randomGenerator → SURVIVED
|
this.randomGenerator = _randomGenerator; |
|
24
|
|
} |
|
25
|
|
|
|
26
|
|
@Override |
|
27
|
|
public boolean canHandle(final MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, |
|
28
|
|
final MutationPolicy mutationPolicy) { |
|
29
|
|
Objects.requireNonNull(mutationPolicyHandlerResolver); |
|
30
|
|
Objects.requireNonNull(mutationPolicy); |
|
31
|
|
|
|
32
|
3
1. canHandle : removed conditional - replaced equality check with false → SURVIVED
2. canHandle : removed conditional - replaced equality check with true → KILLED
3. canHandle : negated conditional → KILLED
|
if (mutationPolicy instanceof MultiMutations == false) { |
|
33
|
2
1. canHandle : Substituted 0 with 1 → NO_COVERAGE
2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → NO_COVERAGE
|
return false; |
|
34
|
|
} |
|
35
|
|
|
|
36
|
|
final MultiMutations multiMutations = (MultiMutations) mutationPolicy; |
|
37
|
|
|
|
38
|
3
1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → SURVIVED
2. canHandle : removed call to net/bmahe/genetics4j/core/spec/mutation/MultiMutations::mutationPolicies → KILLED
3. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → KILLED
|
return multiMutations.mutationPolicies() |
|
39
|
1
1. canHandle : removed call to java/util/List::stream → KILLED
|
.stream() |
|
40
|
4
1. lambda$canHandle$0 : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$canHandle$0 → SURVIVED
2. lambda$canHandle$0 : removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandlerResolver::canHandle → KILLED
3. lambda$canHandle$0 : replaced boolean return with false for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$canHandle$0 → KILLED
4. canHandle : removed call to java/util/stream/Stream::allMatch → KILLED
|
.allMatch((mp) -> mutationPolicyHandlerResolver.canHandle(mp)); |
|
41
|
|
} |
|
42
|
|
|
|
43
|
|
@Override |
|
44
|
|
public Mutator createMutator(final AbstractEAExecutionContext<T> eaExecutionContext, |
|
45
|
|
final AbstractEAConfiguration<T> eaConfiguration, |
|
46
|
|
final MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, final MutationPolicy mutationPolicy) { |
|
47
|
|
Objects.requireNonNull(eaExecutionContext); |
|
48
|
|
Objects.requireNonNull(eaConfiguration); |
|
49
|
|
Objects.requireNonNull(mutationPolicyHandlerResolver); |
|
50
|
|
Objects.requireNonNull(mutationPolicy); |
|
51
|
|
Validate.isInstanceOf(MultiMutations.class, mutationPolicy); |
|
52
|
|
|
|
53
|
|
final MultiMutations multiMutations = (MultiMutations) mutationPolicy; |
|
54
|
|
|
|
55
|
1
1. createMutator : removed call to net/bmahe/genetics4j/core/spec/mutation/MultiMutations::mutationPolicies → KILLED
|
final List<Mutator> mutators = multiMutations.mutationPolicies() |
|
56
|
1
1. createMutator : removed call to java/util/List::stream → KILLED
|
.stream() |
|
57
|
2
1. createMutator : replaced call to java/util/stream/Stream::map with receiver → SURVIVED
2. createMutator : removed call to java/util/stream/Stream::map → KILLED
|
.map((mp) -> { |
|
58
|
|
|
|
59
|
1
1. lambda$createMutator$1 : removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandlerResolver::resolve → KILLED
|
final MutationPolicyHandler<T> mutationPolicyHandler = mutationPolicyHandlerResolver.resolve(mp); |
|
60
|
|
|
|
61
|
1
1. lambda$createMutator$1 : replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$createMutator$1 → SURVIVED
|
return mutationPolicyHandler |
|
62
|
1
1. lambda$createMutator$1 : removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandler::createMutator → SURVIVED
|
.createMutator(eaExecutionContext, eaConfiguration, mutationPolicyHandlerResolver, mp); |
|
63
|
|
}) |
|
64
|
2
1. createMutator : removed call to java/util/stream/Stream::collect → SURVIVED
2. createMutator : removed call to java/util/stream/Collectors::toList → KILLED
|
.collect(Collectors.toList()); |
|
65
|
|
|
|
66
|
4
1. createMutator : removed call to net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler$1::<init> → SURVIVED
2. <init> : Removed assignment to member variable val$mutators → SURVIVED
3. <init> : Removed assignment to member variable this$0 → SURVIVED
4. createMutator : replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::createMutator → SURVIVED
|
return new Mutator() { |
|
67
|
|
|
|
68
|
|
@Override |
|
69
|
|
public Genotype mutate(final long generation, final Genotype original) { |
|
70
|
|
Validate.isTrue(generation >= 0); |
|
71
|
|
Objects.requireNonNull(original); |
|
72
|
|
|
|
73
|
3
1. mutate : removed call to java/util/List::size → NO_COVERAGE
2. mutate : replaced call to java/util/random/RandomGenerator::nextInt with argument → NO_COVERAGE
3. mutate : removed call to java/util/random/RandomGenerator::nextInt → NO_COVERAGE
|
final int selectedMutatorIndex = randomGenerator.nextInt(mutators.size()); |
|
74
|
|
|
|
75
|
2
1. mutate : replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler$1::mutate → NO_COVERAGE
2. mutate : removed call to java/util/List::get → NO_COVERAGE
|
return mutators.get(selectedMutatorIndex) |
|
76
|
2
1. mutate : replaced call to net/bmahe/genetics4j/core/mutation/Mutator::mutate with argument → NO_COVERAGE
2. mutate : removed call to net/bmahe/genetics4j/core/mutation/Mutator::mutate → NO_COVERAGE
|
.mutate(generation, original); |
|
77
|
|
} |
|
78
|
|
}; |
|
79
|
|
} |
|
80
|
|
} |
| | Mutations |
| 23 |
|
1.1 Location : <init> Killed by : none Removed assignment to member variable randomGenerator → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:ctorNoSurvivorSelector()]
- net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:ctorNoOffspringSelector()]
- net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:ctorNoElitismSpec()]
- net.bmahe.genetics4j.core.selection.TournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.TournamentSelectionPolicyHandlerTest]/[method:selectMaximize()]
- net.bmahe.genetics4j.core.selection.RouletteWheelSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.RouletteWheelSelectionPolicyHandlerTest]/[method:selectMaximizing()]
- net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
- net.bmahe.genetics4j.core.selection.RandomSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.RandomSelectionPolicyHandlerTest]/[method:select()]
- net.bmahe.genetics4j.core.selection.TournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.TournamentSelectionPolicyHandlerTest]/[method:selectMinimize()]
- net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:atLeastSpecified()]
- net.bmahe.genetics4j.core.selection.MultiTournamentsSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiTournamentsSelectionPolicyHandlerTest]/[method:selectMaxThenMin()]
- net.bmahe.genetics4j.core.selection.RouletteWheelSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.RouletteWheelSelectionPolicyHandlerTest]/[method:selectMinimizing()]
- net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()]
- net.bmahe.genetics4j.core.selection.ProportionalTournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.ProportionalTournamentSelectionPolicyHandlerTest]/[method:selectMinimize()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testSystemConstruction()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testGetterMethods()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvaluateOnceWithDifferentGenerations()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvaluateOnce()]
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
- net.bmahe.genetics4j.core.selection.ProportionalTournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.ProportionalTournamentSelectionPolicyHandlerTest]/[method:selectMaximize()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithBitChromosome()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithImmediateTermination()]
|
| 32 |
|
1.1 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] removed conditional - replaced equality check with true → KILLED
2.2 Location : canHandle Killed by : none removed conditional - replaced equality check with false → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
3.3 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] negated conditional → KILLED
|
| 33 |
|
1.1 Location : canHandle Killed by : none Substituted 0 with 1 → NO_COVERAGE
2.2 Location : canHandle Killed by : none replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → NO_COVERAGE
|
| 38 |
|
1.1 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] removed call to net/bmahe/genetics4j/core/spec/mutation/MultiMutations::mutationPolicies → KILLED
2.2 Location : canHandle Killed by : none replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
3.3 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] replaced boolean return with false for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::canHandle → KILLED
|
| 39 |
|
1.1 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] removed call to java/util/List::stream → KILLED
|
| 40 |
|
1.1 Location : lambda$canHandle$0 Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandlerResolver::canHandle → KILLED
2.2 Location : lambda$canHandle$0 Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] replaced boolean return with false for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$canHandle$0 → KILLED
3.3 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] removed call to java/util/stream/Stream::allMatch → KILLED
4.4 Location : lambda$canHandle$0 Killed by : none replaced boolean return with true for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$canHandle$0 → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
|
| 55 |
|
1.1 Location : createMutator Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] removed call to net/bmahe/genetics4j/core/spec/mutation/MultiMutations::mutationPolicies → KILLED
|
| 56 |
|
1.1 Location : createMutator Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] removed call to java/util/List::stream → KILLED
|
| 57 |
|
1.1 Location : createMutator Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] removed call to java/util/stream/Stream::map → KILLED
2.2 Location : createMutator Killed by : none replaced call to java/util/stream/Stream::map with receiver → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
|
| 59 |
|
1.1 Location : lambda$createMutator$1 Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandlerResolver::resolve → KILLED
|
| 61 |
|
1.1 Location : lambda$createMutator$1 Killed by : none replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::lambda$createMutator$1 → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
|
| 62 |
|
1.1 Location : lambda$createMutator$1 Killed by : none removed call to net/bmahe/genetics4j/core/mutation/MutationPolicyHandler::createMutator → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
|
| 64 |
|
1.1 Location : createMutator Killed by : none removed call to java/util/stream/Stream::collect → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
2.2 Location : createMutator Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] removed call to java/util/stream/Collectors::toList → KILLED
|
| 66 |
|
1.1 Location : createMutator Killed by : none removed call to net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler$1::<init> → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
2.2 Location : <init> Killed by : none Removed assignment to member variable val$mutators → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
3.3 Location : <init> Killed by : none Removed assignment to member variable this$0 → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
4.4 Location : createMutator Killed by : none replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler::createMutator → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
|
| 73 |
|
1.1 Location : mutate Killed by : none removed call to java/util/List::size → NO_COVERAGE
2.2 Location : mutate Killed by : none replaced call to java/util/random/RandomGenerator::nextInt with argument → NO_COVERAGE
3.3 Location : mutate Killed by : none removed call to java/util/random/RandomGenerator::nextInt → NO_COVERAGE
|
| 75 |
|
1.1 Location : mutate Killed by : none replaced return value with null for net/bmahe/genetics4j/core/mutation/MultiMutationsPolicyHandler$1::mutate → NO_COVERAGE
2.2 Location : mutate Killed by : none removed call to java/util/List::get → NO_COVERAGE
|
| 76 |
|
1.1 Location : mutate Killed by : none replaced call to net/bmahe/genetics4j/core/mutation/Mutator::mutate with argument → NO_COVERAGE
2.2 Location : mutate Killed by : none removed call to net/bmahe/genetics4j/core/mutation/Mutator::mutate → NO_COVERAGE
|