|
1
|
|
package net.bmahe.genetics4j.core.mutation.chromosome.randommutation; |
|
2
|
|
|
|
3
|
|
import java.util.BitSet; |
|
4
|
|
import java.util.random.RandomGenerator; |
|
5
|
|
|
|
6
|
|
import org.apache.commons.lang3.Validate; |
|
7
|
|
|
|
8
|
|
import net.bmahe.genetics4j.core.chromosomes.BitChromosome; |
|
9
|
|
import net.bmahe.genetics4j.core.chromosomes.Chromosome; |
|
10
|
|
import net.bmahe.genetics4j.core.mutation.chromosome.ChromosomeMutationHandler; |
|
11
|
|
import net.bmahe.genetics4j.core.spec.chromosome.BitChromosomeSpec; |
|
12
|
|
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec; |
|
13
|
|
import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy; |
|
14
|
|
import net.bmahe.genetics4j.core.spec.mutation.RandomMutation; |
|
15
|
|
|
|
16
|
|
public class BitChromosomeRandomMutationHandler implements ChromosomeMutationHandler<BitChromosome> { |
|
17
|
|
|
|
18
|
|
private final RandomGenerator randomGenerator; |
|
19
|
|
|
|
20
|
|
public BitChromosomeRandomMutationHandler(final RandomGenerator _randomGenerator) { |
|
21
|
|
Validate.notNull(_randomGenerator); |
|
22
|
|
|
|
23
|
1
1. <init> : Removed assignment to member variable randomGenerator → KILLED
|
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 → SURVIVED
2. canHandle : removed conditional - replaced equality check with true → KILLED
3. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/mutation/chromosome/randommutation/BitChromosomeRandomMutationHandler::canHandle → KILLED
4. canHandle : negated conditional → KILLED
5. canHandle : removed conditional - replaced equality check with false → KILLED
6. canHandle : Substituted 0 with 1 → KILLED
7. canHandle : Substituted 1 with 0 → KILLED
8. canHandle : negated conditional → KILLED
9. canHandle : removed conditional - replaced equality check with false → KILLED
|
return mutationPolicy instanceof RandomMutation && chromosome instanceof BitChromosomeSpec; |
|
32
|
|
} |
|
33
|
|
|
|
34
|
|
@Override |
|
35
|
|
public BitChromosome mutate(final MutationPolicy mutationPolicy, final Chromosome chromosome) { |
|
36
|
|
Validate.notNull(mutationPolicy); |
|
37
|
|
Validate.notNull(chromosome); |
|
38
|
|
Validate.isInstanceOf(RandomMutation.class, mutationPolicy); |
|
39
|
|
Validate.isInstanceOf(BitChromosome.class, chromosome); |
|
40
|
|
|
|
41
|
|
final BitChromosome bitChromosome = (BitChromosome) chromosome; |
|
42
|
|
|
|
43
|
2
1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getNumAlleles → SURVIVED
2. mutate : removed call to java/util/BitSet::<init> → KILLED
|
final BitSet newBitSet = new BitSet(bitChromosome.getNumAlleles()); |
|
44
|
6
1. mutate : changed conditional boundary → SURVIVED
2. mutate : Substituted 0 with 1 → SURVIVED
3. mutate : removed conditional - replaced comparison check with true → TIMED_OUT
4. mutate : removed conditional - replaced comparison check with false → KILLED
5. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getNumAlleles → KILLED
6. mutate : negated conditional → KILLED
|
for (int i = 0; i < bitChromosome.getNumAlleles(); i++) { |
|
45
|
2
1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getBitSet → KILLED
2. mutate : removed call to java/util/BitSet::or → KILLED
|
newBitSet.or(bitChromosome.getBitSet()); |
|
46
|
|
} |
|
47
|
|
|
|
48
|
3
1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getNumAlleles → KILLED
2. mutate : replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED
3. mutate : removed call to java/util/random/RandomGenerator::nextInt → KILLED
|
final int bitFlipIndex = randomGenerator.nextInt(bitChromosome.getNumAlleles()); |
|
49
|
1
1. mutate : removed call to java/util/BitSet::flip → KILLED
|
newBitSet.flip(bitFlipIndex); |
|
50
|
|
|
|
51
|
2
1. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getNumAlleles → KILLED
2. mutate : removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::<init> → KILLED
|
final BitChromosome newBitChromosome = new BitChromosome(bitChromosome.getNumAlleles(), newBitSet); |
|
52
|
|
|
|
53
|
1
1. mutate : replaced return value with null for net/bmahe/genetics4j/core/mutation/chromosome/randommutation/BitChromosomeRandomMutationHandler::mutate → KILLED
|
return newBitChromosome; |
|
54
|
|
} |
|
55
|
|
} |
| | Mutations |
| 23 |
|
1.1 Location : <init> Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] Removed assignment to member variable randomGenerator → KILLED
|
| 31 |
|
1.1 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:canHandle()] removed conditional - replaced equality check with true → KILLED
2.2 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:canHandle()] replaced boolean return with true for net/bmahe/genetics4j/core/mutation/chromosome/randommutation/BitChromosomeRandomMutationHandler::canHandle → KILLED
3.3 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:canHandle()] negated conditional → KILLED
4.4 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:canHandle()] removed conditional - replaced equality check with false → KILLED
5.5 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:canHandle()] Substituted 0 with 1 → KILLED
6.6 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:canHandle()] Substituted 1 with 0 → KILLED
7.7 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:canHandle()] negated conditional → KILLED
8.8 Location : canHandle Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:canHandle()] removed conditional - replaced equality check with false → KILLED
9.9 Location : canHandle Killed by : none removed conditional - replaced equality check with true → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:canHandle()]
- net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.evaluation.FitnessEvaluatorVirtualThreadTest]/[method:testVirtualThreadFactory()]
- 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.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()]
|
| 43 |
|
1.1 Location : mutate Killed by : none removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getNumAlleles → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()]
- 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()]
2.2 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] removed call to java/util/BitSet::<init> → KILLED
|
| 44 |
|
1.1 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] removed conditional - replaced comparison check with false → KILLED
2.2 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getNumAlleles → KILLED
3.3 Location : mutate Killed by : none removed conditional - replaced comparison check with true → TIMED_OUT
4.4 Location : mutate Killed by : none changed conditional boundary → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()]
- 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()]
5.5 Location : mutate Killed by : none Substituted 0 with 1 → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()]
- 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()]
6.6 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] negated conditional → KILLED
|
| 45 |
|
1.1 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getBitSet → KILLED
2.2 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] removed call to java/util/BitSet::or → KILLED
|
| 48 |
|
1.1 Location : mutate Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithPostEvaluationProcessor()] removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getNumAlleles → KILLED
2.2 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED
3.3 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] removed call to java/util/random/RandomGenerator::nextInt → KILLED
|
| 49 |
|
1.1 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] removed call to java/util/BitSet::flip → KILLED
|
| 51 |
|
1.1 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::getNumAlleles → KILLED
2.2 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::<init> → KILLED
|
| 53 |
|
1.1 Location : mutate Killed by : net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.mutation.chromosome.randommutation.BitChromosomeRandomMutationHandlerTest]/[method:mutateValidate()] replaced return value with null for net/bmahe/genetics4j/core/mutation/chromosome/randommutation/BitChromosomeRandomMutationHandler::mutate → KILLED
|