FloatChromosomeCreepMutationHandler.java

1
package net.bmahe.genetics4j.core.mutation.chromosome.creepmutation;
2
3
import java.util.Arrays;
4
import java.util.Objects;
5
import java.util.function.Supplier;
6
import java.util.random.RandomGenerator;
7
8
import org.apache.commons.lang3.Validate;
9
10
import net.bmahe.genetics4j.core.chromosomes.Chromosome;
11
import net.bmahe.genetics4j.core.chromosomes.FloatChromosome;
12
import net.bmahe.genetics4j.core.mutation.chromosome.ChromosomeMutationHandler;
13
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
14
import net.bmahe.genetics4j.core.spec.chromosome.FloatChromosomeSpec;
15
import net.bmahe.genetics4j.core.spec.mutation.CreepMutation;
16
import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy;
17
import net.bmahe.genetics4j.core.spec.statistics.distributions.Distribution;
18
import net.bmahe.genetics4j.core.util.DistributionUtils;
19
20
public class FloatChromosomeCreepMutationHandler implements ChromosomeMutationHandler<FloatChromosome> {
21
22
	private final RandomGenerator randomGenerator;
23
24
	public FloatChromosomeCreepMutationHandler(final RandomGenerator _randomGenerator) {
25
		Objects.requireNonNull(_randomGenerator);
26
27 1 1. <init> : Removed assignment to member variable randomGenerator → KILLED
		this.randomGenerator = _randomGenerator;
28
	}
29
30
	@Override
31
	public boolean canHandle(final MutationPolicy mutationPolicy, final ChromosomeSpec chromosome) {
32
		Objects.requireNonNull(mutationPolicy);
33
		Objects.requireNonNull(chromosome);
34
35 9 1. canHandle : removed conditional - replaced equality check with true → SURVIVED
2. canHandle : negated conditional → KILLED
3. canHandle : removed conditional - replaced equality check with false → KILLED
4. canHandle : negated conditional → KILLED
5. canHandle : removed conditional - replaced equality check with true → KILLED
6. canHandle : removed conditional - replaced equality check with false → KILLED
7. canHandle : Substituted 0 with 1 → KILLED
8. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/chromosome/creepmutation/FloatChromosomeCreepMutationHandler::canHandle → KILLED
9. canHandle : Substituted 1 with 0 → KILLED
		return mutationPolicy instanceof CreepMutation && chromosome instanceof FloatChromosomeSpec;
36
	}
37
38
	@Override
39
	public FloatChromosome mutate(final MutationPolicy mutationPolicy, final Chromosome chromosome) {
40
		Objects.requireNonNull(mutationPolicy);
41
		Objects.requireNonNull(chromosome);
42
		Validate.isInstanceOf(CreepMutation.class, mutationPolicy);
43
		Validate.isInstanceOf(FloatChromosome.class, chromosome);
44
45
		final var floatChromosome = (FloatChromosome) chromosome;
46
		final var creepMutation = (CreepMutation) mutationPolicy;
47
48 1 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getMinValue → KILLED
		final var minValue = floatChromosome.getMinValue();
49 1 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getMaxValue → KILLED
		final var maxValue = floatChromosome.getMaxValue();
50 1 1. mutate : removed call to net/bmahe/genetics4j/core/spec/mutation/CreepMutation::distribution → KILLED
		final Distribution distribution = creepMutation.distribution();
51
52
		final Supplier<Float> distributionValueSupplier = DistributionUtils
53 1 1. mutate : removed call to net/bmahe/genetics4j/core/util/DistributionUtils::distributionFloatValueSupplier → KILLED
				.distributionFloatValueSupplier(randomGenerator, minValue, maxValue, distribution);
54
55 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/FloatChromosome::getNumAlleles → KILLED
4. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getValues → KILLED
		final float[] newValues = Arrays.copyOf(floatChromosome.getValues(), floatChromosome.getNumAlleles());
56
57 3 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::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(floatChromosome.getNumAlleles());
58 3 1. mutate : removed call to java/lang/Float::floatValue → KILLED
2. mutate : Replaced float addition with subtraction → KILLED
3. mutate : removed call to java/util/function/Supplier::get → KILLED
		newValues[alleleFlipIndex] += distributionValueSupplier.get();
59
60 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) {
61
			newValues[alleleFlipIndex] = maxValue;
62 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) {
63
			newValues[alleleFlipIndex] = minValue;
64
		}
65
66 2 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getSize → KILLED
2. mutate : replaced return value with null for net/bmahe/genetics4j/core/mutation/chromosome/creepmutation/FloatChromosomeCreepMutationHandler::mutate → KILLED
		return new FloatChromosome(floatChromosome.getSize(),
67 1 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getMinValue → SURVIVED
				floatChromosome.getMinValue(),
68 2 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getMaxValue → SURVIVED
2. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::<init> → KILLED
				floatChromosome.getMaxValue(),
69
				newValues);
70
	}
71
}

Mutations

27

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

35

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

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

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

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

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

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

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

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

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

48

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

49

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

50

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

53

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

55

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.FloatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.FloatChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed call to java/util/Arrays::copyOf → KILLED

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

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

57

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.FloatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.FloatChromosomeCreepMutationHandlerTest]/[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.FloatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.FloatChromosomeCreepMutationHandlerTest]/[method:mutateValidateAboveMax()]
removed call to java/util/random/RandomGenerator::nextInt → KILLED

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

58

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

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

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

60

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.FloatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.FloatChromosomeCreepMutationHandlerTest]/[method:mutateValidateBelowMin()]
removed conditional - replaced comparison check with true → KILLED

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

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

62

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.FloatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.FloatChromosomeCreepMutationHandlerTest]/[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.FloatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.creepmutation.FloatChromosomeCreepMutationHandlerTest]/[method:mutateValidate()]
removed conditional - replaced comparison check with true → KILLED

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

66

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

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

67

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

68

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

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

Active mutators

Tests examined


Report generated by PIT 1.25.7 support