| 1 |  | package net.bmahe.genetics4j.core.mutation.chromosome.swapmutation; | 
| 2 |  | 
 | 
| 3 |  | import java.util.Arrays; | 
| 4 |  | import java.util.random.RandomGenerator; | 
| 5 |  | 
 | 
| 6 |  | import org.apache.commons.lang3.Validate; | 
| 7 |  | 
 | 
| 8 |  | import net.bmahe.genetics4j.core.chromosomes.Chromosome; | 
| 9 |  | import net.bmahe.genetics4j.core.chromosomes.FloatChromosome; | 
| 10 |  | import net.bmahe.genetics4j.core.mutation.chromosome.ChromosomeMutationHandler; | 
| 11 |  | import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec; | 
| 12 |  | import net.bmahe.genetics4j.core.spec.chromosome.FloatChromosomeSpec; | 
| 13 |  | import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy; | 
| 14 |  | import net.bmahe.genetics4j.core.spec.mutation.SwapMutation; | 
| 15 |  | 
 | 
| 16 |  | public class FloatChromosomeSwapMutationHandler implements ChromosomeMutationHandler<FloatChromosome> { | 
| 17 |  | 
 | 
| 18 |  | 	private final RandomGenerator randomGenerator; | 
| 19 |  | 
 | 
| 20 |  | 	public FloatChromosomeSwapMutationHandler(final RandomGenerator _randomGenerator) { | 
| 21 |  | 		Validate.notNull(_randomGenerator); | 
| 22 |  | 
 | 
| 23 | 1
1. <init> : Removed assignment to member variable randomGenerator → SURVIVED 
 | 		this.randomGenerator = _randomGenerator; | 
| 24 |  | 	} | 
| 25 |  | 
 | 
| 26 |  | 	@Override | 
| 27 |  | 	public boolean canHandle(final MutationPolicy mutationPolicy, final ChromosomeSpec chromosome) { | 
| 28 |  | 		Validate.notNull(mutationPolicy); | 
| 29 |  | 		Validate.notNull(chromosome); | 
| 30 |  | 
 | 
| 31 | 9
1. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE 2. canHandle : negated conditional → NO_COVERAGE
 3. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/chromosome/swapmutation/FloatChromosomeSwapMutationHandler::canHandle → NO_COVERAGE
 4. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
 5. canHandle : removed conditional - replaced equality check with true → NO_COVERAGE
 6. canHandle : Substituted 0 with 1 → NO_COVERAGE
 7. canHandle : Substituted 1 with 0 → NO_COVERAGE
 8. canHandle : negated conditional → NO_COVERAGE
 9. canHandle : removed conditional - replaced equality check with false → NO_COVERAGE
 
 | 		return mutationPolicy instanceof SwapMutation && chromosome instanceof FloatChromosomeSpec; | 
| 32 |  | 	} | 
| 33 |  | 
 | 
| 34 |  | 	@Override | 
| 35 |  | 	public FloatChromosome mutate(final MutationPolicy mutationPolicy, final Chromosome chromosome) { | 
| 36 |  | 		Validate.notNull(mutationPolicy); | 
| 37 |  | 		Validate.notNull(chromosome); | 
| 38 |  | 		Validate.isInstanceOf(SwapMutation.class, mutationPolicy); | 
| 39 |  | 		Validate.isInstanceOf(FloatChromosome.class, chromosome); | 
| 40 |  | 
 | 
| 41 |  | 		final SwapMutation swapMutation = (SwapMutation) mutationPolicy; | 
| 42 | 5
1. mutate : removed call to net/bmahe/genetics4j/core/spec/mutation/SwapMutation::numSwap → NO_COVERAGE 2. mutate : removed conditional - replaced equality check with false → NO_COVERAGE
 3. mutate : negated conditional → NO_COVERAGE
 4. mutate : removed call to net/bmahe/genetics4j/core/spec/mutation/SwapMutation::isNumSwapFixed → NO_COVERAGE
 5. mutate : removed conditional - replaced equality check with true → NO_COVERAGE
 
 | 		final int numSwap = swapMutation.isNumSwapFixed() ? swapMutation.numSwap() | 
| 43 | 5
1. mutate : Substituted 1 with 0 → NO_COVERAGE 2. mutate : Replaced integer addition with subtraction → NO_COVERAGE
 3. mutate : removed call to java/util/random/RandomGenerator::nextInt → NO_COVERAGE
 4. mutate : replaced call to java/util/random/RandomGenerator::nextInt with argument → NO_COVERAGE
 5. mutate : removed call to net/bmahe/genetics4j/core/spec/mutation/SwapMutation::numSwap → NO_COVERAGE
 
 | 				: 1 + randomGenerator.nextInt(swapMutation.numSwap()); | 
| 44 |  | 
 | 
| 45 |  | 		final FloatChromosome floatChromosome = (FloatChromosome) chromosome; | 
| 46 |  | 
 | 
| 47 | 1
1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getValues → NO_COVERAGE 
 | 		final float[] values = floatChromosome.getValues(); | 
| 48 | 2
1. mutate : replaced call to java/util/Arrays::copyOf with argument → NO_COVERAGE 2. mutate : removed call to java/util/Arrays::copyOf → NO_COVERAGE
 
 | 		final float[] newValues = Arrays.copyOf(values, values.length); | 
| 49 |  | 
 | 
| 50 | 5
1. mutate : changed conditional boundary → NO_COVERAGE 2. mutate : Substituted 0 with 1 → NO_COVERAGE
 3. mutate : negated conditional → NO_COVERAGE
 4. mutate : removed conditional - replaced comparison check with false → NO_COVERAGE
 5. mutate : removed conditional - replaced comparison check with true → NO_COVERAGE
 
 | 		for (int i = 0; i < numSwap; i++) { | 
| 51 | 3
1. mutate : replaced call to java/util/random/RandomGenerator::nextInt with argument → NO_COVERAGE 2. mutate : removed call to java/util/random/RandomGenerator::nextInt → NO_COVERAGE
 3. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getNumAlleles → NO_COVERAGE
 
 | 			final int value1Index = randomGenerator.nextInt(floatChromosome.getNumAlleles()); | 
| 52 | 3
1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getNumAlleles → NO_COVERAGE 2. mutate : replaced call to java/util/random/RandomGenerator::nextInt with argument → NO_COVERAGE
 3. mutate : removed call to java/util/random/RandomGenerator::nextInt → NO_COVERAGE
 
 | 			final int value2Index = randomGenerator.nextInt(floatChromosome.getNumAlleles()); | 
| 53 |  | 
 | 
| 54 |  | 			final float value1 = newValues[value1Index]; | 
| 55 |  | 			final float value2 = newValues[value2Index]; | 
| 56 |  | 
 | 
| 57 |  | 			newValues[value1Index] = value2; | 
| 58 |  | 			newValues[value2Index] = value1; | 
| 59 |  | 		} | 
| 60 |  | 
 | 
| 61 | 2
1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getSize → NO_COVERAGE 2. mutate : replaced return value with null for net/bmahe/genetics4j/core/mutation/chromosome/swapmutation/FloatChromosomeSwapMutationHandler::mutate → NO_COVERAGE
 
 | 		return new FloatChromosome(floatChromosome.getSize(), | 
| 62 | 1
1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getMinValue → NO_COVERAGE 
 | 				floatChromosome.getMinValue(), | 
| 63 | 2
1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getMaxValue → NO_COVERAGE 2. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::<init> → NO_COVERAGE
 
 | 				floatChromosome.getMaxValue(), | 
| 64 |  | 				newValues); | 
| 65 |  | 	} | 
| 66 |  | } | 
|  |  | Mutations | 
| 23 |  | 1.1Location : <init>
 Killed by : none Removed assignment to member variable randomGenerator → SURVIVED
