TarpeianMethod.java

1
package net.bmahe.genetics4j.gp.postevaluationprocess;
2
3
import java.util.function.Function;
4
import java.util.random.RandomGenerator;
5
6
import org.apache.commons.lang3.Validate;
7
import org.immutables.value.Value;
8
9
import net.bmahe.genetics4j.core.Genotype;
10
import net.bmahe.genetics4j.core.Population;
11
import net.bmahe.genetics4j.core.chromosomes.TreeChromosome;
12
13
@Value.Immutable
14
public abstract class TarpeianMethod implements Function<Population<Double>, Population<Double>> {
15
16
	@Value.Parameter
17
	public abstract RandomGenerator randomGenerator();
18
19
	@Value.Parameter
20
	public abstract Function<Genotype, Integer> sizeFunction();
21
22
	@Value.Parameter
23
	public abstract double probability();
24
25
	@Value.Parameter
26
	public abstract double newValue();
27
28
	@Value.Check
29
	protected void check() {
30
		Validate.inclusiveBetween(0.0d, 1.0d, probability());
31
	}
32
33
	@Override
34
	public Population<Double> apply(final Population<Double> population) {
35
		Validate.notNull(population);
36
37 4 1. apply : removed conditional - replaced equality check with true → NO_COVERAGE
2. apply : negated conditional → NO_COVERAGE
3. apply : removed conditional - replaced equality check with false → NO_COVERAGE
4. apply : removed call to net/bmahe/genetics4j/core/Population::isEmpty → NO_COVERAGE
		if (population.isEmpty()) {
38 1 1. apply : replaced return value with null for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::apply → NO_COVERAGE
			return population;
39
		}
40
41 1 1. apply : removed call to net/bmahe/genetics4j/core/Population::getAllGenotypes → NO_COVERAGE
		final double averageSize = population.getAllGenotypes()
42 1 1. apply : removed call to java/util/List::stream → NO_COVERAGE
				.stream()
43 6 1. lambda$apply$0 : replaced Integer return value with 0 for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::lambda$apply$0 → NO_COVERAGE
2. lambda$apply$0 : removed call to net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::sizeFunction → NO_COVERAGE
3. apply : replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE
4. apply : removed call to java/util/stream/Stream::map → NO_COVERAGE
5. lambda$apply$0 : replaced call to java/util/function/Function::apply with argument → NO_COVERAGE
6. lambda$apply$0 : removed call to java/util/function/Function::apply → NO_COVERAGE
				.map(genotype -> sizeFunction().apply(genotype))
44 3 1. lambda$apply$1 : removed call to java/lang/Integer::intValue → NO_COVERAGE
2. apply : removed call to java/util/stream/Stream::mapToInt → NO_COVERAGE
3. lambda$apply$1 : replaced int return with 0 for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::lambda$apply$1 → NO_COVERAGE
				.mapToInt(i -> i)
45 1 1. apply : removed call to java/util/stream/IntStream::average → NO_COVERAGE
				.average()
46 1 1. apply : removed call to java/util/OptionalDouble::getAsDouble → NO_COVERAGE
				.getAsDouble();
47
48 1 1. apply : removed call to net/bmahe/genetics4j/core/Population::<init> → NO_COVERAGE
		final Population<Double> newPopulation = new Population<>();
49 6 1. apply : negated conditional → NO_COVERAGE
2. apply : removed conditional - replaced comparison check with true → NO_COVERAGE
3. apply : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE
4. apply : changed conditional boundary → NO_COVERAGE
5. apply : Substituted 0 with 1 → NO_COVERAGE
6. apply : removed conditional - replaced comparison check with false → NO_COVERAGE
		for (int i = 0; i < population.size(); i++) {
50
51 1 1. apply : removed call to net/bmahe/genetics4j/core/Population::getGenotype → NO_COVERAGE
			final Genotype genotype = population.getGenotype(i);
52 4 1. apply : removed call to java/util/function/Function::apply → NO_COVERAGE
2. apply : removed call to java/lang/Integer::intValue → NO_COVERAGE
3. apply : replaced call to java/util/function/Function::apply with argument → NO_COVERAGE
4. apply : removed call to net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::sizeFunction → NO_COVERAGE
			final int size = sizeFunction().apply(genotype);
53
54 2 1. apply : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE
2. apply : removed call to java/lang/Double::doubleValue → NO_COVERAGE
			double fitness = population.getFitness(i);
55 11 1. apply : negated conditional → NO_COVERAGE
2. apply : removed conditional - replaced comparison check with true → NO_COVERAGE
3. apply : removed conditional - replaced comparison check with false → NO_COVERAGE
4. apply : removed call to java/util/random/RandomGenerator::nextDouble → NO_COVERAGE
5. apply : removed conditional - replaced comparison check with true → NO_COVERAGE
6. apply : changed conditional boundary → NO_COVERAGE
7. apply : negated conditional → NO_COVERAGE
8. apply : removed call to net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::randomGenerator → NO_COVERAGE
9. apply : removed conditional - replaced comparison check with false → NO_COVERAGE
10. apply : removed call to net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::probability → NO_COVERAGE
11. apply : changed conditional boundary → NO_COVERAGE
			if (size > averageSize && randomGenerator().nextDouble() < probability()) {
56 1 1. apply : removed call to net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::newValue → NO_COVERAGE
				fitness = newValue();
57
			}
58
59 2 1. apply : removed call to java/lang/Double::valueOf → NO_COVERAGE
2. apply : removed call to net/bmahe/genetics4j/core/Population::add → NO_COVERAGE
			newPopulation.add(genotype, fitness);
60
		}
61
62 1 1. apply : replaced return value with null for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::apply → NO_COVERAGE
		return newPopulation;
63
	}
64
65
	public static TarpeianMethod of(final RandomGenerator randomGenerator,
66
			final Function<Genotype, Integer> sizeFunction, final double probability, final double newValue) {
67 2 1. of : removed call to net/bmahe/genetics4j/gp/postevaluationprocess/ImmutableTarpeianMethod::of → NO_COVERAGE
2. of : replaced return value with null for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::of → NO_COVERAGE
		return ImmutableTarpeianMethod.of(randomGenerator, sizeFunction, probability, newValue);
68
	}
69
70
	public static TarpeianMethod ofTreeChromosome(final RandomGenerator randomGenerator, final int chromosomeIndex,
71
			final double probability, final double newValue) {
72
73 2 1. ofTreeChromosome : removed call to net/bmahe/genetics4j/gp/postevaluationprocess/ImmutableTarpeianMethod::of → NO_COVERAGE
2. ofTreeChromosome : replaced return value with null for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::ofTreeChromosome → NO_COVERAGE
		return ImmutableTarpeianMethod.of(randomGenerator,
74 4 1. lambda$ofTreeChromosome$2 : replaced Integer return value with 0 for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::lambda$ofTreeChromosome$2 → NO_COVERAGE
2. lambda$ofTreeChromosome$2 : removed call to net/bmahe/genetics4j/core/chromosomes/TreeChromosome::getSize → NO_COVERAGE
3. lambda$ofTreeChromosome$2 : removed call to net/bmahe/genetics4j/core/Genotype::getChromosome → NO_COVERAGE
4. lambda$ofTreeChromosome$2 : removed call to java/lang/Integer::valueOf → NO_COVERAGE
				(genotype) -> genotype.getChromosome(chromosomeIndex, TreeChromosome.class).getSize(),
75
				probability,
76
				newValue);
77
	}
78
}

