| 1 | package net.bmahe.genetics4j.neat.combination.parentcompare; | |
| 2 | ||
| 3 | import org.apache.commons.lang3.Validate; | |
| 4 | ||
| 5 | import net.bmahe.genetics4j.neat.chromosomes.NeatChromosome; | |
| 6 | import net.bmahe.genetics4j.neat.spec.combination.parentcompare.FitnessThenSizeComparison; | |
| 7 | import net.bmahe.genetics4j.neat.spec.combination.parentcompare.ParentComparisonPolicy; | |
| 8 | ||
| 9 | public class FitnessThenSizeComparisonHandler implements ParentComparisonHandler { | |
| 10 | ||
| 11 | @Override | |
| 12 | public boolean canHandle(final ParentComparisonPolicy parentComparisonPolicy) { | |
| 13 | Validate.notNull(parentComparisonPolicy); | |
| 14 | ||
| 15 |
2
1. canHandle : replaced boolean return with false for net/bmahe/genetics4j/neat/combination/parentcompare/FitnessThenSizeComparisonHandler::canHandle → KILLED 2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/neat/combination/parentcompare/FitnessThenSizeComparisonHandler::canHandle → KILLED |
return parentComparisonPolicy instanceof FitnessThenSizeComparison; |
| 16 | } | |
| 17 | ||
| 18 | @Override | |
| 19 | public ChosenOtherChromosome compare(final ParentComparisonPolicy parentComparisonPolicy, final NeatChromosome first, | |
| 20 | final NeatChromosome second, final int fitnessComparison) { | |
| 21 | Validate.notNull(parentComparisonPolicy); | |
| 22 | Validate.notNull(first); | |
| 23 | Validate.notNull(second); | |
| 24 | ||
| 25 |
13
1. compare : changed conditional boundary → SURVIVED 2. compare : removed conditional - replaced comparison check with false → KILLED 3. compare : negated conditional → KILLED 4. compare : negated conditional → KILLED 5. compare : removed conditional - replaced comparison check with false → KILLED 6. compare : removed conditional - replaced comparison check with true → KILLED 7. compare : removed conditional - replaced equality check with true → KILLED 8. compare : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getNumAlleles → KILLED 9. compare : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getNumAlleles → KILLED 10. compare : removed conditional - replaced comparison check with true → KILLED 11. compare : changed conditional boundary → KILLED 12. compare : negated conditional → KILLED 13. compare : removed conditional - replaced equality check with false → KILLED |
if (fitnessComparison < 0 || (fitnessComparison == 0 && first.getNumAlleles() > second.getNumAlleles())) { |
| 26 |
2
1. compare : replaced return value with null for net/bmahe/genetics4j/neat/combination/parentcompare/FitnessThenSizeComparisonHandler::compare → KILLED 2. compare : removed call to net/bmahe/genetics4j/neat/combination/parentcompare/ChosenOtherChromosome::<init> → KILLED |
return new ChosenOtherChromosome(second, first); |
| 27 | } | |
| 28 |
2
1. compare : replaced return value with null for net/bmahe/genetics4j/neat/combination/parentcompare/FitnessThenSizeComparisonHandler::compare → KILLED 2. compare : removed call to net/bmahe/genetics4j/neat/combination/parentcompare/ChosenOtherChromosome::<init> → KILLED |
return new ChosenOtherChromosome(first, second); |
| 29 | } | |
| 30 | } | |
Mutations | ||
| 15 |
1.1 2.2 |
|
| 25 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 13.13 |
|
| 26 |
1.1 2.2 |
|
| 28 |
1.1 2.2 |