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 → NO_COVERAGE 2. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/selection/SelectAllPolicyHandler::canHandle → NO_COVERAGE |
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<T>() { |
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.size() > 0); | |
43 | Validate.isTrue(fitnessScore.size() > 0); | |
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 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) { |
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 : removed call to java/util/List::size → KILLED 3. select : Replaced integer addition with subtraction → 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 2.2 |
|
33 |
1.1 2.2 |
|
46 |
1.1 |
|
48 |
1.1 |
|
49 |
1.1 2.2 3.3 4.4 5.5 |
|
50 |
1.1 2.2 3.3 |
|
52 |
1.1 2.2 3.3 4.4 |
|
55 |
1.1 |