|
1
|
|
package net.bmahe.genetics4j.core.combination.singlepointcrossover; |
|
2
|
|
|
|
3
|
|
import java.util.random.RandomGenerator; |
|
4
|
|
|
|
5
|
|
import org.apache.commons.lang3.Validate; |
|
6
|
|
|
|
7
|
|
import net.bmahe.genetics4j.core.combination.ChromosomeCombinator; |
|
8
|
|
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorHandler; |
|
9
|
|
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorResolver; |
|
10
|
|
import net.bmahe.genetics4j.core.spec.chromosome.BitChromosomeSpec; |
|
11
|
|
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec; |
|
12
|
|
import net.bmahe.genetics4j.core.spec.chromosome.DoubleChromosomeSpec; |
|
13
|
|
import net.bmahe.genetics4j.core.spec.chromosome.FloatChromosomeSpec; |
|
14
|
|
import net.bmahe.genetics4j.core.spec.chromosome.IntChromosomeSpec; |
|
15
|
|
import net.bmahe.genetics4j.core.spec.combination.CombinationPolicy; |
|
16
|
|
import net.bmahe.genetics4j.core.spec.combination.SinglePointCrossover; |
|
17
|
|
|
|
18
|
|
public class SinglePointCrossoverHandler<T extends Comparable<T>> implements ChromosomeCombinatorHandler<T> { |
|
19
|
|
|
|
20
|
|
private final RandomGenerator randomGenerator; |
|
21
|
|
|
|
22
|
|
public SinglePointCrossoverHandler(final RandomGenerator _randomGenerator) { |
|
23
|
|
Validate.notNull(_randomGenerator); |
|
24
|
|
|
|
25
|
1
1. <init> : Removed assignment to member variable randomGenerator → KILLED
|
this.randomGenerator = _randomGenerator; |
|
26
|
|
} |
|
27
|
|
|
|
28
|
|
@Override |
|
29
|
|
public boolean canHandle(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver, |
|
30
|
|
final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) { |
|
31
|
|
Validate.notNull(chromosomeCombinatorResolver); |
|
32
|
|
Validate.notNull(combinationPolicy); |
|
33
|
|
Validate.notNull(chromosome); |
|
34
|
|
|
|
35
|
18
1. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
2. canHandle : negated conditional → NO_COVERAGE
3. canHandle : removed conditional - replaced equality check with false → SURVIVED
4. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
5. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
6. canHandle : Substituted 0 with 1 → NO_COVERAGE
7. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
8. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/combination/singlepointcrossover/SinglePointCrossoverHandler::canHandle → SURVIVED
9. canHandle : removed conditional - replaced equality check with false → SURVIVED
10. canHandle : negated conditional → NO_COVERAGE
11. canHandle : removed conditional - replaced equality check with true → SURVIVED
12. canHandle : negated conditional → KILLED
13. canHandle : removed conditional - replaced equality check with true → KILLED
14. canHandle : negated conditional → KILLED
15. canHandle : negated conditional → KILLED
16. canHandle : Substituted 1 with 0 → KILLED
17. canHandle : removed conditional - replaced equality check with false → KILLED
18. canHandle : removed conditional - replaced equality check with true → KILLED
|
return combinationPolicy instanceof SinglePointCrossover |
|
36
|
|
&& (chromosome instanceof BitChromosomeSpec || chromosome instanceof IntChromosomeSpec |
|
37
|
|
|| chromosome instanceof DoubleChromosomeSpec || chromosome instanceof FloatChromosomeSpec); |
|
38
|
|
} |
|
39
|
|
|
|
40
|
|
@Override |
|
41
|
|
public ChromosomeCombinator<T> resolve(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver, |
|
42
|
|
final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) { |
|
43
|
|
Validate.notNull(chromosomeCombinatorResolver); |
|
44
|
|
Validate.notNull(combinationPolicy); |
|
45
|
|
Validate.notNull(chromosome); |
|
46
|
|
Validate.isInstanceOf(SinglePointCrossover.class, combinationPolicy); |
|
47
|
|
|
|
48
|
3
1. resolve : removed conditional - replaced equality check with true → KILLED
2. resolve : removed conditional - replaced equality check with false → KILLED
3. resolve : negated conditional → KILLED
|
if (chromosome instanceof BitChromosomeSpec) { |
|
49
|
2
1. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointcrossover/SinglePointCrossoverHandler::resolve → KILLED
2. resolve : removed call to net/bmahe/genetics4j/core/combination/singlepointcrossover/BitChromosomeSinglePointCrossover::<init> → KILLED
|
return new BitChromosomeSinglePointCrossover<T>(randomGenerator); |
|
50
|
|
} |
|
51
|
|
|
|
52
|
3
1. resolve : removed conditional - replaced equality check with true → SURVIVED
2. resolve : negated conditional → KILLED
3. resolve : removed conditional - replaced equality check with false → KILLED
|
if (chromosome instanceof IntChromosomeSpec) { |
|
53
|
2
1. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointcrossover/SinglePointCrossoverHandler::resolve → KILLED
2. resolve : removed call to net/bmahe/genetics4j/core/combination/singlepointcrossover/IntChromosomeSinglePointCrossover::<init> → KILLED
|
return new IntChromosomeSinglePointCrossover<T>(randomGenerator); |
|
54
|
|
} |
|
55
|
|
|
|
56
|
3
1. resolve : removed conditional - replaced equality check with false → NO_COVERAGE
2. resolve : negated conditional → NO_COVERAGE
3. resolve : removed conditional - replaced equality check with true → NO_COVERAGE
|
if (chromosome instanceof DoubleChromosomeSpec) { |
|
57
|
2
1. resolve : removed call to net/bmahe/genetics4j/core/combination/singlepointcrossover/DoubleChromosomeSinglePointCrossover::<init> → NO_COVERAGE
2. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointcrossover/SinglePointCrossoverHandler::resolve → NO_COVERAGE
|
return new DoubleChromosomeSinglePointCrossover<T>(randomGenerator); |
|
58
|
|
} |
|
59
|
|
|
|
60
|
3
1. resolve : removed conditional - replaced equality check with false → NO_COVERAGE
2. resolve : negated conditional → NO_COVERAGE
3. resolve : removed conditional - replaced equality check with true → NO_COVERAGE
|
if (chromosome instanceof FloatChromosomeSpec) { |
|
61
|
2
1. resolve : removed call to net/bmahe/genetics4j/core/combination/singlepointcrossover/FloatChromosomeSinglePointCrossover::<init> → NO_COVERAGE
2. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointcrossover/SinglePointCrossoverHandler::resolve → NO_COVERAGE
|
return new FloatChromosomeSinglePointCrossover<T>(randomGenerator); |
|
62
|
|
} |
|
63
|
|
|
|
64
|
2
1. resolve : removed call to java/lang/String::valueOf → NO_COVERAGE
2. resolve : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE
|
throw new IllegalArgumentException("Could not handle chromosome " + chromosome); |
|
65
|
|
} |
|
66
|
|
} |
| | Mutations |
| 25 |
|
1.1 Location : <init> Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()] Removed assignment to member variable randomGenerator → KILLED
|
| 35 |
|
1.1 Location : canHandle Killed by : none removed conditional - replaced equality check with false → NO_COVERAGE
2.2 Location : canHandle Killed by : none negated conditional → NO_COVERAGE
3.3 Location : canHandle Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()] negated conditional → KILLED
4.4 Location : canHandle Killed by : none removed conditional - replaced equality check with false → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()]
- 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.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()]
5.5 Location : canHandle Killed by : none removed conditional - replaced equality check with true → NO_COVERAGE
6.6 Location : canHandle Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()] removed conditional - replaced equality check with true → KILLED
7.7 Location : canHandle Killed by : none removed conditional - replaced equality check with false → NO_COVERAGE
8.8 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
9.9 Location : canHandle Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()] negated conditional → KILLED
10.10 Location : canHandle Killed by : none Substituted 0 with 1 → NO_COVERAGE
11.11 Location : canHandle Killed by : none removed conditional - replaced equality check with true → NO_COVERAGE
12.12 Location : canHandle Killed by : none replaced boolean return with true for net/bmahe/genetics4j/core/combination/singlepointcrossover/SinglePointCrossoverHandler::canHandle → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()]
- 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.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()]
13.13 Location : canHandle Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()] Substituted 1 with 0 → KILLED
14.14 Location : canHandle Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()] removed conditional - replaced equality check with false → KILLED
15.15 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
16.16 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()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]
17.17 Location : canHandle Killed by : none negated conditional → NO_COVERAGE
18.18 Location : canHandle Killed by : none removed conditional - replaced equality check with true → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()]
- 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.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()]
|
| 48 |
|
1.1 Location : resolve Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()] removed conditional - replaced equality check with true → KILLED
2.2 Location : resolve Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()] removed conditional - replaced equality check with false → KILLED
3.3 Location : resolve Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()] negated conditional → KILLED
|
| 49 |
|
1.1 Location : resolve Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()] replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointcrossover/SinglePointCrossoverHandler::resolve → KILLED
2.2 Location : resolve Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()] removed call to net/bmahe/genetics4j/core/combination/singlepointcrossover/BitChromosomeSinglePointCrossover::<init> → KILLED
|
| 52 |
|
1.1 Location : resolve Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] negated conditional → KILLED
2.2 Location : resolve Killed by : none removed conditional - replaced equality check with true → SURVIVED
Covering tests
Covered by tests:
- 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:testEvolveWithIntChromosome()]
3.3 Location : resolve 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 false → KILLED
|
| 53 |
|
1.1 Location : resolve Killed by : net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()] replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointcrossover/SinglePointCrossoverHandler::resolve → KILLED
2.2 Location : resolve 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/combination/singlepointcrossover/IntChromosomeSinglePointCrossover::<init> → KILLED
|
| 56 |
|
1.1 Location : resolve Killed by : none removed conditional - replaced equality check with false → NO_COVERAGE
2.2 Location : resolve Killed by : none negated conditional → NO_COVERAGE
3.3 Location : resolve Killed by : none removed conditional - replaced equality check with true → NO_COVERAGE
|
| 57 |
|
1.1 Location : resolve Killed by : none removed call to net/bmahe/genetics4j/core/combination/singlepointcrossover/DoubleChromosomeSinglePointCrossover::<init> → NO_COVERAGE
2.2 Location : resolve Killed by : none replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointcrossover/SinglePointCrossoverHandler::resolve → NO_COVERAGE
|
| 60 |
|
1.1 Location : resolve Killed by : none removed conditional - replaced equality check with false → NO_COVERAGE
2.2 Location : resolve Killed by : none negated conditional → NO_COVERAGE
3.3 Location : resolve Killed by : none removed conditional - replaced equality check with true → NO_COVERAGE
|
| 61 |
|
1.1 Location : resolve Killed by : none removed call to net/bmahe/genetics4j/core/combination/singlepointcrossover/FloatChromosomeSinglePointCrossover::<init> → NO_COVERAGE
2.2 Location : resolve Killed by : none replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointcrossover/SinglePointCrossoverHandler::resolve → NO_COVERAGE
|
| 64 |
|
1.1 Location : resolve Killed by : none removed call to java/lang/String::valueOf → NO_COVERAGE
2.2 Location : resolve Killed by : none removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE
|