| 1 | package net.bmahe.genetics4j.moo.nsga2.impl; | |
| 2 | ||
| 3 | import org.apache.commons.lang3.Validate; | |
| 4 | ||
| 5 | import net.bmahe.genetics4j.core.selection.SelectionPolicyHandler; | |
| 6 | import net.bmahe.genetics4j.core.selection.SelectionPolicyHandlerResolver; | |
| 7 | import net.bmahe.genetics4j.core.selection.Selector; | |
| 8 | import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; | |
| 9 | import net.bmahe.genetics4j.core.spec.AbstractEAExecutionContext; | |
| 10 | import net.bmahe.genetics4j.core.spec.selection.SelectionPolicy; | |
| 11 | import net.bmahe.genetics4j.moo.nsga2.spec.NSGA2Selection; | |
| 12 | ||
| 13 | public class NSGA2SelectionPolicyHandler<T extends Comparable<T>> implements SelectionPolicyHandler<T> { | |
| 14 | ||
| 15 | @Override | |
| 16 | public boolean canHandle(final SelectionPolicy selectionPolicy) { | |
| 17 | Validate.notNull(selectionPolicy); | |
| 18 |
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<?>; |
| 19 | } | |
| 20 | ||
| 21 | @Override | |
| 22 | public Selector<T> resolve(final AbstractEAExecutionContext<T> eaExecutionContext, | |
| 23 | final AbstractEAConfiguration<T> eaConfiguration, | |
| 24 | final SelectionPolicyHandlerResolver<T> selectionPolicyHandlerResolver, | |
| 25 | final SelectionPolicy selectionPolicy) { | |
| 26 | Validate.notNull(eaExecutionContext); | |
| 27 | Validate.notNull(eaConfiguration); | |
| 28 | Validate.notNull(selectionPolicyHandlerResolver); | |
| 29 | Validate.notNull(selectionPolicy); | |
| 30 | Validate.isInstanceOf(NSGA2Selection.class, selectionPolicy); | |
| 31 | ||
| 32 | final NSGA2Selection<T> nsga2Spec = (NSGA2Selection<T>) selectionPolicy; | |
| 33 | ||
| 34 |
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<T>(nsga2Spec); |
| 35 | } | |
| 36 | } | |
Mutations | ||
| 18 |
1.1 2.2 |
|
| 34 |
1.1 2.2 |