Covering tests
 Covered by tests:
 
net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:ctorNoSurvivorSelector()]net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:ctorNoOffspringSelector()]net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:ctorNoElitismSpec()]net.bmahe.genetics4j.core.selection.TournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.TournamentSelectionPolicyHandlerTest]/[method:selectMaximize()]net.bmahe.genetics4j.core.selection.RouletteWheelSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.RouletteWheelSelectionPolicyHandlerTest]/[method:selectMaximizing()]net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:simple()]net.bmahe.genetics4j.core.selection.RandomSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.RandomSelectionPolicyHandlerTest]/[method:select()]net.bmahe.genetics4j.core.selection.TournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.TournamentSelectionPolicyHandlerTest]/[method:selectMinimize()]net.bmahe.genetics4j.core.replacement.ElitismImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.ElitismImplTest]/[method:atLeastSpecified()]net.bmahe.genetics4j.core.selection.MultiTournamentsSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.MultiTournamentsSelectionPolicyHandlerTest]/[method:selectMaxThenMin()]net.bmahe.genetics4j.core.selection.RouletteWheelSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.RouletteWheelSelectionPolicyHandlerTest]/[method:selectMinimizing()]net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()]net.bmahe.genetics4j.core.selection.ProportionalTournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.ProportionalTournamentSelectionPolicyHandlerTest]/[method:selectMinimize()]net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testSystemConstruction()]net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testGetterMethods()]net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvaluateOnceWithDifferentGenerations()]net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvaluateOnce()]net.bmahe.genetics4j.core.mutation.SupersimpleTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.SupersimpleTest]/[method:simple()]net.bmahe.genetics4j.core.selection.ProportionalTournamentSelectionPolicyHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.selection.ProportionalTournamentSelectionPolicyHandlerTest]/[method:selectMaximize()]net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()]net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithBitChromosome()]net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithImmediateTermination()] | 
| 31 |  | 1.1Location : canHandle
 Killed by : none removed conditional - replaced equality check with true → NO_COVERAGE
 2.2Location : canHandle
 Killed by : none negated conditional → NO_COVERAGE
 3.3Location : canHandle
 Killed by : none replaced boolean return with true for net/bmahe/genetics4j/core/mutation/chromosome/swapmutation/FloatChromosomeSwapMutationHandler::canHandle → NO_COVERAGE
 4.4Location : canHandle
 Killed by : none removed conditional - replaced equality check with false → NO_COVERAGE
 5.5Location : canHandle
 Killed by : none removed conditional - replaced equality check with true → NO_COVERAGE
 6.6Location : canHandle
 Killed by : none Substituted 0 with 1 → NO_COVERAGE
 7.7Location : canHandle
 Killed by : none Substituted 1 with 0 → NO_COVERAGE
 8.8Location : canHandle
 Killed by : none negated conditional → NO_COVERAGE
 9.9Location : canHandle
 Killed by : none removed conditional - replaced equality check with false → NO_COVERAGE
 | 
