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