ProgramRandomCombineHandler.java

1
package net.bmahe.genetics4j.gp.combination;
2
3
import java.util.Objects;
4
import java.util.random.RandomGenerator;
5
6
import org.apache.commons.lang3.Validate;
7
import org.apache.logging.log4j.LogManager;
8
import org.apache.logging.log4j.Logger;
9
10
import net.bmahe.genetics4j.core.combination.ChromosomeCombinator;
11
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorHandler;
12
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorResolver;
13
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
14
import net.bmahe.genetics4j.core.spec.combination.CombinationPolicy;
15
import net.bmahe.genetics4j.gp.spec.chromosome.ProgramTreeChromosomeSpec;
16
import net.bmahe.genetics4j.gp.spec.combination.ProgramRandomCombine;
17
18
public class ProgramRandomCombineHandler<T extends Comparable<T>> implements ChromosomeCombinatorHandler<T> {
19
	public static final Logger logger = LogManager.getLogger(ProgramRandomCombineHandler.class);
20
21
	final RandomGenerator randomGenerator;
22
23
	public ProgramRandomCombineHandler(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 9 1. canHandle : removed conditional - replaced equality check with true → KILLED
2. canHandle : Substituted 0 with 1 → KILLED
3. canHandle : removed conditional - replaced equality check with false → KILLED
4. canHandle : removed conditional - replaced equality check with false → KILLED
5. canHandle : Substituted 1 with 0 → KILLED
6. canHandle : negated conditional → KILLED
7. canHandle : replaced boolean return with true for net/bmahe/genetics4j/gp/combination/ProgramRandomCombineHandler::canHandle → KILLED
8. canHandle : removed conditional - replaced equality check with true → KILLED
9. canHandle : negated conditional → KILLED
		return combinationPolicy instanceof ProgramRandomCombine && chromosome instanceof ProgramTreeChromosomeSpec;
37
	}
38
39
	@Override
40
	public ChromosomeCombinator<T> resolve(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver,
41
			final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosomeSpec) {
42
		Objects.requireNonNull(chromosomeCombinatorResolver);
43
		Objects.requireNonNull(combinationPolicy);
44
		Objects.requireNonNull(chromosomeSpec);
45
		Validate.isInstanceOf(
46
				ProgramTreeChromosomeSpec.class,
47
					chromosomeSpec,
48
					"This combinator does not support chromosome specs %s",
49
					chromosomeSpec);
50
51
		final ProgramTreeChromosomeSpec programTreeChromosomeSpec = (ProgramTreeChromosomeSpec) chromosomeSpec;
52
53 2 1. resolve : removed call to net/bmahe/genetics4j/gp/combination/ProgramChromosomeCombinator::<init> → KILLED
2. resolve : replaced return value with null for net/bmahe/genetics4j/gp/combination/ProgramRandomCombineHandler::resolve → KILLED
		return new ProgramChromosomeCombinator<>(randomGenerator);
54
	}
55
}

Mutations

26

1.1
Location : <init>
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:resolve()]
Removed assignment to member variable randomGenerator → KILLED

36

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:canHandle()]
removed conditional - replaced equality check with true → KILLED

2.2
Location : canHandle
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:canHandle()]
Substituted 0 with 1 → KILLED

3.3
Location : canHandle
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:canHandle()]
removed conditional - replaced equality check with false → KILLED

4.4
Location : canHandle
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:canHandle()]
removed conditional - replaced equality check with false → KILLED

5.5
Location : canHandle
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:canHandle()]
Substituted 1 with 0 → KILLED

6.6
Location : canHandle
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:canHandle()]
negated conditional → KILLED

7.7
Location : canHandle
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:canHandle()]
replaced boolean return with true for net/bmahe/genetics4j/gp/combination/ProgramRandomCombineHandler::canHandle → KILLED

8.8
Location : canHandle
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:canHandle()]
removed conditional - replaced equality check with true → KILLED

9.9
Location : canHandle
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:canHandle()]
negated conditional → KILLED

53

1.1
Location : resolve
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:resolve()]
removed call to net/bmahe/genetics4j/gp/combination/ProgramChromosomeCombinator::<init> → KILLED

2.2
Location : resolve
Killed by : net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.gp.combination.ProgramRandomCombineHandlerTest]/[method:resolve()]
replaced return value with null for net/bmahe/genetics4j/gp/combination/ProgramRandomCombineHandler::resolve → KILLED

Active mutators

Tests examined


Report generated by PIT 1.25.7 support