1
|
|
package net.bmahe.genetics4j.core.combination.singlepointcrossover; |
2
|
|
|
3
|
|
import java.util.List; |
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.IntChromosome; |
10
|
|
import net.bmahe.genetics4j.core.combination.ChromosomeCombinator; |
11
|
|
import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; |
12
|
|
|
13
|
|
public class IntChromosomeSinglePointCrossover<T extends Comparable<T>> implements ChromosomeCombinator<T> { |
14
|
|
|
15
|
|
private final RandomGenerator randomGenerator; |
16
|
|
|
17
|
|
public IntChromosomeSinglePointCrossover(final RandomGenerator _randomGenerator) { |
18
|
|
Validate.notNull(_randomGenerator); |
19
|
|
|
20
|
1
1. <init> : Removed assignment to member variable randomGenerator → KILLED
|
this.randomGenerator = _randomGenerator; |
21
|
|
} |
22
|
|
|
23
|
|
@Override |
24
|
|
public List<Chromosome> combine(final AbstractEAConfiguration<T> eaConfiguration, final Chromosome chromosome1, |
25
|
|
final T firstParentFitness, final Chromosome chromosome2, final T secondParentFitness) { |
26
|
|
Validate.notNull(chromosome1); |
27
|
|
Validate.notNull(chromosome2); |
28
|
|
Validate.isInstanceOf(IntChromosome.class, chromosome1); |
29
|
|
Validate.isInstanceOf(IntChromosome.class, chromosome2); |
30
|
|
Validate.isTrue(chromosome1.getNumAlleles() == chromosome2.getNumAlleles()); |
31
|
|
|
32
|
3
1. combine : removed call to net/bmahe/genetics4j/core/chromosomes/Chromosome::getNumAlleles → KILLED
2. combine : removed call to java/util/random/RandomGenerator::nextInt → KILLED
3. combine : replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED
|
final int alleleSplit = randomGenerator.nextInt(chromosome1.getNumAlleles()); |
33
|
|
|
34
|
|
final IntChromosome intChromosome1 = (IntChromosome) chromosome1; |
35
|
|
final IntChromosome intChromosome2 = (IntChromosome) chromosome2; |
36
|
|
|
37
|
1
1. combine : removed call to net/bmahe/genetics4j/core/chromosomes/Chromosome::getNumAlleles → KILLED
|
final int numAlleles = chromosome1.getNumAlleles(); |
38
|
|
final int[] firstChildValues = new int[numAlleles]; |
39
|
|
final int[] secondChildValues = new int[numAlleles]; |
40
|
|
|
41
|
5
1. combine : removed conditional - replaced comparison check with true → KILLED
2. combine : Substituted 0 with 1 → KILLED
3. combine : changed conditional boundary → KILLED
4. combine : removed conditional - replaced comparison check with false → KILLED
5. combine : negated conditional → KILLED
|
for (int i = 0; i < numAlleles; i++) { |
42
|
|
|
43
|
4
1. combine : removed conditional - replaced comparison check with false → KILLED
2. combine : negated conditional → KILLED
3. combine : removed conditional - replaced comparison check with true → KILLED
4. combine : changed conditional boundary → KILLED
|
if (i < alleleSplit) { |
44
|
2
1. combine : replaced call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele with argument → SURVIVED
2. combine : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele → KILLED
|
firstChildValues[i] = intChromosome1.getAllele(i); |
45
|
2
1. combine : replaced call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele with argument → KILLED
2. combine : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele → KILLED
|
secondChildValues[i] = intChromosome2.getAllele(i); |
46
|
|
} else { |
47
|
2
1. combine : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele → KILLED
2. combine : replaced call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele with argument → KILLED
|
firstChildValues[i] = intChromosome2.getAllele(i); |
48
|
2
1. combine : replaced call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele with argument → SURVIVED
2. combine : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele → KILLED
|
secondChildValues[i] = intChromosome1.getAllele(i); |
49
|
|
} |
50
|
|
} |
51
|
|
|
52
|
2
1. combine : replaced return value with Collections.emptyList for net/bmahe/genetics4j/core/combination/singlepointcrossover/IntChromosomeSinglePointCrossover::combine → KILLED
2. combine : removed call to java/util/List::of → KILLED
|
return List.of( |
53
|
3
1. combine : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getMinValue → SURVIVED
2. combine : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::<init> → KILLED
3. combine : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getMaxValue → KILLED
|
new IntChromosome(numAlleles, intChromosome1.getMinValue(), intChromosome1.getMaxValue(), firstChildValues), |
54
|
|
new IntChromosome(numAlleles, |
55
|
1
1. combine : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getMinValue → SURVIVED
|
intChromosome1.getMinValue(), |
56
|
2
1. combine : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getMaxValue → KILLED
2. combine : removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::<init> → KILLED
|
intChromosome1.getMaxValue(), |
57
|
|
secondChildValues)); |
58
|
|
} |
59
|
|
} |
| | Mutations |
20 |
|
1.1 Location : <init> Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] Removed assignment to member variable randomGenerator → KILLED
|
32 |
|
1.1 Location : combine 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/chromosomes/Chromosome::getNumAlleles → KILLED
2.2 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed call to java/util/random/RandomGenerator::nextInt → KILLED
3.3 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED
|
37 |
|
1.1 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed call to net/bmahe/genetics4j/core/chromosomes/Chromosome::getNumAlleles → KILLED
|
41 |
|
1.1 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed conditional - replaced comparison check with true → KILLED
2.2 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] Substituted 0 with 1 → KILLED
3.3 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] changed conditional boundary → KILLED
4.4 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed conditional - replaced comparison check with false → KILLED
5.5 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] negated conditional → KILLED
|
43 |
|
1.1 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed conditional - replaced comparison check with false → KILLED
2.2 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] negated conditional → KILLED
3.3 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed conditional - replaced comparison check with true → KILLED
4.4 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] changed conditional boundary → KILLED
|
44 |
|
1.1 Location : combine Killed by : none replaced call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele with argument → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]
2.2 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele → KILLED
|
45 |
|
1.1 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] replaced call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele with argument → KILLED
2.2 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele → KILLED
|
47 |
|
1.1 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele → KILLED
2.2 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] replaced call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele with argument → KILLED
|
48 |
|
1.1 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele → KILLED
2.2 Location : combine Killed by : none replaced call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getAllele with argument → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]
|
52 |
|
1.1 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] replaced return value with Collections.emptyList for net/bmahe/genetics4j/core/combination/singlepointcrossover/IntChromosomeSinglePointCrossover::combine → KILLED
2.2 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed call to java/util/List::of → KILLED
|
53 |
|
1.1 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::<init> → KILLED
2.2 Location : combine Killed by : none removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getMinValue → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]
3.3 Location : combine 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/chromosomes/IntChromosome::getMaxValue → KILLED
|
55 |
|
1.1 Location : combine Killed by : none removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::getMinValue → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()]
- net.bmahe.genetics4j.core.EASystemTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.EASystemTest]/[method:testEvolveWithIntChromosome()]
|
56 |
|
1.1 Location : combine 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/chromosomes/IntChromosome::getMaxValue → KILLED
2.2 Location : combine Killed by : net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.combination.singlepointcrossover.IntChromosomeSinglePointCrossoverTest]/[method:combineTest()] removed call to net/bmahe/genetics4j/core/chromosomes/IntChromosome::<init> → KILLED
|