FloatChromosomeRandomMutationHandler.java

1
package net.bmahe.genetics4j.core.mutation.chromosome.randommutation;
2
3
import java.util.Arrays;
4
import java.util.Objects;
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.FloatChromosome;
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.FloatChromosomeSpec;
14
import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy;
15
import net.bmahe.genetics4j.core.spec.mutation.RandomMutation;
16
17
public class FloatChromosomeRandomMutationHandler implements ChromosomeMutationHandler<FloatChromosome> {
18
19
	private final RandomGenerator randomGenerator;
20
21
	public FloatChromosomeRandomMutationHandler(final RandomGenerator _randomGenerator) {
22
		Objects.requireNonNull(_randomGenerator);
23
24 1 1. <init> : Removed assignment to member variable randomGenerator → KILLED
		this.randomGenerator = _randomGenerator;
25
	}
26
27
	@Override
28
	public boolean canHandle(final MutationPolicy mutationPolicy, final ChromosomeSpec chromosome) {
29
		Objects.requireNonNull(mutationPolicy);
30
		Objects.requireNonNull(chromosome);
31
32 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 : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/chromosome/randommutation/FloatChromosomeRandomMutationHandler::canHandle → KILLED
5. canHandle : Substituted 0 with 1 → KILLED
6. canHandle : Substituted 1 with 0 → KILLED
7. canHandle : negated conditional → KILLED
8. canHandle : removed conditional - replaced equality check with false → KILLED
9. canHandle : removed conditional - replaced equality check with true → KILLED
		return mutationPolicy instanceof RandomMutation && chromosome instanceof FloatChromosomeSpec;
33
	}
34
35
	@Override
36
	public FloatChromosome mutate(final MutationPolicy mutationPolicy, final Chromosome chromosome) {
37
		Objects.requireNonNull(mutationPolicy);
38
		Objects.requireNonNull(chromosome);
39
		Validate.isInstanceOf(RandomMutation.class, mutationPolicy);
40
		Validate.isInstanceOf(FloatChromosome.class, chromosome);
41
42
		final FloatChromosome floatChromosome = (FloatChromosome) chromosome;
43 1 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getMinValue → KILLED
		final float minValue = floatChromosome.getMinValue();
44 1 1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getMaxValue → KILLED
		final float maxValue = floatChromosome.getMaxValue();
45
46 4 1. mutate : replaced call to java/util/Arrays::copyOf with argument → SURVIVED
2. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getNumAlleles → KILLED
3. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getValues → KILLED
4. mutate : removed call to java/util/Arrays::copyOf → KILLED
		final float[] newValues = Arrays.copyOf(floatChromosome.getValues(), floatChromosome.getNumAlleles());
47
48 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());
49 4 1. mutate : Replaced float addition with subtraction → KILLED
2. mutate : Replaced float subtraction with addition → KILLED
3. mutate : Replaced float multiplication with division → KILLED
4. mutate : removed call to java/util/random/RandomGenerator::nextFloat → KILLED
		newValues[alleleFlipIndex] = minValue + randomGenerator.nextFloat() * (maxValue - minValue);
50
51 3 1. mutate : replaced return value with null for net/bmahe/genetics4j/core/mutation/chromosome/randommutation/FloatChromosomeRandomMutationHandler::mutate → KILLED
2. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::<init> → KILLED
3. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getSize → KILLED
		return new FloatChromosome(floatChromosome.getSize(), minValue, maxValue, newValues);
52
	}
53
}

Mutations

24

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

32

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

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

3.3
Location : canHandle
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest]/[method:canHandle()]
replaced boolean return with true for net/bmahe/genetics4j/core/mutation/chromosome/randommutation/FloatChromosomeRandomMutationHandler::canHandle → KILLED

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

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

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

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

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

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

43

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

44

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

46

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest]/[method:mutateValidate()]
removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getNumAlleles → KILLED

2.2
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest]/[method:mutateValidate()]
removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getValues → KILLED

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

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

48

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

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

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

49

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest]/[method:mutateValidate()]
Replaced float addition with subtraction → KILLED

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

3.3
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest]/[method:mutateValidate()]
Replaced float multiplication with division → KILLED

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

51

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest]/[method:mutateValidate()]
replaced return value with null for net/bmahe/genetics4j/core/mutation/chromosome/randommutation/FloatChromosomeRandomMutationHandler::mutate → KILLED

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

3.3
Location : mutate
Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.FloatChromosomeRandomMutationHandlerTest]/[method:mutateValidate()]
removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getSize → KILLED

Active mutators

Tests examined


Report generated by PIT 1.25.7 support