DoubleChromosomeCreepMutationHandler.java

1
package net.bmahe.genetics4j.core.mutation.chromosome.creepmutation;
2
3
import java.util.Arrays;
4
import java.util.function.Supplier;
5
import java.util.random.RandomGenerator;
6
7
import org.apache.commons.lang3.Validate;
8
9
import net.bmahe.genetics4j.core.chromosomes.Chromosome;
10
import net.bmahe.genetics4j.core.chromosomes.DoubleChromosome;
11
import net.bmahe.genetics4j.core.mutation.chromosome.ChromosomeMutationHandler;
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.mutation.CreepMutation;
15
import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy;
16
import net.bmahe.genetics4j.core.spec.statistics.distributions.Distribution;
17
import net.bmahe.genetics4j.core.util.DistributionUtils;
18
19
public class DoubleChromosomeCreepMutationHandler implements ChromosomeMutationHandler<DoubleChromosome> {
20
21
	private final RandomGenerator randomGenerator;
22
23
	public DoubleChromosomeCreepMutationHandler(final RandomGenerator _randomGenerator) {
24
		Validate.notNull(_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 MutationPolicy mutationPolicy, final ChromosomeSpec chromosome) {
31
		Validate.notNull(mutationPolicy);
32
		Validate.notNull(chromosome);
33
34 9 1. canHandle : removed conditional - replaced equality check with true → SURVIVED
2. canHandle : Substituted 1 with 0 → KILLED
3. canHandle : Substituted 0 with 1 → KILLED
4. canHandle : negated conditional → KILLED
5. canHandle : removed conditional - replaced equality check with false → KILLED
6. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/chromosome/creepmutation/DoubleChromosomeCreepMutationHandler::canHandle → KILLED
7. canHandle : removed conditional - replaced equality check with true → KILLED
8. canHandle : negated conditional → KILLED
9. canHandle : removed conditional - replaced equality check with false → KILLED
		return mutationPolicy instanceof CreepMutation && chromosome instanceof DoubleChromosomeSpec;
35
	}
36
37
	@Override
38
	public DoubleChromosome mutate(final MutationPolicy mutationPolicy, final Chromosome chromosome) {
39
		Validate.notNull(mutationPolicy);
40
		Validate.notNull(chromosome);
41
		Validate.isInstanceOf(CreepMutation.class, mutationPolicy);
42
		Validate.isInstanceOf(DoubleChromosome.class, chromosome);
43
44
		final var doubleChromosome = (DoubleChromosome) chromosome;
45
		final var creepMutation = (CreepMutation) mutationPolicy;
46
47 1 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getMinValue → KILLED
		final var minValue = doubleChromosome.getMinValue();
48 1 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getMaxValue → KILLED
		final var maxValue = doubleChromosome.getMaxValue();
49 1 1. mutate : removed call to net/bmahe/genetics4j/core/spec/mutation/CreepMutation::distribution → KILLED
		final Distribution distribution = creepMutation.distribution();
50
51
		final Supplier<Double> distributionValueSupplier = DistributionUtils
52 1 1. mutate : removed call to net/bmahe/genetics4j/core/util/DistributionUtils::distributionValueSupplier → KILLED
				.distributionValueSupplier(randomGenerator, minValue, maxValue, distribution);
53
54 4 1. mutate : replaced call to java/util/Arrays::copyOf with argument → SURVIVED
2. mutate : removed call to java/util/Arrays::copyOf → KILLED
3. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getNumAlleles → KILLED
4. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getValues → KILLED
		final double[] newValues = Arrays.copyOf(doubleChromosome.getValues(), doubleChromosome.getNumAlleles());
55
56 3 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getNumAlleles → SURVIVED
2. mutate : replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED
3. mutate : removed call to java/util/random/RandomGenerator::nextInt → KILLED
		final int alleleFlipIndex = randomGenerator.nextInt(doubleChromosome.getNumAlleles());
57 3 1. mutate : removed call to java/lang/Double::doubleValue → KILLED
2. mutate : Replaced double addition with subtraction → KILLED
3. mutate : removed call to java/util/function/Supplier::get → KILLED
		newValues[alleleFlipIndex] += distributionValueSupplier.get();
58
59 4 1. mutate : changed conditional boundary → SURVIVED
2. mutate : removed conditional - replaced comparison check with true → KILLED
3. mutate : negated conditional → KILLED
4. mutate : removed conditional - replaced comparison check with false → KILLED
		if (newValues[alleleFlipIndex] > maxValue) {
60
			newValues[alleleFlipIndex] = maxValue;
61 4 1. mutate : changed conditional boundary → SURVIVED
2. mutate : removed conditional - replaced comparison check with false → KILLED
3. mutate : removed conditional - replaced comparison check with true → KILLED
4. mutate : negated conditional → KILLED
		} else if (newValues[alleleFlipIndex] < minValue) {
62
			newValues[alleleFlipIndex] = minValue;
63
		}
64
65 3 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getMinValue → SURVIVED
2. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getSize → KILLED
3. mutate : replaced return value with null for net/bmahe/genetics4j/core/mutation/chromosome/creepmutation/DoubleChromosomeCreepMutationHandler::mutate → KILLED
		return new DoubleChromosome(doubleChromosome.getSize(), doubleChromosome.getMinValue(),
66 2 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getMaxValue → SURVIVED
2. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::<init> → KILLED
				doubleChromosome.getMaxValue(), newValues);
67
	}
68
}

Mutations

26

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

34

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:canHandle()]
Substituted 1 with 0 → KILLED

