1
|
|
package net.bmahe.genetics4j.core.chromosomes.factory; |
2
|
|
|
3
|
|
import java.util.random.RandomGenerator; |
4
|
|
|
5
|
|
import org.apache.commons.lang3.Validate; |
6
|
|
|
7
|
|
import net.bmahe.genetics4j.core.chromosomes.IntChromosome; |
8
|
|
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec; |
9
|
|
import net.bmahe.genetics4j.core.spec.chromosome.IntChromosomeSpec; |
10
|
|
|
11
|
|
public class IntChromosomeFactory implements ChromosomeFactory<IntChromosome> { |
12
|
|
|
13
|
|
private final RandomGenerator randomGenerator; |
14
|
|
|
15
|
|
public IntChromosomeFactory(final RandomGenerator _randomGenerator) { |
16
|
|
Validate.notNull(_randomGenerator); |
17
|
|
|
18
|
1
1. <init> : Removed assignment to member variable randomGenerator → KILLED
|
this.randomGenerator = _randomGenerator; |
19
|
|
} |
20
|
|
|
21
|
|
@Override |
22
|
|
public boolean canHandle(final ChromosomeSpec chromosomeSpec) { |
23
|
|
Validate.notNull(chromosomeSpec); |
24
|
|
|
25
|
2
1. canHandle : replaced boolean return with false for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::canHandle → KILLED
2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::canHandle → KILLED
|
return chromosomeSpec instanceof IntChromosomeSpec; |
26
|
|
} |
27
|
|
|
28
|
|
@Override |
29
|
|
public IntChromosome generate(final ChromosomeSpec chromosomeSpec) { |
30
|
|
Validate.notNull(chromosomeSpec); |
31
|
|
Validate.isInstanceOf(IntChromosomeSpec.class, chromosomeSpec); |
32
|
|
|
33
|
|
final IntChromosomeSpec intChromosomeSpec = (IntChromosomeSpec) chromosomeSpec; |
34
|
|
|
35
|
1
1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED
|
int[] values = new int[intChromosomeSpec.size()]; |
36
|
6
1. generate : Substituted 0 with 1 → KILLED
2. generate : removed conditional - replaced comparison check with false → KILLED
3. generate : negated conditional → KILLED
4. generate : removed conditional - replaced comparison check with true → KILLED
5. generate : changed conditional boundary → KILLED
6. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED
|
for (int i = 0; i < intChromosomeSpec.size(); i++) { |
37
|
1
1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
|
values[i] = intChromosomeSpec.minValue() |
38
|
6
1. generate : Replaced integer subtraction with addition → SURVIVED
2. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
3. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::maxValue → KILLED
4. generate : Replaced integer addition with subtraction → KILLED
5. generate : replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED
6. generate : removed call to java/util/random/RandomGenerator::nextInt → KILLED
|
+ randomGenerator.nextInt(intChromosomeSpec.maxValue() - intChromosomeSpec.minValue()); |
39
|
|
} |
40
|
|
|
41
|
5
1. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
2. generate : replaced return value with null for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::generate → KILLED
3. generate : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::<init> → KILLED
4. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED
5. generate : removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::maxValue → KILLED
|
return new IntChromosome(intChromosomeSpec.size(), intChromosomeSpec.minValue(), intChromosomeSpec.maxValue(), |
42
|
|
values); |
43
|
|
} |
44
|
|
|
45
|
|
} |
| | Mutations |
18 |
|
1.1 Location : <init> Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] Removed assignment to member variable randomGenerator → KILLED
|
25 |
|
1.1 Location : canHandle Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:canHandleTest()] replaced boolean return with false for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::canHandle → KILLED
2.2 Location : canHandle Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:canHandleTest()] replaced boolean return with true for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::canHandle → KILLED
|
35 |
|
1.1 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED
|
36 |
|
1.1 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] Substituted 0 with 1 → KILLED
2.2 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] removed conditional - replaced comparison check with false → KILLED
3.3 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] negated conditional → KILLED
4.4 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] removed conditional - replaced comparison check with true → KILLED
5.5 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] changed conditional boundary → KILLED
6.6 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED
|
37 |
|
1.1 Location : generate Killed by : none removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
- net.bmahe.genetics4j.core.util.GenotypeGeneratorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.util.GenotypeGeneratorTest]/[method:usingDefaultGenerator()]
- net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]
|
38 |
|
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/IntChromosomeSpec::maxValue → KILLED
2.2 Location : generate Killed by : none Replaced integer subtraction with addition → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
- net.bmahe.genetics4j.core.util.GenotypeGeneratorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.util.GenotypeGeneratorTest]/[method:usingDefaultGenerator()]
- net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]
3.3 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] Replaced integer addition with subtraction → KILLED
4.4 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED
5.5 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] removed call to java/util/random/RandomGenerator::nextInt → KILLED
6.6 Location : generate Killed by : none removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
- net.bmahe.genetics4j.core.util.GenotypeGeneratorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.util.GenotypeGeneratorTest]/[method:usingDefaultGenerator()]
- net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]
|
41 |
|
1.1 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] replaced return value with null for net/bmahe/genetics4j/core/chromosomes/factory/IntChromosomeFactory::generate → KILLED
2.2 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::<init> → KILLED
3.3 Location : generate Killed by : net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()] removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::size → KILLED
4.4 Location : generate Killed by : net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()] removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::maxValue → KILLED
5.5 Location : generate Killed by : none removed call to net/bmahe/genetics4j/core/spec/chromosome/IntChromosomeSpec::minValue → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.chromosomes.factory.IntChromosomeFactoryTest]/[method:generateTest()]
- net.bmahe.genetics4j.core.util.GenotypeGeneratorTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.util.GenotypeGeneratorTest]/[method:usingDefaultGenerator()]
- net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]
|