SelectAllPolicyHandler.java

1
package net.bmahe.genetics4j.core.selection;
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.spec.AbstractEAConfiguration;
10
import net.bmahe.genetics4j.core.spec.AbstractEAExecutionContext;
11
import net.bmahe.genetics4j.core.spec.selection.SelectAll;
12
import net.bmahe.genetics4j.core.spec.selection.SelectionPolicy;
13
14
public class SelectAllPolicyHandler<T extends Comparable<T>> implements SelectionPolicyHandler<T> {
15
16
	public SelectAllPolicyHandler() {
17
	}
18
19
	@Override
20
	public boolean canHandle(final SelectionPolicy selectionPolicy) {
21
		Validate.notNull(selectionPolicy);
22 2 1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler::canHandle → NO_COVERAGE
2. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler::canHandle → NO_COVERAGE
		return selectionPolicy instanceof SelectAll;
23
	}
24
25
	@Override
26
	public Selector<T> resolve(AbstractEAExecutionContext<T> eaExecutionContext,
27
			AbstractEAConfiguration<T> eaConfiguration, SelectionPolicyHandlerResolver<T> selectionPolicyHandlerResolver,
28
			SelectionPolicy selectionPolicy) {
29
		Validate.notNull(selectionPolicy);
30
		Validate.isInstanceOf(SelectAll.class, selectionPolicy);
31
32 2 1. resolve : removed call to net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler$1::<init> → KILLED
2. resolve : replaced return value with null for net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler::resolve → KILLED
		return new Selector<T>() {
33
34
			@Override
35
			public Population<T> select(AbstractEAConfiguration<T> eaConfiguration, int numIndividuals,
36
					List<Genotype> population, List<T> fitnessScore) {
37
				Validate.notNull(eaConfiguration);
38
				Validate.notNull(population);
39
				Validate.notNull(fitnessScore);
40
				Validate.isTrue(numIndividuals > 0);
41
				Validate.isTrue(population.size() > 0);
42
				Validate.isTrue(fitnessScore.size() > 0);
43
				Validate.isTrue(fitnessScore.size() == population.size());
44
45 1 1. select : removed call to net/bmahe/genetics4j/core/Population::<init> → KILLED
				final Population<T> selected = new Population<>();
46
47 1 1. select : Substituted 0 with 1 → KILLED
				int i = 0;
48 5 1. select : removed call to net/bmahe/genetics4j/core/Population::size → TIMED_OUT
2. select : removed conditional - replaced comparison check with true → TIMED_OUT
3. select : changed conditional boundary → KILLED
4. select : removed conditional - replaced comparison check with false → KILLED
5. select : negated conditional → KILLED
				while (selected.size() < numIndividuals) {
49 3 1. select : removed call to net/bmahe/genetics4j/core/Population::add → TIMED_OUT
2. select : removed call to java/util/List::get → KILLED
3. select : removed call to java/util/List::get → KILLED
					selected.add(population.get(i), fitnessScore.get(i));
50
51 4 1. select : Replaced integer modulus with multiplication → KILLED
2. select : Replaced integer addition with subtraction → KILLED
3. select : removed call to java/util/List::size → KILLED
4. select : Substituted 1 with 0 → KILLED
					i = (i + 1) % population.size();
52
				}
53
54 1 1. select : replaced return value with null for net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler$1::select → KILLED
				return selected;
55
			}
56
		};
57
	}
58
}

Mutations

22

1.1
Location : canHandle
Killed by : none
replaced boolean return with true for net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler::canHandle → NO_COVERAGE

2.2
Location : canHandle
Killed by : none
replaced boolean return with false for net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler::canHandle → NO_COVERAGE

32

1.1
Location : resolve
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
removed call to net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler$1::<init> → KILLED

2.2
Location : resolve
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
replaced return value with null for net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler::resolve → KILLED

45

1.1
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
removed call to net/bmahe/genetics4j/core/Population::<init> → KILLED

47

1.1
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
Substituted 0 with 1 → KILLED

48

1.1
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
changed conditional boundary → KILLED

2.2
Location : select
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::size → TIMED_OUT

3.3
Location : select
Killed by : none
removed conditional - replaced comparison check with true → TIMED_OUT

4.4
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
removed conditional - replaced comparison check with false → KILLED

5.5
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
negated conditional → KILLED

49

1.1
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
removed call to java/util/List::get → KILLED

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

3.3
Location : select
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::add → TIMED_OUT

51

1.1
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
Replaced integer modulus with multiplication → KILLED

2.2
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
Replaced integer addition with subtraction → KILLED

3.3
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
removed call to java/util/List::size → KILLED

4.4
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
Substituted 1 with 0 → KILLED

54

1.1
Location : select
Killed by : net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]
replaced return value with null for net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler$1::select → KILLED

Active mutators

Tests examined


Report generated by PIT 1.19.6