| 1 | package net.bmahe.genetics4j.gp.mutation; | |
| 2 | ||
| 3 | import java.util.random.RandomGenerator; | |
| 4 | ||
| 5 | import org.apache.commons.lang3.Validate; | |
| 6 | ||
| 7 | import net.bmahe.genetics4j.core.mutation.MutationPolicyHandler; | |
| 8 | import net.bmahe.genetics4j.core.mutation.MutationPolicyHandlerResolver; | |
| 9 | import net.bmahe.genetics4j.core.mutation.Mutator; | |
| 10 | import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; | |
| 11 | import net.bmahe.genetics4j.core.spec.AbstractEAExecutionContext; | |
| 12 | import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy; | |
| 13 | import net.bmahe.genetics4j.gp.program.ProgramHelper; | |
| 14 | import net.bmahe.genetics4j.gp.spec.mutation.ProgramRandomPrune; | |
| 15 | ||
| 16 | public class ProgramRandomPrunePolicyHandler<T extends Comparable<T>> implements MutationPolicyHandler<T> { | |
| 17 | ||
| 18 | final RandomGenerator randomGenerator; | |
| 19 | final ProgramHelper programHelper; | |
| 20 | ||
| 21 | public ProgramRandomPrunePolicyHandler(final RandomGenerator _randomGenerator, final ProgramHelper _programHelper) { | |
| 22 | Validate.notNull(_randomGenerator); | |
| 23 | Validate.notNull(_programHelper); | |
| 24 | ||
| 25 |
1
1. <init> : Removed assignment to member variable randomGenerator → KILLED |
this.randomGenerator = _randomGenerator; |
| 26 |
1
1. <init> : Removed assignment to member variable programHelper → KILLED |
this.programHelper = _programHelper; |
| 27 | } | |
| 28 | ||
| 29 | @Override | |
| 30 | public boolean canHandle(final MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, | |
| 31 | final MutationPolicy mutationPolicy) { | |
| 32 | Validate.notNull(mutationPolicyHandlerResolver); | |
| 33 | Validate.notNull(mutationPolicy); | |
| 34 | ||
| 35 |
2
1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/gp/mutation/ProgramRandomPrunePolicyHandler::canHandle → KILLED 2. canHandle : replaced boolean return with false for net/bmahe/genetics4j/gp/mutation/ProgramRandomPrunePolicyHandler::canHandle → KILLED |
return mutationPolicy instanceof ProgramRandomPrune; |
| 36 | } | |
| 37 | ||
| 38 | @Override | |
| 39 | public Mutator createMutator(final AbstractEAExecutionContext<T> eaExecutionContext, | |
| 40 | final AbstractEAConfiguration<T> eaConfiguration, | |
| 41 | final MutationPolicyHandlerResolver<T> mutationPolicyHandlerResolver, final MutationPolicy mutationPolicy) { | |
| 42 | Validate.notNull(eaExecutionContext); | |
| 43 | Validate.notNull(eaConfiguration); | |
| 44 | Validate.notNull(mutationPolicyHandlerResolver); | |
| 45 | Validate.notNull(mutationPolicy); | |
| 46 | Validate.isInstanceOf(ProgramRandomPrune.class, mutationPolicy); | |
| 47 | ||
| 48 | final ProgramRandomPrune programRandomPrune = (ProgramRandomPrune) mutationPolicy; | |
| 49 |
1
1. createMutator : removed call to net/bmahe/genetics4j/gp/spec/mutation/ProgramRandomPrune::populationMutationProbability → SURVIVED |
final double populationMutationProbability = programRandomPrune.populationMutationProbability(); |
| 50 | ||
| 51 |
2
1. createMutator : removed call to net/bmahe/genetics4j/gp/mutation/ProgramRandomPruneMutator::<init> → KILLED 2. createMutator : replaced return value with null for net/bmahe/genetics4j/gp/mutation/ProgramRandomPrunePolicyHandler::createMutator → KILLED |
return new ProgramRandomPruneMutator(programHelper, |
| 52 | randomGenerator, | |
| 53 | eaConfiguration, | |
| 54 | populationMutationProbability); | |
| 55 | } | |
| 56 | } | |
Mutations | ||
| 25 |
1.1 |
|
| 26 |
1.1 |
|
| 35 |
1.1 2.2 |
|
| 49 |
1.1 |
|
| 51 |
1.1 2.2 |