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 2.2 |
|
32 |
1.1 2.2 |
|
45 |
1.1 |
|
47 |
1.1 |
|
48 |
1.1 2.2 3.3 4.4 5.5 |
|
49 |
1.1 2.2 3.3 |
|
51 |
1.1 2.2 3.3 4.4 |
|
54 |
1.1 |