| 1 | package net.bmahe.genetics4j.moo.nsga2.impl; | |
| 2 | ||
| 3 | import java.util.random.RandomGenerator; | |
| 4 | ||
| 5 | import org.apache.commons.lang3.Validate; | |
| 6 | ||
| 7 | import net.bmahe.genetics4j.core.selection.SelectionPolicyHandler; | |
| 8 | import net.bmahe.genetics4j.core.selection.SelectionPolicyHandlerResolver; | |
| 9 | import net.bmahe.genetics4j.core.selection.Selector; | |
| 10 | import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; | |
| 11 | import net.bmahe.genetics4j.core.spec.AbstractEAExecutionContext; | |
| 12 | import net.bmahe.genetics4j.core.spec.selection.SelectionPolicy; | |
| 13 | import net.bmahe.genetics4j.moo.nsga2.spec.TournamentNSGA2Selection; | |
| 14 | ||
| 15 | public class TournamentNSGA2SelectionPolicyHandler<T extends Comparable<T>> implements SelectionPolicyHandler<T> { | |
| 16 | ||
| 17 | private final RandomGenerator randomGenerator; | |
| 18 | ||
| 19 | public TournamentNSGA2SelectionPolicyHandler(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 |
2
1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/moo/nsga2/impl/TournamentNSGA2SelectionPolicyHandler::canHandle → KILLED 2. canHandle : replaced boolean return with false for net/bmahe/genetics4j/moo/nsga2/impl/TournamentNSGA2SelectionPolicyHandler::canHandle → KILLED |
return selectionPolicy instanceof TournamentNSGA2Selection<?>; |
| 29 | } | |
| 30 | ||
| 31 | @Override | |
| 32 | public Selector<T> resolve(final AbstractEAExecutionContext<T> EASystemDescriptor, | |
| 33 | final AbstractEAConfiguration<T> eaConfiguration, | |
| 34 | final SelectionPolicyHandlerResolver<T> selectionPolicyHandlerResolver, | |
| 35 | final SelectionPolicy selectionPolicy) { | |
| 36 | Validate.notNull(EASystemDescriptor); | |
| 37 | Validate.notNull(eaConfiguration); | |
| 38 | Validate.notNull(selectionPolicyHandlerResolver); | |
| 39 | Validate.notNull(selectionPolicy); | |
| 40 | Validate.isInstanceOf(TournamentNSGA2Selection.class, selectionPolicy); | |
| 41 | ||
| 42 | final TournamentNSGA2Selection<T> tournamentNsga2Spec = (TournamentNSGA2Selection<T>) selectionPolicy; | |
| 43 | ||
| 44 |
2
1. resolve : replaced return value with null for net/bmahe/genetics4j/moo/nsga2/impl/TournamentNSGA2SelectionPolicyHandler::resolve → KILLED 2. resolve : removed call to net/bmahe/genetics4j/moo/nsga2/impl/TournamentNSGA2Selector::<init> → KILLED |
return new TournamentNSGA2Selector<T>(randomGenerator, tournamentNsga2Spec); |
| 45 | } | |
| 46 | } | |
Mutations | ||
| 22 |
1.1 |
|
| 28 |
1.1 2.2 |
|
| 44 |
1.1 2.2 |