Mutations

37

1.1
Location : apply
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

2.2
Location : apply
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : apply
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

4.4
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::isEmpty → NO_COVERAGE

38

1.1
Location : apply
Killed by : none
replaced return value with null for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::apply → NO_COVERAGE

41

1.1
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::getAllGenotypes → NO_COVERAGE

42

1.1
Location : apply
Killed by : none
removed call to java/util/List::stream → NO_COVERAGE

43

1.1
Location : lambda$apply$0
Killed by : none
replaced Integer return value with 0 for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::lambda$apply$0 → NO_COVERAGE

2.2
Location : lambda$apply$0
Killed by : none
removed call to net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::sizeFunction → NO_COVERAGE

3.3
Location : apply
Killed by : none
replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE

4.4
Location : apply
Killed by : none
removed call to java/util/stream/Stream::map → NO_COVERAGE

5.5
Location : lambda$apply$0
Killed by : none
replaced call to java/util/function/Function::apply with argument → NO_COVERAGE

6.6
Location : lambda$apply$0
Killed by : none
removed call to java/util/function/Function::apply → NO_COVERAGE

44

1.1
Location : lambda$apply$1
Killed by : none
removed call to java/lang/Integer::intValue → NO_COVERAGE

2.2
Location : apply
Killed by : none
removed call to java/util/stream/Stream::mapToInt → NO_COVERAGE