2.2
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:canHandle()]
Substituted 0 with 1 → KILLED

3.3
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:canHandle()]
negated conditional → KILLED

4.4
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:canHandle()]
removed conditional - replaced equality check with false → KILLED

5.5
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:canHandle()]
replaced boolean return with true for net/bmahe/genetics4j/core/mutation/chromosome/creepmutation/DoubleChromosomeCreepMutationHandler::canHandle → KILLED

6.6
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:canHandle()]
removed conditional - replaced equality check with true → KILLED

7.7
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:canHandle()]
negated conditional → KILLED

8.8
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:canHandle()]
removed conditional - replaced equality check with false → KILLED

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

47

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getMinValue → KILLED

48

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidate()]
removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getMaxValue → KILLED

49

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to net/bmahe/genetics4j/core/spec/mutation/CreepMutation::distribution → KILLED

52

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to net/bmahe/genetics4j/core/util/DistributionUtils::distributionValueSupplier → KILLED

54

1.1
Location : mutate
Killed by : none
replaced call to java/util/Arrays::copyOf with argument → SURVIVED
Covering tests

2.2
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to java/util/Arrays::copyOf → KILLED

3.3
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getNumAlleles → KILLED

4.4
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getValues → KILLED

56

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED

2.2
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidate()]
removed call to java/util/random/RandomGenerator::nextInt → KILLED

3.3
Location : mutate
Killed by : none
removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getNumAlleles → SURVIVED
Covering tests

57

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to java/lang/Double::doubleValue → KILLED

2.2
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
Replaced double addition with subtraction → KILLED

3.3
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to java/util/function/Supplier::get → KILLED

59

1.1
Location : mutate
Killed by : none
changed conditional boundary → SURVIVED
Covering tests

2.2
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed conditional - replaced comparison check with true → KILLED

3.3
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
negated conditional → KILLED

4.4
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateAboveMax()]
removed conditional - replaced comparison check with false → KILLED

61

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed conditional - replaced comparison check with false → KILLED

2.2
Location : mutate
Killed by : none
changed conditional boundary → SURVIVED
Covering tests

3.3
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidate()]
removed conditional - replaced comparison check with true → KILLED

4.4
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
negated conditional → KILLED

65

1.1
Location : mutate
Killed by : none
removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getMinValue → SURVIVED
Covering tests

2.2
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getSize → KILLED

3.3
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
replaced return value with null for net/bmahe/genetics4j/core/mutation/chromosome/creepmutation/DoubleChromosomeCreepMutationHandler::mutate → KILLED

66

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.DoubleChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::<init> → KILLED

2.2
Location : mutate
Killed by : none
removed call to net/bmahe/genetics4j/core/chromosomes/DoubleChromosome::getMaxValue → SURVIVED
Covering tests

Active mutators

Tests examined


Report generated by PIT 1.19.6