|
1
|
|
package net.bmahe.genetics4j.core.selection; |
|
2
|
|
|
|
3
|
|
import java.util.List; |
|
4
|
|
import java.util.Objects; |
|
5
|
|
import java.util.stream.Collectors; |
|
6
|
|
|
|
7
|
|
import org.apache.commons.lang3.Validate; |
|
8
|
|
|
|
9
|
|
import net.bmahe.genetics4j.core.Genotype; |
|
10
|
|
import net.bmahe.genetics4j.core.Population; |
|
11
|
|
import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; |
|
12
|
|
import net.bmahe.genetics4j.core.spec.AbstractEAExecutionContext; |
|
13
|
|
import net.bmahe.genetics4j.core.spec.selection.MultiSelections; |
|
14
|
|
import net.bmahe.genetics4j.core.spec.selection.SelectionPolicy; |
|
15
|
|
|
|
16
|
|
public class MultiSelectionsPolicyHandler<T extends Comparable<T>> implements SelectionPolicyHandler<T> { |
|
17
|
|
|
|
18
|
|
public MultiSelectionsPolicyHandler() { |
|
19
|
|
} |
|
20
|
|
|
|
21
|
|
@Override |
|
22
|
|
public boolean canHandle(final SelectionPolicy selectionPolicy) { |
|
23
|
|
Objects.requireNonNull(selectionPolicy); |
|
24
|
2
1. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler::canHandle → KILLED
2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler::canHandle → KILLED
|
return selectionPolicy instanceof MultiSelections; |
|
25
|
|
} |
|
26
|
|
|
|
27
|
|
@Override |
|
28
|
|
public Selector<T> resolve(final AbstractEAExecutionContext<T> eaExecutionContext, |
|
29
|
|
final AbstractEAConfiguration<T> eaConfiguration, |
|
30
|
|
final SelectionPolicyHandlerResolver<T> selectionPolicyHandlerResolver, |
|
31
|
|
final SelectionPolicy selectionPolicy) { |
|
32
|
|
Objects.requireNonNull(selectionPolicy); |
|
33
|
|
Validate.isInstanceOf(MultiSelections.class, selectionPolicy); |
|
34
|
|
|
|
35
|
|
final MultiSelections multiSelections = (MultiSelections) selectionPolicy; |
|
36
|
1
1. resolve : removed call to net/bmahe/genetics4j/core/spec/selection/MultiSelections::selectionPolicies → KILLED
|
final List<SelectionPolicy> selectionPolicies = multiSelections.selectionPolicies(); |
|
37
|
|
Validate.isTrue(selectionPolicies.isEmpty() == false); |
|
38
|
|
|
|
39
|
3
1. resolve : removed call to java/util/stream/Stream::map → KILLED
2. resolve : replaced call to java/util/stream/Stream::map with receiver → KILLED
3. resolve : removed call to java/util/List::stream → KILLED
|
final List<Selector<T>> selectors = selectionPolicies.stream().map(sp -> { |
|
40
|
|
|
|
41
|
1
1. lambda$resolve$0 : removed call to net/bmahe/genetics4j/core/selection/SelectionPolicyHandlerResolver::resolve → KILLED
|
final SelectionPolicyHandler<T> spHandler = selectionPolicyHandlerResolver.resolve(sp); |
|
42
|
2
1. lambda$resolve$0 : removed call to net/bmahe/genetics4j/core/selection/SelectionPolicyHandler::resolve → KILLED
2. lambda$resolve$0 : replaced return value with null for net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler::lambda$resolve$0 → KILLED
|
return spHandler.resolve(eaExecutionContext, eaConfiguration, selectionPolicyHandlerResolver, sp); |
|
43
|
2
1. resolve : removed call to java/util/stream/Stream::collect → KILLED
2. resolve : removed call to java/util/stream/Collectors::toList → KILLED
|
}).collect(Collectors.toList()); |
|
44
|
|
|
|
45
|
2
1. resolve : replaced return value with null for net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler::resolve → KILLED
2. resolve : removed call to net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler$1::<init> → KILLED
|
return new Selector<>() { |
|
46
|
|
|
|
47
|
|
@Override |
|
48
|
|
public Population<T> select(final AbstractEAConfiguration<T> eaConfiguration, final long generation, |
|
49
|
|
final int numIndividuals, final List<Genotype> population, final List<T> fitnessScore) { |
|
50
|
2
1. select : Replaced integer division with multiplication → KILLED
2. select : removed call to java/util/List::size → KILLED
|
final int incrementSelection = numIndividuals / selectors.size(); |
|
51
|
|
|
|
52
|
1
1. select : removed call to net/bmahe/genetics4j/core/Population::<init> → KILLED
|
final Population<T> selectedIndividuals = new Population<>(); |
|
53
|
|
for (final Selector<T> selector : selectors) { |
|
54
|
1
1. select : removed call to net/bmahe/genetics4j/core/Population::addAll → SURVIVED
|
selectedIndividuals.addAll( |
|
55
|
1
1. select : removed call to net/bmahe/genetics4j/core/selection/Selector::select → KILLED
|
selector.select(eaConfiguration, generation, incrementSelection, population, fitnessScore)); |
|
56
|
|
} |
|
57
|
|
|
|
58
|
1
1. select : Substituted 0 with 1 → SURVIVED
|
int i = 0; |
|
59
|
5
1. select : removed conditional - replaced comparison check with false → SURVIVED
2. select : removed call to net/bmahe/genetics4j/core/Population::size → TIMED_OUT
3. select : removed conditional - replaced comparison check with true → TIMED_OUT
4. select : negated conditional → TIMED_OUT
5. select : changed conditional boundary → KILLED
|
while (selectedIndividuals.size() < numIndividuals) { |
|
60
|
|
|
|
61
|
1
1. select : removed call to net/bmahe/genetics4j/core/Population::addAll → NO_COVERAGE
|
selectedIndividuals.addAll( |
|
62
|
1
1. select : removed call to java/util/List::get → NO_COVERAGE
|
selectors.get(i) |
|
63
|
1
1. select : removed call to net/bmahe/genetics4j/core/selection/Selector::select → NO_COVERAGE
|
.select(eaConfiguration, generation, incrementSelection, population, fitnessScore)); |
|
64
|
|
|
|
65
|
4
1. select : removed call to java/util/List::size → NO_COVERAGE
2. select : Substituted 1 with 0 → NO_COVERAGE
3. select : Replaced integer modulus with multiplication → NO_COVERAGE
4. select : Replaced integer addition with subtraction → NO_COVERAGE
|
i = (i + 1) % selectors.size(); |
|
66
|
|
} |
|
67
|
|
|
|
68
|
1
1. select : replaced return value with null for net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler$1::select → KILLED
|
return selectedIndividuals; |
|
69
|
|
} |
|
70
|
|
}; |
|
71
|
|
} |
|
72
|
|
} |
| | Mutations |
| 24 |
|
1.1 Location : canHandle Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:canHandle()] replaced boolean return with false for net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler::canHandle → KILLED
2.2 Location : canHandle Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:canHandle()] replaced boolean return with true for net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler::canHandle → KILLED
|
| 36 |
|
1.1 Location : resolve Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to net/bmahe/genetics4j/core/spec/selection/MultiSelections::selectionPolicies → KILLED
|
| 39 |
|
1.1 Location : resolve Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to java/util/stream/Stream::map → KILLED
2.2 Location : resolve Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] replaced call to java/util/stream/Stream::map with receiver → KILLED
3.3 Location : resolve Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to java/util/List::stream → KILLED
|
| 41 |
|
1.1 Location : lambda$resolve$0 Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to net/bmahe/genetics4j/core/selection/SelectionPolicyHandlerResolver::resolve → KILLED
|
| 42 |
|
1.1 Location : lambda$resolve$0 Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to net/bmahe/genetics4j/core/selection/SelectionPolicyHandler::resolve → KILLED
2.2 Location : lambda$resolve$0 Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] replaced return value with null for net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler::lambda$resolve$0 → KILLED
|
| 43 |
|
1.1 Location : resolve Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to java/util/stream/Stream::collect → KILLED
2.2 Location : resolve Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to java/util/stream/Collectors::toList → KILLED
|
| 45 |
|
1.1 Location : resolve Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] replaced return value with null for net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler::resolve → KILLED
2.2 Location : resolve Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler$1::<init> → KILLED
|
| 50 |
|
1.1 Location : select Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] Replaced integer division with multiplication → KILLED
2.2 Location : select Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to java/util/List::size → KILLED
|
| 52 |
|
1.1 Location : select Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to net/bmahe/genetics4j/core/Population::<init> → KILLED
|
| 54 |
|
1.1 Location : select Killed by : none removed call to net/bmahe/genetics4j/core/Population::addAll → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()]
|
| 55 |
|
1.1 Location : select Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] removed call to net/bmahe/genetics4j/core/selection/Selector::select → KILLED
|
| 58 |
|
1.1 Location : select Killed by : none Substituted 0 with 1 → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()]
|
| 59 |
|
1.1 Location : select Killed by : none removed call to net/bmahe/genetics4j/core/Population::size → TIMED_OUT
2.2 Location : select Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] changed conditional boundary → KILLED
3.3 Location : select Killed by : none removed conditional - replaced comparison check with true → TIMED_OUT
4.4 Location : select Killed by : none negated conditional → TIMED_OUT
5.5 Location : select Killed by : none removed conditional - replaced comparison check with false → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()]
|
| 61 |
|
1.1 Location : select Killed by : none removed call to net/bmahe/genetics4j/core/Population::addAll → NO_COVERAGE
|
| 62 |
|
1.1 Location : select Killed by : none removed call to java/util/List::get → NO_COVERAGE
|
| 63 |
|
1.1 Location : select Killed by : none removed call to net/bmahe/genetics4j/core/selection/Selector::select → NO_COVERAGE
|
| 65 |
|
1.1 Location : select Killed by : none removed call to java/util/List::size → NO_COVERAGE
2.2 Location : select Killed by : none Substituted 1 with 0 → NO_COVERAGE
3.3 Location : select Killed by : none Replaced integer modulus with multiplication → NO_COVERAGE
4.4 Location : select Killed by : none Replaced integer addition with subtraction → NO_COVERAGE
|
| 68 |
|
1.1 Location : select Killed by : net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiSelectionsPolicyHandlerTest]/[method:selectSplitsAcrossSelectors()] replaced return value with null for net/bmahe/genetics4j/core/selection/MultiSelectionsPolicyHandler$1::select → KILLED
|