GenerationalReplacementImpl.java

1
package net.bmahe.genetics4j.core.replacement;
2
3
import java.util.List;
4
5
import org.apache.commons.lang3.Validate;
6
7
import net.bmahe.genetics4j.core.Genotype;
8
import net.bmahe.genetics4j.core.Population;
9
import net.bmahe.genetics4j.core.selection.Selector;
10
import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration;
11
import net.bmahe.genetics4j.core.spec.replacement.GenerationalReplacement;
12
13
public class GenerationalReplacementImpl<T extends Comparable<T>> implements ReplacementStrategyImplementor<T> {
14
15
	private final GenerationalReplacement generationalReplacementSpec;
16
	private final Selector<T> offspringSelector;
17
18
	public GenerationalReplacementImpl(final GenerationalReplacement _elistismSpec,
19
			final Selector<T> _offspringSelector) {
20
		Validate.notNull(_elistismSpec);
21
22 1 1. <init> : Removed assignment to member variable generationalReplacementSpec → NO_COVERAGE
		this.generationalReplacementSpec = _elistismSpec;
23 1 1. <init> : Removed assignment to member variable offspringSelector → NO_COVERAGE
		this.offspringSelector = _offspringSelector;
24
	}
25
26
	@Override
27
	public Population<T> select(final AbstractEAConfiguration<T> eaConfiguration, final int numIndividuals,
28
			final List<Genotype> population, final List<T> populationScores, final List<Genotype> offsprings,
29
			final List<T> offspringScores) {
30
		Validate.notNull(eaConfiguration);
31
		Validate.isTrue(numIndividuals > 0);
32
		Validate.notNull(population);
33
		Validate.notNull(populationScores);
34
		Validate.isTrue(population.size() == populationScores.size());
35
		Validate.notNull(offsprings);
36
		Validate.notNull(offspringScores);
37
		Validate.isTrue(offsprings.size() == offspringScores.size());
38
39 1 1. select : removed call to net/bmahe/genetics4j/core/Population::<init> → NO_COVERAGE
		final Population<T> selected = new Population<>();
40
41
		final Population<T> selectedOffspring = offspringSelector
42 1 1. select : removed call to net/bmahe/genetics4j/core/selection/Selector::select → NO_COVERAGE
				.select(eaConfiguration, numIndividuals, offsprings, offspringScores);
43 1 1. select : removed call to net/bmahe/genetics4j/core/Population::addAll → NO_COVERAGE
		selected.addAll(selectedOffspring);
44
45 1 1. select : replaced return value with null for net/bmahe/genetics4j/core/replacement/GenerationalReplacementImpl::select → NO_COVERAGE
		return selected;
46
	}
47
}

Mutations

22

1.1
Location : <init>
Killed by : none
Removed assignment to member variable generationalReplacementSpec → NO_COVERAGE

23

1.1
Location : <init>
Killed by : none
Removed assignment to member variable offspringSelector → NO_COVERAGE

39

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

42

1.1
Location : select
Killed by : none
removed call to net/bmahe/genetics4j/core/selection/Selector::select → NO_COVERAGE

43

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

45

1.1
Location : select
Killed by : none
replaced return value with null for net/bmahe/genetics4j/core/replacement/GenerationalReplacementImpl::select → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.6