ProgramRandomCombineHandler.java

1
package net.bmahe.genetics4j.gp.combination;
2
3
import java.util.random.RandomGenerator;
4
5
import org.apache.commons.lang3.Validate;
6
import org.apache.logging.log4j.LogManager;
7
import org.apache.logging.log4j.Logger;
8
9
import net.bmahe.genetics4j.core.combination.ChromosomeCombinator;
10
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorHandler;
11
import net.bmahe.genetics4j.core.combination.ChromosomeCombinatorResolver;
12
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
13
import net.bmahe.genetics4j.core.spec.combination.CombinationPolicy;
14
import net.bmahe.genetics4j.gp.spec.chromosome.ProgramTreeChromosomeSpec;
15
import net.bmahe.genetics4j.gp.spec.combination.ProgramRandomCombine;
16
17
public class ProgramRandomCombineHandler<T extends Comparable<T>> implements ChromosomeCombinatorHandler<T> {
18
	final static public Logger logger = LogManager.getLogger(ProgramRandomCombineHandler.class);
19
20
	final RandomGenerator randomGenerator;
21
22
	public ProgramRandomCombineHandler(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 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;
36
	}
37
38
	@Override
39
	public ChromosomeCombinator<T> resolve(final ChromosomeCombinatorResolver<T> chromosomeCombinatorResolver,
40
			final CombinationPolicy combinationPolicy, final ChromosomeSpec chromosomeSpec) {
41
		Validate.notNull(chromosomeCombinatorResolver);
42
		Validate.notNull(combinationPolicy);
43
		Validate.notNull(chromosomeSpec);
44
		Validate.isInstanceOf(ProgramTreeChromosomeSpec.class,
45
				chromosomeSpec,
46
				"This combinator does not support chromosome specs %s",
47
				chromosomeSpec);
48
49
		final ProgramTreeChromosomeSpec programTreeChromosomeSpec = (ProgramTreeChromosomeSpec) chromosomeSpec;
50
51 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<T>(randomGenerator);
52
	}
53
}

Mutations

25

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

35

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

51

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.19.6