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