EvolutionResult.java

1
package net.bmahe.genetics4j.core.spec;
2
3
import java.util.Comparator;
4
import java.util.List;
5
import java.util.Optional;
6
import java.util.stream.IntStream;
7
8
import org.apache.commons.lang3.Validate;
9
import org.immutables.value.Value;
10
11
import net.bmahe.genetics4j.core.Genotype;
12
13
@Value.Immutable
14
public abstract class EvolutionResult<T extends Comparable<T>> {
15
16
	@Value.Parameter
17
	public abstract AbstractEAConfiguration<T> eaConfiguration();
18
19
	@Value.Parameter
20
	public abstract long generation();
21
22
	@Value.Parameter
23
	public abstract List<Genotype> population();
24
25
	@Value.Parameter
26
	public abstract List<T> fitness();
27
28
	@Value.Derived
29
	public GenotypeFitness<T> bestIndividual() {
30
31 1 1. bestIndividual : removed call to net/bmahe/genetics4j/core/spec/EvolutionResult::population → KILLED
		final List<Genotype> population = population();
32 1 1. bestIndividual : removed call to net/bmahe/genetics4j/core/spec/EvolutionResult::fitness → KILLED
		final List<T> fitness = fitness();
33
34
		Validate.notNull(population);
35
		Validate.notNull(fitness);
36
		Validate.isTrue(population.size() == fitness.size());
37
		Validate.isTrue(population.size() > 0);
38
39 2 1. bestIndividual : removed call to net/bmahe/genetics4j/core/spec/AbstractEAConfiguration::fitnessComparator → KILLED
2. bestIndividual : removed call to net/bmahe/genetics4j/core/spec/EvolutionResult::eaConfiguration → KILLED
		final Comparator<T> comparator = eaConfiguration().fitnessComparator();
40
41 3 1. bestIndividual : Substituted 0 with 1 → SURVIVED
2. bestIndividual : removed call to java/util/List::size → KILLED
3. bestIndividual : removed call to java/util/stream/IntStream::range → KILLED
		final Optional<Integer> bestIndexOpt = IntStream.range(0, fitness.size())
42 1 1. bestIndividual : removed call to java/util/stream/IntStream::boxed → KILLED
				.boxed()
43 7 1. lambda$bestIndividual$0 : replaced int return with 0 for net/bmahe/genetics4j/core/spec/EvolutionResult::lambda$bestIndividual$0 → SURVIVED
2. lambda$bestIndividual$0 : removed call to java/lang/Integer::intValue → SURVIVED
3. lambda$bestIndividual$0 : removed call to java/lang/Integer::intValue → SURVIVED
4. lambda$bestIndividual$0 : removed call to java/util/Comparator::compare → SURVIVED
5. lambda$bestIndividual$0 : removed call to java/util/List::get → KILLED
6. bestIndividual : removed call to java/util/stream/Stream::max → KILLED
7. lambda$bestIndividual$0 : removed call to java/util/List::get → KILLED
				.max((a, b) -> comparator.compare(fitness.get(a), fitness.get(b)));
44
45 1 1. bestIndividual : removed call to java/util/Optional::orElseThrow → KILLED
		final Integer bestIndex = bestIndexOpt.orElseThrow(
46 2 1. lambda$bestIndividual$1 : replaced return value with null for net/bmahe/genetics4j/core/spec/EvolutionResult::lambda$bestIndividual$1 → NO_COVERAGE
2. lambda$bestIndividual$1 : removed call to java/lang/IllegalStateException::<init> → NO_COVERAGE
				() -> new IllegalStateException("Couldn't find a best entry despite having a non-zero population"));
47
48 6 1. bestIndividual : removed call to java/lang/Integer::intValue → SURVIVED
2. bestIndividual : removed call to java/lang/Integer::intValue → SURVIVED
3. bestIndividual : removed call to java/util/List::get → KILLED
4. bestIndividual : removed call to net/bmahe/genetics4j/core/spec/GenotypeFitness::of → KILLED
5. bestIndividual : replaced return value with null for net/bmahe/genetics4j/core/spec/EvolutionResult::bestIndividual → KILLED
6. bestIndividual : removed call to java/util/List::get → KILLED
		return GenotypeFitness.of(population.get(bestIndex), fitness.get(bestIndex));
49
	}
50
51
	public Genotype bestGenotype() {
52 3 1. bestGenotype : removed call to net/bmahe/genetics4j/core/spec/GenotypeFitness::genotype → KILLED
2. bestGenotype : replaced return value with null for net/bmahe/genetics4j/core/spec/EvolutionResult::bestGenotype → KILLED
3. bestGenotype : removed call to net/bmahe/genetics4j/core/spec/EvolutionResult::bestIndividual → KILLED
		return bestIndividual().genotype();
53
	}
54
55
	public T bestFitness() {
56 3 1. bestFitness : removed call to net/bmahe/genetics4j/core/spec/EvolutionResult::bestIndividual → KILLED
2. bestFitness : replaced return value with null for net/bmahe/genetics4j/core/spec/EvolutionResult::bestFitness → KILLED
3. bestFitness : removed call to net/bmahe/genetics4j/core/spec/GenotypeFitness::fitness → KILLED
		return bestIndividual().fitness();
57
	}
58
}

