| 1 | package net.bmahe.genetics4j.gp.mutation; | |
| 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.mutation.MutationPolicyHandler; | |
| 10 | import net.bmahe.genetics4j.core.mutation.MutationPolicyHandlerResolver; | |
| 11 | import net.bmahe.genetics4j.core.mutation.Mutator; | |
| 12 | import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; | |
| 13 | import net.bmahe.genetics4j.core.spec.AbstractEAExecutionContext; | |
| 14 | import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy; | |
| 15 | import net.bmahe.genetics4j.gp.program.ProgramGenerator; | |
| 16 | import net.bmahe.genetics4j.gp.spec.mutation.TrimTree; | |
| 17 | ||
| 18 | public class TrimTreePolicyHandler<T extends Comparable<T>> implements MutationPolicyHandler<T> { | |
| 19 | final static public Logger logger = LogManager.getLogger(TrimTreePolicyHandler.class); | |
| 20 | ||
| 21 | final RandomGenerator randomGenerator; | |
| 22 | final ProgramGenerator programGenerator; | |
| 23 | ||
| 24 | public TrimTreePolicyHandler(final RandomGenerator _randomGenerator, final ProgramGenerator _programGenerator) { | |
| 25 | Validate.notNull(_randomGenerator); | |
| 26 | Validate.notNull(_programGenerator); | |
| 27 | ||
| 28 |
1
1. <init> : Removed assignment to member variable randomGenerator → NO_COVERAGE |
this.randomGenerator = _randomGenerator; |
| 29 |
1
1. <init> : Removed assignment to member variable programGenerator → NO_COVERAGE |
this.programGenerator = _programGenerator; |
| 30 | } | |
| 31 | ||
| 32 | @Override | |
| 33 | public boolean canHandle(final MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, | |
| 34 | final MutationPolicy mutationPolicy) { | |
| 35 | Validate.notNull(mutationPolicyHandlerResolver); | |
| 36 | Validate.notNull(mutationPolicy); | |
| 37 | ||
| 38 |
2
1. canHandle : replaced boolean return with false for net/bmahe/genetics4j/gp/mutation/TrimTreePolicyHandler::canHandle → NO_COVERAGE 2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/gp/mutation/TrimTreePolicyHandler::canHandle → NO_COVERAGE |
return mutationPolicy instanceof TrimTree; |
| 39 | } | |
| 40 | ||
| 41 | @Override | |
| 42 | public Mutator createMutator(final AbstractEAExecutionContext<T> eaExecutionContext, | |
| 43 | final AbstractEAConfiguration<T> eaConfiguration, | |
| 44 | final MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, final MutationPolicy mutationPolicy) { | |
| 45 | Validate.notNull(eaExecutionContext); | |
| 46 | Validate.notNull(eaConfiguration); | |
| 47 | Validate.notNull(mutationPolicyHandlerResolver); | |
| 48 | Validate.notNull(mutationPolicy); | |
| 49 | Validate.isInstanceOf(TrimTree.class, mutationPolicy); | |
| 50 | ||
| 51 | final TrimTree trimTree = (TrimTree) mutationPolicy; | |
| 52 | ||
| 53 |
2
1. createMutator : replaced return value with null for net/bmahe/genetics4j/gp/mutation/TrimTreePolicyHandler::createMutator → NO_COVERAGE 2. createMutator : removed call to net/bmahe/genetics4j/gp/mutation/TrimTreeMutator::<init> → NO_COVERAGE |
return new TrimTreeMutator(programGenerator, randomGenerator, eaConfiguration, trimTree); |
| 54 | } | |
| 55 | } | |
Mutations | ||
| 28 |
1.1 |
|
| 29 |
1.1 |
|
| 38 |
1.1 2.2 |
|
| 53 |
1.1 2.2 |