FloatChromosomeFactory.java

1
package net.bmahe.genetics4j.core.chromosomes.factory;
2
3
import java.util.function.Supplier;
4
import java.util.random.RandomGenerator;
5
6
import org.apache.commons.lang3.Validate;
7
8
import net.bmahe.genetics4j.core.chromosomes.FloatChromosome;
9
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
10
import net.bmahe.genetics4j.core.spec.chromosome.FloatChromosomeSpec;
11
import net.bmahe.genetics4j.core.util.DistributionUtils;
12
13
public class FloatChromosomeFactory implements ChromosomeFactory<FloatChromosome> {
14
15
	private final RandomGenerator randomGenerator;
16
17
	public FloatChromosomeFactory(final RandomGenerator _randomGenerator) {
18
		Validate.notNull(_randomGenerator);
19
20 1 1. <init> : Removed assignment to member variable randomGenerator → KILLED
		this.randomGenerator = _randomGenerator;
21
	}
22
23
	@Override
24
	public boolean canHandle(final ChromosomeSpec chromosomeSpec) {
25
		Validate.notNull(chromosomeSpec);
26
27 2 1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::canHandle → KILLED
2. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::canHandle → KILLED
		return chromosomeSpec instanceof FloatChromosomeSpec;
28
	}
29
30
	@Override
31
	public FloatChromosome generate(final ChromosomeSpec chromosomeSpec) {
32
		Validate.notNull(chromosomeSpec);
33
		Validate.isInstanceOf(FloatChromosomeSpec.class, chromosomeSpec);
34
35
		final FloatChromosomeSpec floatChromosomeSpec = (FloatChromosomeSpec) chromosomeSpec;
36
37 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::minValue → KILLED
		final var minValue = floatChromosomeSpec.minValue();
38 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::maxValue → KILLED
		final var maxValue = floatChromosomeSpec.maxValue();
39 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::distribution → KILLED
		final var distribution = floatChromosomeSpec.distribution();
40
41
		final Supplier<Float> generator = DistributionUtils
42 1 1. generate : removed call to net/bmahe/genetics4j/core/util/DistributionUtils::distributionFloatValueSupplier → KILLED
				.distributionFloatValueSupplier(randomGenerator, minValue, maxValue, distribution);
43
44 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED
		float[] values = new float[floatChromosomeSpec.size()];
45 6 1. generate : Substituted 0 with 1 → KILLED
2. generate : removed conditional - replaced comparison check with false → KILLED
3. generate : negated conditional → KILLED
4. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED
5. generate : removed conditional - replaced comparison check with true → KILLED
6. generate : changed conditional boundary → KILLED
		for (int i = 0; i < floatChromosomeSpec.size(); i++) {
46 2 1. generate : removed call to java/lang/Float::floatValue → KILLED
2. generate : removed call to java/util/function/Supplier::get → KILLED
			values[i] = generator.get();
47
		}
48
49 2 1. generate : replaced return value with null for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::generate → KILLED
2. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED
		return new FloatChromosome(floatChromosomeSpec.size(),
50 1 1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::minValue → SURVIVED
				floatChromosomeSpec.minValue(),
51 2 1. generate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::<init> → KILLED
2. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::maxValue → KILLED
				floatChromosomeSpec.maxValue(),
52
				values);
53
	}
54
}

Mutations

20

1.1
Location : <init>
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
Removed assignment to member variable randomGenerator → KILLED

27

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:canHandleTest()]
replaced boolean return with true for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::canHandle → KILLED

2.2
Location : canHandle
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:canHandleTest()]
replaced boolean return with false for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::canHandle → KILLED

37

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::minValue → KILLED

38

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::maxValue → KILLED

39

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::distribution → KILLED

42

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/util/DistributionUtils::distributionFloatValueSupplier → KILLED

44

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED

45

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
Substituted 0 with 1 → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed conditional - replaced comparison check with false → KILLED

3.3
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
negated conditional → KILLED

4.4
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED

5.5
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed conditional - replaced comparison check with true → KILLED

6.6
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
changed conditional boundary → KILLED

46

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to java/lang/Float::floatValue → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to java/util/function/Supplier::get → KILLED

49

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
replaced return value with null for net/bmahe/genetics4j/core/chromosomes/factory/FloatChromosomeFactory::generate → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::size → KILLED

50

1.1
Location : generate
Killed by : none
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::minValue → SURVIVED
Covering tests

51

1.1
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::<init> → KILLED

2.2
Location : generate
Killed by : net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.FloatChromosomeFactoryTest]/[method:generateTest()]
removed call to net/bmahe/genetics4j/core/spec/chromosome/FloatChromosomeSpec::maxValue → KILLED

Active mutators

Tests examined


Report generated by PIT 1.19.6