Mutations

31

1.1
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to net/bmahe/genetics4j/core/spec/EvolutionResult::population → KILLED

32

1.1
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to net/bmahe/genetics4j/core/spec/EvolutionResult::fitness → KILLED

39

1.1
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to net/bmahe/genetics4j/core/spec/AbstractEAConfiguration::fitnessComparator → KILLED

2.2
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to net/bmahe/genetics4j/core/spec/EvolutionResult::eaConfiguration → KILLED

41

1.1
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to java/util/List::size → KILLED

2.2
Location : bestIndividual
Killed by : none
Substituted 0 with 1 → SURVIVED
Covering tests

3.3
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to java/util/stream/IntStream::range → KILLED

42

1.1
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to java/util/stream/IntStream::boxed → KILLED

43

1.1
Location : lambda$bestIndividual$0
Killed by : none
replaced int return with 0 for net/bmahe/genetics4j/core/spec/EvolutionResult::lambda$bestIndividual$0 → SURVIVED
Covering tests

2.2
Location : lambda$bestIndividual$0
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to java/util/List::get → KILLED

3.3
Location : lambda$bestIndividual$0
Killed by : none
removed call to java/lang/Integer::intValue → SURVIVED Covering tests

4.4
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to java/util/stream/Stream::max → KILLED

5.5
Location : lambda$bestIndividual$0
Killed by : none
removed call to java/lang/Integer::intValue → SURVIVED Covering tests

6.6
Location : lambda$bestIndividual$0
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to java/util/List::get → KILLED

7.7
Location : lambda$bestIndividual$0
Killed by : none
removed call to java/util/Comparator::compare → SURVIVED Covering tests

45

1.1
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to java/util/Optional::orElseThrow → KILLED

46

1.1
Location : lambda$bestIndividual$1
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/spec/EvolutionResult::lambda$bestIndividual$1 → NO_COVERAGE

2.2
Location : lambda$bestIndividual$1
Killed by : none
removed call to java/lang/IllegalStateException::<init> → NO_COVERAGE

48

1.1
Location : bestIndividual
Killed by : none
removed call to java/lang/Integer::intValue → SURVIVED
Covering tests

2.2
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to java/util/List::get → KILLED

3.3
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to net/bmahe/genetics4j/core/spec/GenotypeFitness::of → KILLED

4.4
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
replaced return value with null for net/bmahe/genetics4j/core/spec/EvolutionResult::bestIndividual → KILLED

5.5
Location : bestIndividual
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to java/util/List::get → KILLED

6.6
Location : bestIndividual
Killed by : none
removed call to java/lang/Integer::intValue → SURVIVED Covering tests

52

1.1
Location : bestGenotype
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithBitChromosome()]
removed call to net/bmahe/genetics4j/core/spec/GenotypeFitness::genotype → KILLED

2.2
Location : bestGenotype
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithBitChromosome()]
replaced return value with null for net/bmahe/genetics4j/core/spec/EvolutionResult::bestGenotype → KILLED

3.3
Location : bestGenotype
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithBitChromosome()]
removed call to net/bmahe/genetics4j/core/spec/EvolutionResult::bestIndividual → KILLED

56

1.1
Location : bestFitness
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to net/bmahe/genetics4j/core/spec/EvolutionResult::bestIndividual → KILLED

2.2
Location : bestFitness
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
replaced return value with null for net/bmahe/genetics4j/core/spec/EvolutionResult::bestFitness → KILLED

3.3
Location : bestFitness
Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]
removed call to net/bmahe/genetics4j/core/spec/GenotypeFitness::fitness → KILLED

Active mutators

Tests examined


Report generated by PIT 1.19.6