MultiPointCrossoverCombinationHandler.java

1
package net.bmahe.genetics4j.core.combination.multipointcrossover;
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.MultiPointCrossover;
17
18
public class MultiPointCrossoverCombinationHandler<T extends Comparable<T>> implements ChromosomeCombinatorHandler<T> {
19
20
	private final RandomGenerator randomGenerator;
21
22
	public MultiPointCrossoverCombinationHandler(final RandomGenerator _randomGenerator) {
23
		Validate.notNull(_randomGenerator);
24
25 1 1. <init> : Removed assignment to member variable randomGenerator → SURVIVED
		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 → SURVIVED
2. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
3. canHandle : negated conditional → NO_COVERAGE
4. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
5. canHandle : negated conditional → NO_COVERAGE
6. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
7. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
8. canHandle : Substituted 1 with 0 → NO_COVERAGE
9. canHandle : negated conditional → NO_COVERAGE
10. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
11. canHandle : negated conditional → NO_COVERAGE
12. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
13. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
14. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
15. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/combination/multipointcrossover/MultiPointCrossoverCombinationHandler::canHandle → KILLED
16. canHandle : removed conditional - replaced equality check with true → KILLED
17. canHandle : Substituted 0 with 1 → KILLED
18. canHandle : negated conditional → KILLED
		return combinationPolicy instanceof MultiPointCrossover
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(MultiPointCrossover.class, combinationPolicy);
47
48 3 1. resolve : removed conditional - replaced equality check with true → NO_COVERAGE
2. resolve : negated conditional → NO_COVERAGE
3. resolve : removed conditional - replaced equality check with false → NO_COVERAGE
		if (chromosome instanceof BitChromosomeSpec) {
49 2 1. resolve : removed call to net/bmahe/genetics4j/core/combination/multipointcrossover/BitChromosomeMultiPointCrossover::<init> → NO_COVERAGE
2. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/multipointcrossover/MultiPointCrossoverCombinationHandler::resolve → NO_COVERAGE
			return new BitChromosomeMultiPointCrossover<T>(randomGenerator, (MultiPointCrossover) combinationPolicy);
50
		}
51
52 3 1. resolve : removed conditional - replaced equality check with true → NO_COVERAGE
2. resolve : negated conditional → NO_COVERAGE
3. resolve : removed conditional - replaced equality check with false → NO_COVERAGE
		if (chromosome instanceof IntChromosomeSpec) {
53 2 1. resolve : removed call to net/bmahe/genetics4j/core/combination/multipointcrossover/IntChromosomeMultiPointCrossover::<init> → NO_COVERAGE
2. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/multipointcrossover/MultiPointCrossoverCombinationHandler::resolve → NO_COVERAGE
			return new IntChromosomeMultiPointCrossover<T>(randomGenerator, (MultiPointCrossover) combinationPolicy);
54
		}
55
56 3 1. resolve : removed conditional - replaced equality check with false → NO_COVERAGE
2. resolve : removed conditional - replaced equality check with true → NO_COVERAGE
3. resolve : negated conditional → NO_COVERAGE
		if (chromosome instanceof DoubleChromosomeSpec) {
57 2 1. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/multipointcrossover/MultiPointCrossoverCombinationHandler::resolve → NO_COVERAGE
2. resolve : removed call to net/bmahe/genetics4j/core/combination/multipointcrossover/DoubleChromosomeMultiPointCrossover::<init> → NO_COVERAGE
			return new DoubleChromosomeMultiPointCrossover<T>(randomGenerator, (MultiPointCrossover) combinationPolicy);
58
		}
59
60 3 1. resolve : removed conditional - replaced equality check with true → NO_COVERAGE
2. resolve : negated conditional → NO_COVERAGE
3. resolve : removed conditional - replaced equality check with false → NO_COVERAGE
		if (chromosome instanceof FloatChromosomeSpec) {
61 2 1. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/multipointcrossover/MultiPointCrossoverCombinationHandler::resolve → NO_COVERAGE
2. resolve : removed call to net/bmahe/genetics4j/core/combination/multipointcrossover/FloatChromosomeMultiPointCrossover::<init> → NO_COVERAGE
			return new FloatChromosomeMultiPointCrossover<T>(randomGenerator, (MultiPointCrossover) combinationPolicy);
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 : none
Removed assignment to member variable randomGenerator → SURVIVED
Covering tests

35

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

2.2
Location : canHandle
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

3.3
Location : canHandle
Killed by : none
negated conditional → NO_COVERAGE

4.4
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/multipointcrossover/MultiPointCrossoverCombinationHandler::canHandle → KILLED

5.5
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 true → KILLED

6.6
Location : canHandle
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

7.7
Location : canHandle
Killed by : none
negated conditional → NO_COVERAGE

8.8
Location : canHandle
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

9.9
Location : canHandle
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

10.10
Location : canHandle
Killed by : none
Substituted 1 with 0 → NO_COVERAGE

11.11
Location : canHandle
Killed by : none
negated conditional → NO_COVERAGE

12.12
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

13.13
Location : canHandle
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

14.14
Location : canHandle
Killed by : none
negated conditional → NO_COVERAGE

15.15
Location : canHandle
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

16.16
Location : canHandle
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

17.17
Location : canHandle
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testGetterMethods()]
negated conditional → KILLED

18.18
Location : canHandle
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

48

1.1
Location : resolve
Killed by : none
removed conditional - replaced equality check with true → 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 false → NO_COVERAGE

49

1.1
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/multipointcrossover/BitChromosomeMultiPointCrossover::<init> → NO_COVERAGE

2.2
Location : resolve
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/combination/multipointcrossover/MultiPointCrossoverCombinationHandler::resolve → NO_COVERAGE

52

1.1
Location : resolve
Killed by : none
removed conditional - replaced equality check with true → 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 false → NO_COVERAGE

53

1.1
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/multipointcrossover/IntChromosomeMultiPointCrossover::<init> → NO_COVERAGE

2.2
Location : resolve
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/combination/multipointcrossover/MultiPointCrossoverCombinationHandler::resolve → NO_COVERAGE

56

1.1
Location : resolve
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

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

3.3
Location : resolve
Killed by : none
negated conditional → NO_COVERAGE

57

1.1
Location : resolve
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/combination/multipointcrossover/MultiPointCrossoverCombinationHandler::resolve → NO_COVERAGE

2.2
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/multipointcrossover/DoubleChromosomeMultiPointCrossover::<init> → NO_COVERAGE

60

1.1
Location : resolve
Killed by : none
removed conditional - replaced equality check with true → 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 false → NO_COVERAGE

61

1.1
Location : resolve
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/combination/multipointcrossover/MultiPointCrossoverCombinationHandler::resolve → NO_COVERAGE

2.2
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/multipointcrossover/FloatChromosomeMultiPointCrossover::<init> → 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

Active mutators

Tests examined


Report generated by PIT 1.19.6