1 | package net.bmahe.genetics4j.core.selection; | |
2 | ||
3 | import java.util.random.RandomGenerator; | |
4 | ||
5 | import org.apache.commons.lang3.Validate; | |
6 | import org.apache.logging.log4j.LogManager; | |
7 | import org.apache.logging.log4j.Logger; | |
8 | ||
9 | import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; | |
10 | import net.bmahe.genetics4j.core.spec.AbstractEAExecutionContext; | |
11 | import net.bmahe.genetics4j.core.spec.selection.SelectionPolicy; | |
12 | import net.bmahe.genetics4j.core.spec.selection.Tournament; | |
13 | ||
14 | public class TournamentSelectionPolicyHandler<T extends Comparable<T>> implements SelectionPolicyHandler<T> { | |
15 | public static final Logger logger = LogManager.getLogger(TournamentSelectionPolicyHandler.class); | |
16 | ||
17 | private final RandomGenerator randomGenerator; | |
18 | ||
19 | public TournamentSelectionPolicyHandler(final RandomGenerator _randomGenerator) { | |
20 | Validate.notNull(_randomGenerator); | |
21 | ||
22 |
1
1. <init> : Removed assignment to member variable randomGenerator → KILLED |
this.randomGenerator = _randomGenerator; |
23 | } | |
24 | ||
25 | @Override | |
26 | public boolean canHandle(final SelectionPolicy selectionPolicy) { | |
27 | Validate.notNull(selectionPolicy); | |
28 | ||
29 |
2
1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/selection/TournamentSelectionPolicyHandler::canHandle → KILLED 2. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/selection/TournamentSelectionPolicyHandler::canHandle → KILLED |
return selectionPolicy instanceof Tournament; |
30 | } | |
31 | ||
32 | @Override | |
33 | public Selector<T> resolve(final AbstractEAExecutionContext<T> eaExecutionContext, | |
34 | final AbstractEAConfiguration<T> eaConfiguration, | |
35 | final SelectionPolicyHandlerResolver<T> selectionPolicyHandlerResolver, | |
36 | final SelectionPolicy selectionPolicy) { | |
37 | Validate.notNull(selectionPolicy); | |
38 | Validate.isInstanceOf(Tournament.class, selectionPolicy); | |
39 | ||
40 |
2
1. resolve : replaced return value with null for net/bmahe/genetics4j/core/selection/TournamentSelectionPolicyHandler::resolve → KILLED 2. resolve : removed call to net/bmahe/genetics4j/core/selection/TournamentSelector::<init> → KILLED |
return new TournamentSelector<>(selectionPolicy, randomGenerator); |
41 | } | |
42 | } | |
Mutations | ||
22 |
1.1 |
|
29 |
1.1 2.2 |
|
40 |
1.1 2.2 |