3.3
Location : lambda$apply$1
Killed by : none
replaced int return with 0 for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::lambda$apply$1 → NO_COVERAGE

45

1.1
Location : apply
Killed by : none
removed call to java/util/stream/IntStream::average → NO_COVERAGE

46

1.1
Location : apply
Killed by : none
removed call to java/util/OptionalDouble::getAsDouble → NO_COVERAGE

48

1.1
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::<init> → NO_COVERAGE

49

1.1
Location : apply
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : apply
Killed by : none
removed conditional - replaced comparison check with true → NO_COVERAGE

3.3
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE

4.4
Location : apply
Killed by : none
changed conditional boundary → NO_COVERAGE

5.5
Location : apply
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

6.6
Location : apply
Killed by : none
removed conditional - replaced comparison check with false → NO_COVERAGE

51

1.1
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::getGenotype → NO_COVERAGE

52

1.1
Location : apply
Killed by : none
removed call to java/util/function/Function::apply → NO_COVERAGE

2.2
Location : apply
Killed by : none
removed call to java/lang/Integer::intValue → NO_COVERAGE

3.3
Location : apply
Killed by : none
replaced call to java/util/function/Function::apply with argument → NO_COVERAGE

4.4
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::sizeFunction → NO_COVERAGE

54

1.1
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE

2.2
Location : apply
Killed by : none
removed call to java/lang/Double::doubleValue → NO_COVERAGE

55

1.1
Location : apply
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : apply
Killed by : none
removed conditional - replaced comparison check with true → NO_COVERAGE

3.3
Location : apply
Killed by : none
removed conditional - replaced comparison check with false → NO_COVERAGE

4.4
Location : apply
Killed by : none
removed call to java/util/random/RandomGenerator::nextDouble → NO_COVERAGE

5.5
Location : apply
Killed by : none
removed conditional - replaced comparison check with true → NO_COVERAGE

6.6
Location : apply
Killed by : none
changed conditional boundary → NO_COVERAGE

7.7
Location : apply
Killed by : none
negated conditional → NO_COVERAGE

8.8
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::randomGenerator → NO_COVERAGE

9.9
Location : apply
Killed by : none
removed conditional - replaced comparison check with false → NO_COVERAGE

10.10
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::probability → NO_COVERAGE

11.11
Location : apply
Killed by : none
changed conditional boundary → NO_COVERAGE

56

1.1
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::newValue → NO_COVERAGE

59

1.1
Location : apply
Killed by : none
removed call to java/lang/Double::valueOf → NO_COVERAGE

2.2
Location : apply
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::add → NO_COVERAGE

62

1.1
Location : apply
Killed by : none
replaced return value with null for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::apply → NO_COVERAGE

67

1.1
Location : of
Killed by : none
removed call to net/bmahe/genetics4j/gp/postevaluationprocess/ImmutableTarpeianMethod::of → NO_COVERAGE

2.2
Location : of
Killed by : none
replaced return value with null for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::of → NO_COVERAGE

73

1.1
Location : ofTreeChromosome
Killed by : none
removed call to net/bmahe/genetics4j/gp/postevaluationprocess/ImmutableTarpeianMethod::of → NO_COVERAGE

2.2
Location : ofTreeChromosome
Killed by : none
replaced return value with null for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::ofTreeChromosome → NO_COVERAGE

74

1.1
Location : lambda$ofTreeChromosome$2
Killed by : none
replaced Integer return value with 0 for net/bmahe/genetics4j/gp/postevaluationprocess/TarpeianMethod::lambda$ofTreeChromosome$2 → NO_COVERAGE

2.2
Location : lambda$ofTreeChromosome$2
Killed by : none
removed call to net/bmahe/genetics4j/core/chromosomes/TreeChromosome::getSize → NO_COVERAGE

3.3
Location : lambda$ofTreeChromosome$2
Killed by : none
removed call to net/bmahe/genetics4j/core/Genotype::getChromosome → NO_COVERAGE

4.4
Location : lambda$ofTreeChromosome$2
Killed by : none
removed call to java/lang/Integer::valueOf → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.6