SinglePointCrossoverHandler.java

1
package net.bmahe.genetics4j.core.combination.singlepointcrossover;
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.combination.ChromosomeCombinator;
9
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorHandler;
10
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorResolver;
11
import net.bmahe.genetics4j.core.spec.chromosome.BitChromosomeSpec;
12
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
13
import net.bmahe.genetics4j.core.spec.chromosome.DoubleChromosomeSpec;
14
import net.bmahe.genetics4j.core.spec.chromosome.FloatChromosomeSpec;
15
import net.bmahe.genetics4j.core.spec.chromosome.IntChromosomeSpec;
16
import net.bmahe.genetics4j.core.spec.combination.CombinationPolicy;
17
import net.bmahe.genetics4j.core.spec.combination.SinglePointCrossover;
18
19
public class SinglePointCrossoverHandler<T extends Comparable<T>> implements ChromosomeCombinatorHandler<T> {
20
21
	private final RandomGenerator randomGenerator;
22
23
	public SinglePointCrossoverHandler(final RandomGenerator _randomGenerator) {
24
		Objects.requireNonNull(_randomGenerator);
25
26 1 1. <init> : Removed assignment to member variable randomGenerator → KILLED
		this.randomGenerator = _randomGenerator;
27
	}
28
29
	@Override
30
	public boolean canHandle(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver,
31
			final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) {
32
		Objects.requireNonNull(chromosomeCombinatorResolver);
33
		Objects.requireNonNull(combinationPolicy);
34
		Objects.requireNonNull(chromosome);
35
36 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
37
				&& (chromosome instanceof BitChromosomeSpec || chromosome instanceof IntChromosomeSpec
38
						|| chromosome instanceof DoubleChromosomeSpec || chromosome instanceof FloatChromosomeSpec);
39
	}
40
41
	@Override
42
	public ChromosomeCombinator<T> resolve(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver,
43
			final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) {
44
		Objects.requireNonNull(chromosomeCombinatorResolver);
45
		Objects.requireNonNull(combinationPolicy);
46
		Objects.requireNonNull(chromosome);
47
		Validate.isInstanceOf(SinglePointCrossover.class, combinationPolicy);
48
49 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) {
50 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<>(randomGenerator);
51
		}
52
53 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) {
54 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<>(randomGenerator);
55
		}
56
57 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) {
58 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<>(randomGenerator);
59
		}
60
61 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) {
62 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<>(randomGenerator);
63
		}
64
65 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);
66
	}
67
}

Mutations

26

1.1
Location : <init>
Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:virtualThreadFactory()]
Removed assignment to member variable randomGenerator → KILLED

36

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:virtualThreadFactory()]
negated conditional → KILLED

4.4
Location : canHandle
Killed by : none
removed conditional - replaced equality check with false → SURVIVED
Covering tests

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:virtualThreadFactory()]
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:virtualThreadFactory()]
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

13.13
Location : canHandle
Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:virtualThreadFactory()]
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:virtualThreadFactory()]
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

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

49

1.1
Location : resolve
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:evolveWithIntChromosome()]
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:virtualThreadFactory()]
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:virtualThreadFactory()]
negated conditional → KILLED

50

1.1
Location : resolve
Killed by : net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:virtualThreadFactory()]
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:virtualThreadFactory()]
removed call to net/bmahe/genetics4j/core/combination/singlepointcrossover/BitChromosomeSinglePointCrossover::<init> → 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()]
negated conditional → KILLED

2.2
Location : resolve
Killed by : none
removed conditional - replaced equality check with true → SURVIVED
Covering tests

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

54

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

57

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

58

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

61

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

62

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

65

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

Active mutators

Tests examined


Report generated by PIT 1.25.7 support