SinglePointArithmeticCombinationHandler.java

1
package net.bmahe.genetics4j.core.combination.singlepointarithmetic;
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.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.SinglePointArithmetic;
17
18
public class SinglePointArithmeticCombinationHandler<T extends Comparable<T>>
19
		implements ChromosomeCombinatorHandler<T>
20
{
21
22
	private final RandomGenerator randomGenerator;
23
24
	public SinglePointArithmeticCombinationHandler(final RandomGenerator _randomGenerator) {
25
		Objects.requireNonNull(_randomGenerator);
26
27 1 1. <init> : Removed assignment to member variable randomGenerator → SURVIVED
		this.randomGenerator = _randomGenerator;
28
	}
29
30
	@Override
31
	public boolean canHandle(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver,
32
			final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosome) {
33
		Objects.requireNonNull(chromosomeCombinatorResolver);
34
		Objects.requireNonNull(combinationPolicy);
35
		Objects.requireNonNull(chromosome);
36
37 15 1. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::canHandle → NO_COVERAGE
3. canHandle : negated conditional → NO_COVERAGE
4. canHandle : negated conditional → NO_COVERAGE
5. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
6. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
7. canHandle : Substituted 1 with 0 → NO_COVERAGE
8. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
9. canHandle : negated conditional → NO_COVERAGE
10. canHandle : Substituted 0 with 1 → NO_COVERAGE
11. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
12. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
13. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
14. canHandle : negated conditional → NO_COVERAGE
15. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
		return combinationPolicy instanceof SinglePointArithmetic && (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(SinglePointArithmetic.class, combinationPolicy);
48
49
		final var singlePointArithmeticRecombination = (SinglePointArithmetic) combinationPolicy;
50 1 1. resolve : removed call to net/bmahe/genetics4j/core/spec/combination/SinglePointArithmetic::alpha → NO_COVERAGE
		final double alpha = singlePointArithmeticRecombination.alpha();
51
52 3 1. resolve : negated conditional → NO_COVERAGE
2. resolve : removed conditional - replaced equality check with true → 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/singlepointarithmetic/IntChromosomeSinglePointArithmetic::<init> → NO_COVERAGE
2. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::resolve → NO_COVERAGE
			return new IntChromosomeSinglePointArithmetic<>(randomGenerator, alpha);
54
		}
55
56 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 DoubleChromosomeSpec) {
57 2 1. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::resolve → NO_COVERAGE
2. resolve : removed call to net/bmahe/genetics4j/core/combination/singlepointarithmetic/DoubleChromosomeSinglePointArithmetic::<init> → NO_COVERAGE
			return new DoubleChromosomeSinglePointArithmetic<>(randomGenerator, alpha);
58
		}
59
60 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 FloatChromosomeSpec) {
61 2 1. resolve : removed call to net/bmahe/genetics4j/core/combination/singlepointarithmetic/FloatChromosomeSinglePointArithmetic::<init> → NO_COVERAGE
2. resolve : replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::resolve → NO_COVERAGE
			return new FloatChromosomeSinglePointArithmetic<>(randomGenerator, (float) alpha);
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

27

1.1
Location : <init>
Killed by : none
Removed assignment to member variable randomGenerator → SURVIVED
Covering tests

37

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

2.2
Location : canHandle
Killed by : none
replaced boolean return with true for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::canHandle → NO_COVERAGE

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

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

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

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

7.7
Location : canHandle
Killed by : none
Substituted 1 with 0 → 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
negated conditional → NO_COVERAGE

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 false → NO_COVERAGE

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

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 true → NO_COVERAGE

50

1.1
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/spec/combination/SinglePointArithmetic::alpha → NO_COVERAGE

52

1.1
Location : resolve
Killed by : none
negated conditional → 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
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/singlepointarithmetic/IntChromosomeSinglePointArithmetic::<init> → NO_COVERAGE

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

56

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

57

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

2.2
Location : resolve
Killed by : none
removed call to net/bmahe/genetics4j/core/combination/singlepointarithmetic/DoubleChromosomeSinglePointArithmetic::<init> → 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
removed conditional - replaced equality check with true → NO_COVERAGE

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

61

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

2.2
Location : resolve
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/combination/singlepointarithmetic/SinglePointArithmeticCombinationHandler::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

Active mutators

Tests examined


Report generated by PIT 1.25.7 support