| 1 | package net.bmahe.genetics4j.moo.nsga2.impl; | |
| 2 | ||
| 3 | import java.util.Objects; | |
| 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.NSGA2Selection; | |
| 14 | ||
| 15 | public class NSGA2SelectionPolicyHandler<T extends Comparable<T>> implements SelectionPolicyHandler<T> { | |
| 16 | ||
| 17 | @Override | |
| 18 | public boolean canHandle(final SelectionPolicy selectionPolicy) { | |
| 19 | Objects.requireNonNull(selectionPolicy); | |
| 20 |
2
1. canHandle : replaced boolean return with false for net/bmahe/genetics4j/moo/nsga2/impl/NSGA2SelectionPolicyHandler::canHandle → KILLED 2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/moo/nsga2/impl/NSGA2SelectionPolicyHandler::canHandle → KILLED |
return selectionPolicy instanceof NSGA2Selection<?>; |
| 21 | } | |
| 22 | ||
| 23 | @Override | |
| 24 | public Selector<T> resolve(final AbstractEAExecutionContext<T> eaExecutionContext, | |
| 25 | final AbstractEAConfiguration<T> eaConfiguration, | |
| 26 | final SelectionPolicyHandlerResolver<T> selectionPolicyHandlerResolver, | |
| 27 | final SelectionPolicy selectionPolicy) { | |
| 28 | Objects.requireNonNull(eaExecutionContext); | |
| 29 | Objects.requireNonNull(eaConfiguration); | |
| 30 | Objects.requireNonNull(selectionPolicyHandlerResolver); | |
| 31 | Objects.requireNonNull(selectionPolicy); | |
| 32 | Validate.isInstanceOf(NSGA2Selection.class, selectionPolicy); | |
| 33 | ||
| 34 | final NSGA2Selection<T> nsga2Spec = (NSGA2Selection<T>) selectionPolicy; | |
| 35 | ||
| 36 |
2
1. resolve : replaced return value with null for net/bmahe/genetics4j/moo/nsga2/impl/NSGA2SelectionPolicyHandler::resolve → KILLED 2. resolve : removed call to net/bmahe/genetics4j/moo/nsga2/impl/NSGA2Selector::<init> → KILLED |
return new NSGA2Selector<>(nsga2Spec); |
| 37 | } | |
| 38 | } | |
Mutations | ||
| 20 |
1.1 2.2 |
|
| 36 |
1.1 2.2 |