1
|
|
package net.bmahe.genetics4j.core.combination.multicombinations; |
2
|
|
|
3
|
|
import java.util.List; |
4
|
|
import java.util.random.RandomGenerator; |
5
|
|
import java.util.stream.Collectors; |
6
|
|
|
7
|
|
import org.apache.commons.lang3.Validate; |
8
|
|
|
9
|
|
import net.bmahe.genetics4j.core.combination.ChromosomeCombinator; |
10
|
|
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorHandler; |
11
|
|
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorResolver; |
12
|
|
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec; |
13
|
|
import net.bmahe.genetics4j.core.spec.combination.CombinationPolicy; |
14
|
|
import net.bmahe.genetics4j.core.spec.combination.MultiCombinations; |
15
|
|
|
16
|
|
public class MultiCombinationsHandler<T extends Comparable<T>> implements ChromosomeCombinatorHandler<T> { |
17
|
|
|
18
|
|
private final RandomGenerator randomGenerator; |
19
|
|
|
20
|
|
public MultiCombinationsHandler(final RandomGenerator _randomGenerator) { |
21
|
|
Validate.notNull(_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 ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver, |
28
|
|
final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) { |
29
|
|
Validate.notNull(chromosomeCombinatorResolver); |
30
|
|
Validate.notNull(combinationPolicy); |
31
|
|
Validate.notNull(chromosome); |
32
|
|
|
33
|
|
final boolean isMultiCombinationPolicy = combinationPolicy instanceof MultiCombinations; |
34
|
|
|
35
|
3
1. canHandle : removed conditional - replaced equality check with true → SURVIVED
2. canHandle : negated conditional → KILLED
3. canHandle : removed conditional - replaced equality check with false → KILLED
|
if (isMultiCombinationPolicy == false) { |
36
|
2
1. canHandle : Substituted 0 with 1 → KILLED
2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → KILLED
|
return false; |
37
|
|
} |
38
|
|
|
39
|
|
final MultiCombinations multiCombinations = (MultiCombinations) combinationPolicy; |
40
|
|
|
41
|
3
1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → NO_COVERAGE
2. canHandle : removed call to net/bmahe/genetics4j/core/spec/combination/MultiCombinations::combinationPolicies → NO_COVERAGE
3. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → NO_COVERAGE
|
return multiCombinations.combinationPolicies() |
42
|
1
1. canHandle : removed call to java/util/List::stream → NO_COVERAGE
|
.stream() |
43
|
4
1. canHandle : removed call to java/util/stream/Stream::allMatch → NO_COVERAGE
2. lambda$canHandle$0 : removed call to net/bmahe/genetics4j/core/combination/ChromosomeCombinatorResolver::canHandle → NO_COVERAGE
3. lambda$canHandle$0 : replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$canHandle$0 → NO_COVERAGE
4. lambda$canHandle$0 : replaced boolean return with false for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$canHandle$0 → NO_COVERAGE
|
.allMatch((cp) -> chromosomeCombinatorResolver.canHandle(cp, chromosome)); |
44
|
|
} |
45
|
|
|
46
|
|
@Override |
47
|
|
public ChromosomeCombinator<T> resolve(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver, |
48
|
|
final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) { |
49
|
|
Validate.notNull(chromosomeCombinatorResolver); |
50
|
|
Validate.notNull(combinationPolicy); |
51
|
|
Validate.notNull(chromosome); |
52
|
|
Validate.isInstanceOf(MultiCombinations.class, combinationPolicy); |
53
|
|
|
54
|
|
final MultiCombinations multiCombinations = (MultiCombinations) combinationPolicy; |
55
|
|
|
56
|
1
1. resolve : removed call to net/bmahe/genetics4j/core/spec/combination/MultiCombinations::combinationPolicies → NO_COVERAGE
|
final List<ChromosomeCombinator<T>> chromosomeCombinators = multiCombinations.combinationPolicies() |
57
|
1
1. resolve : removed call to java/util/List::stream → NO_COVERAGE
|
.stream() |
58
|
2
1. resolve : removed call to java/util/stream/Stream::map → NO_COVERAGE
2. resolve : replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE
|
.map((cp) -> { |
59
|
2
1. lambda$resolve$1 : removed call to net/bmahe/genetics4j/core/combination/ChromosomeCombinatorResolver::resolve → NO_COVERAGE
2. lambda$resolve$1 : replaced return value with null for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$resolve$1 → NO_COVERAGE
|
return chromosomeCombinatorResolver.resolve(cp, chromosome); |
60
|
|
}) |
61
|
2
1. resolve : removed call to java/util/stream/Stream::collect → NO_COVERAGE
2. resolve : removed call to java/util/stream/Collectors::toList → NO_COVERAGE
|
.collect(Collectors.toList()); |
62
|
|
|
63
|
2
1. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::resolve → NO_COVERAGE
2. resolve : removed call to net/bmahe/genetics4j/core/combination/multicombinations/MultiChromosomeCombinations::<init> → NO_COVERAGE
|
return new MultiChromosomeCombinations<T>(randomGenerator, chromosomeCombinators); |
64
|
|
} |
65
|
|
} |
| | 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.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.DoubleTournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.DoubleTournamentSelectionPolicyHandlerTest]/[method:selectMaximize()]
- net.bmahe.genetics4j.core.selection.RouletteWheelSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.RouletteWheelSelectionPolicyHandlerTest]/[method:selectMinimizing()]
- net.bmahe.genetics4j.core.selection.MultiTournamentsSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiTournamentsSelectionPolicyHandlerTest]/[method:selectMaxThenMin()]
- net.bmahe.genetics4j.core.selection.DoubleTournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.DoubleTournamentSelectionPolicyHandlerTest]/[method:selectMaximizeAndDoFitnessLast()]
- 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:testGetterMethods()]
- net.bmahe.genetics4j.core.selection.DoubleTournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.DoubleTournamentSelectionPolicyHandlerTest]/[method:selectMinimize()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testSystemConstruction()]
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
- net.bmahe.genetics4j.core.selection.RandomSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.RandomSelectionPolicyHandlerTest]/[method:select()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvaluateOnce()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvaluateOnceWithDifferentGenerations()]
- 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:testEvolveWithPostEvaluationProcessor()]
- 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:testEvolveWithBitChromosome()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithImmediateTermination()]
|
35 |
|
1.1 Location : canHandle Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testGetterMethods()] negated conditional → KILLED
2.2 Location : canHandle Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testGetterMethods()] removed conditional - replaced equality check with false → KILLED
3.3 Location : canHandle Killed by : none removed conditional - replaced equality check with true → SURVIVED
Covering tests
Covered by tests:
- 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:testSystemConstruction()]
- net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvaluateOnce()]
- 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:testEvolveWithPostEvaluationProcessor()]
- 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:testEvolveWithBitChromosome()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithImmediateTermination()]
|
36 |
|
1.1 Location : canHandle Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testGetterMethods()] Substituted 0 with 1 → KILLED
2.2 Location : canHandle Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testGetterMethods()] replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → KILLED
|
41 |
|
1.1 Location : canHandle Killed by : none replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → NO_COVERAGE
2.2 Location : canHandle Killed by : none removed call to net/bmahe/genetics4j/core/spec/combination/MultiCombinations::combinationPolicies → NO_COVERAGE
3.3 Location : canHandle Killed by : none replaced boolean return with false for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::canHandle → NO_COVERAGE
|
42 |
|
1.1 Location : canHandle Killed by : none removed call to java/util/List::stream → NO_COVERAGE
|
43 |
|
1.1 Location : canHandle Killed by : none removed call to java/util/stream/Stream::allMatch → NO_COVERAGE
2.2 Location : lambda$canHandle$0 Killed by : none removed call to net/bmahe/genetics4j/core/combination/ChromosomeCombinatorResolver::canHandle → NO_COVERAGE
3.3 Location : lambda$canHandle$0 Killed by : none replaced boolean return with true for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$canHandle$0 → NO_COVERAGE
4.4 Location : lambda$canHandle$0 Killed by : none replaced boolean return with false for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$canHandle$0 → NO_COVERAGE
|
56 |
|
1.1 Location : resolve Killed by : none removed call to net/bmahe/genetics4j/core/spec/combination/MultiCombinations::combinationPolicies → NO_COVERAGE
|
57 |
|
1.1 Location : resolve Killed by : none removed call to java/util/List::stream → NO_COVERAGE
|
58 |
|
1.1 Location : resolve Killed by : none removed call to java/util/stream/Stream::map → NO_COVERAGE
2.2 Location : resolve Killed by : none replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE
|
59 |
|
1.1 Location : lambda$resolve$1 Killed by : none removed call to net/bmahe/genetics4j/core/combination/ChromosomeCombinatorResolver::resolve → NO_COVERAGE
2.2 Location : lambda$resolve$1 Killed by : none replaced return value with null for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::lambda$resolve$1 → NO_COVERAGE
|
61 |
|
1.1 Location : resolve Killed by : none removed call to java/util/stream/Stream::collect → NO_COVERAGE
2.2 Location : resolve Killed by : none removed call to java/util/stream/Collectors::toList → NO_COVERAGE
|
63 |
|
1.1 Location : resolve Killed by : none replaced return value with null for net/bmahe/genetics4j/core/combination/multicombinations/MultiCombinationsHandler::resolve → NO_COVERAGE
2.2 Location : resolve Killed by : none removed call to net/bmahe/genetics4j/core/combination/multicombinations/MultiChromosomeCombinations::<init> → NO_COVERAGE
|