1
|
|
package net.bmahe.genetics4j.core.chromosomes.factory; |
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.spec.chromosome.BitChromosomeSpec; |
10
|
|
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec; |
11
|
|
|
12
|
|
public class BitChromosomeFactory implements ChromosomeFactory<BitChromosome> { |
13
|
|
|
14
|
|
private final RandomGenerator randomGenerator; |
15
|
|
|
16
|
|
public BitChromosomeFactory(final RandomGenerator _randomGenerator) { |
17
|
|
Validate.notNull(_randomGenerator); |
18
|
|
|
19
|
1
1. <init> : Removed assignment to member variable randomGenerator → KILLED
|
this.randomGenerator = _randomGenerator; |
20
|
|
} |
21
|
|
|
22
|
|
@Override |
23
|
|
public boolean canHandle(final ChromosomeSpec chromosomeSpec) { |
24
|
|
Validate.notNull(chromosomeSpec); |
25
|
|
|
26
|
2
1. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/chromosomes/factory/BitChromosomeFactory::canHandle → KILLED
2. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/chromosomes/factory/BitChromosomeFactory::canHandle → KILLED
|
return chromosomeSpec instanceof BitChromosomeSpec; |
27
|
|
} |
28
|
|
|
29
|
|
@Override |
30
|
|
public BitChromosome generate(final ChromosomeSpec chromosomeSpec) { |
31
|
|
Validate.notNull(chromosomeSpec); |
32
|
|
Validate.isInstanceOf(BitChromosomeSpec.class, chromosomeSpec); |
33
|
|
|
34
|
|
final BitChromosomeSpec bitChromosomeSpec = (BitChromosomeSpec) chromosomeSpec; |
35
|
1
1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/BitChromosomeSpec::numBits → KILLED
|
final int numBits = bitChromosomeSpec.numBits(); |
36
|
|
|
37
|
1
1. generate : removed call to java/util/BitSet::<init> → KILLED
|
final BitSet bitSet = new BitSet(numBits); |
38
|
5
1. generate : changed conditional boundary → SURVIVED
2. generate : removed conditional - replaced comparison check with true → TIMED_OUT
3. generate : negated conditional → KILLED
4. generate : Substituted 0 with 1 → KILLED
5. generate : removed conditional - replaced comparison check with false → KILLED
|
for (int i = 0; i < numBits; i++) { |
39
|
2
1. generate : removed call to java/util/random/RandomGenerator::nextBoolean → KILLED
2. generate : removed call to java/util/BitSet::set → KILLED
|
bitSet.set(i, randomGenerator.nextBoolean()); |
40
|
|
} |
41
|
|
|
42
|
2
1. generate : replaced return value with null for net/bmahe/genetics4j/core/chromosomes/factory/BitChromosomeFactory::generate → KILLED
2. generate : removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::<init> → KILLED
|
return new BitChromosome(numBits, bitSet); |
43
|
|
} |
44
|
|
} |
| | Mutations |
19 |
|
1.1 Location : <init> Killed by : net.bmahe.genetics4j.core.util.GenotypeGeneratorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.util.GenotypeGeneratorTest]/[method:usingDefaultGenerator()] Removed assignment to member variable randomGenerator → KILLED
|
26 |
|
1.1 Location : canHandle Killed by : net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest]/[method:canHandleTest()] replaced boolean return with true for net/bmahe/genetics4j/core/chromosomes/factory/BitChromosomeFactory::canHandle → KILLED
2.2 Location : canHandle Killed by : net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest]/[method:canHandleTest()] replaced boolean return with false for net/bmahe/genetics4j/core/chromosomes/factory/BitChromosomeFactory::canHandle → KILLED
|
35 |
|
1.1 Location : generate Killed by : net.bmahe.genetics4j.core.util.GenotypeGeneratorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.util.GenotypeGeneratorTest]/[method:usingDefaultGenerator()] removed call to net/bmahe/genetics4j/core/spec/chromosome/BitChromosomeSpec::numBits → KILLED
|
37 |
|
1.1 Location : generate Killed by : net.bmahe.genetics4j.core.util.GenotypeGeneratorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.util.GenotypeGeneratorTest]/[method:usingDefaultGenerator()] removed call to java/util/BitSet::<init> → KILLED
|
38 |
|
1.1 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest]/[method:generateTest()] negated conditional → KILLED
2.2 Location : generate Killed by : none changed conditional boundary → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.util.GenotypeGeneratorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.util.GenotypeGeneratorTest]/[method:usingDefaultGenerator()]
- 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.chromosomes.factory.BitChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest]/[method:generateTest()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithImmediateTermination()]
3.3 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest]/[method:generateTest()] Substituted 0 with 1 → KILLED
4.4 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest]/[method:generateTest()] removed conditional - replaced comparison check with false → KILLED
5.5 Location : generate Killed by : none removed conditional - replaced comparison check with true → TIMED_OUT
|
39 |
|
1.1 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest]/[method:generateTest()] removed call to java/util/random/RandomGenerator::nextBoolean → KILLED
2.2 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.BitChromosomeFactoryTest]/[method:generateTest()] removed call to java/util/BitSet::set → KILLED
|
42 |
|
1.1 Location : generate Killed by : net.bmahe.genetics4j.core.util.GenotypeGeneratorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.util.GenotypeGeneratorTest]/[method:usingDefaultGenerator()] replaced return value with null for net/bmahe/genetics4j/core/chromosomes/factory/BitChromosomeFactory::generate → KILLED
2.2 Location : generate Killed by : net.bmahe.genetics4j.core.util.GenotypeGeneratorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.util.GenotypeGeneratorTest]/[method:usingDefaultGenerator()] removed call to net/bmahe/genetics4j/core/chromosomes/BitChromosome::<init> → KILLED
|