| 42 |  | 1.1Location : mutate
 Killed by : none removed call to net/bmahe/genetics4j/core/spec/mutation/SwapMutation::numSwap → NO_COVERAGE
 2.2Location : mutate
 Killed by : none removed conditional - replaced equality check with false → NO_COVERAGE
 3.3Location : mutate
 Killed by : none negated conditional → NO_COVERAGE
 4.4Location : mutate
 Killed by : none removed call to net/bmahe/genetics4j/core/spec/mutation/SwapMutation::isNumSwapFixed → NO_COVERAGE
 5.5Location : mutate
 Killed by : none removed conditional - replaced equality check with true → NO_COVERAGE
 | 
| 43 |  | 1.1Location : mutate
 Killed by : none Substituted 1 with 0 → NO_COVERAGE
 2.2Location : mutate
 Killed by : none Replaced integer addition with subtraction → NO_COVERAGE
 3.3Location : mutate
 Killed by : none removed call to java/util/random/RandomGenerator::nextInt → NO_COVERAGE
 4.4Location : mutate
 Killed by : none replaced call to java/util/random/RandomGenerator::nextInt with argument → NO_COVERAGE
 5.5Location : mutate
 Killed by : none removed call to net/bmahe/genetics4j/core/spec/mutation/SwapMutation::numSwap → NO_COVERAGE
 | 
| 47 |  | 1.1Location : mutate
 Killed by : none removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getValues → NO_COVERAGE
 | 
| 48 |  | 1.1Location : mutate
 Killed by : none replaced call to java/util/Arrays::copyOf with argument → NO_COVERAGE
 2.2Location : mutate
 Killed by : none removed call to java/util/Arrays::copyOf → NO_COVERAGE
 | 
| 50 |  | 1.1Location : mutate
 Killed by : none changed conditional boundary → NO_COVERAGE
 2.2Location : mutate
 Killed by : none Substituted 0 with 1 → NO_COVERAGE
 3.3Location : mutate
 Killed by : none negated conditional → NO_COVERAGE
 4.4Location : mutate
 Killed by : none removed conditional - replaced comparison check with false → NO_COVERAGE
 5.5Location : mutate
 Killed by : none removed conditional - replaced comparison check with true → NO_COVERAGE
 | 
| 51 |  | 1.1Location : mutate
 Killed by : none replaced call to java/util/random/RandomGenerator::nextInt with argument → NO_COVERAGE
 2.2Location : mutate
 Killed by : none removed call to java/util/random/RandomGenerator::nextInt → NO_COVERAGE
 3.3Location : mutate
 Killed by : none removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getNumAlleles → NO_COVERAGE
 | 
| 52 |  | 1.1Location : mutate
 Killed by : none removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getNumAlleles → NO_COVERAGE
 2.2Location : mutate
 Killed by : none replaced call to java/util/random/RandomGenerator::nextInt with argument → NO_COVERAGE
 3.3Location : mutate
 Killed by : none removed call to java/util/random/RandomGenerator::nextInt → NO_COVERAGE
 | 
| 61 |  | 1.1Location : mutate
 Killed by : none removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getSize → NO_COVERAGE
 2.2Location : mutate
 Killed by : none replaced return value with null for net/bmahe/genetics4j/core/mutation/chromosome/swapmutation/FloatChromosomeSwapMutationHandler::mutate → NO_COVERAGE
 | 
| 62 |  | 1.1Location : mutate
 Killed by : none removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getMinValue → NO_COVERAGE
 | 
| 63 |  | 1.1Location : mutate
 Killed by : none removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::getMaxValue → NO_COVERAGE
 2.2Location : mutate
 Killed by : none removed call to net/bmahe/genetics4j/core/chromosomes/FloatChromosome::<init> → NO_COVERAGE
 |