SPEA2Utils.java

1
package net.bmahe.genetics4j.moo.spea2.replacement;
2
3
import java.util.Comparator;
4
import java.util.List;
5
import java.util.Objects;
6
import java.util.stream.Collectors;
7
import java.util.stream.IntStream;
8
9
import org.apache.commons.lang3.Validate;
10
import org.apache.commons.lang3.tuple.ImmutablePair;
11
import org.apache.commons.lang3.tuple.Pair;
12
13
import net.bmahe.genetics4j.core.Population;
14
15
public class SPEA2Utils {
16
17
	private SPEA2Utils() {
18
	}
19
20
	public static <T extends Comparable<T>> int strength(final Comparator<T> dominance, final int index, final T fitness,
21
			final Population<T> population) {
22
		Validate.isTrue(index >= 0);
23
		Validate.isTrue(index < population.size());
24
25
		Objects.requireNonNull(fitness);
26
		Objects.requireNonNull(population);
27
		Validate.isTrue(population.size() > 0);
28
29 1 1. strength : Substituted 0 with 1 → NO_COVERAGE
		int dominatedCount = 0;
30
31 6 1. strength : removed conditional - replaced comparison check with true → NO_COVERAGE
2. strength : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE
3. strength : Substituted 0 with 1 → NO_COVERAGE
4. strength : removed conditional - replaced comparison check with false → NO_COVERAGE
5. strength : negated conditional → NO_COVERAGE
6. strength : changed conditional boundary → NO_COVERAGE
		for (int j = 0; j < population.size(); j++) {
32 1 1. strength : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE
			final T fitnessJ = population.getFitness(j);
33
34 5 1. strength : removed conditional - replaced comparison check with true → NO_COVERAGE
2. strength : removed call to java/util/Comparator::compare → NO_COVERAGE
3. strength : negated conditional → NO_COVERAGE
4. strength : changed conditional boundary → NO_COVERAGE
5. strength : removed conditional - replaced comparison check with false → NO_COVERAGE
			if (dominance.compare(fitness, fitnessJ) > 0) {
35 2 1. strength : Removed increment 1 → NO_COVERAGE
2. strength : Changed increment from 1 to -1 → NO_COVERAGE
				dominatedCount++;
36
			}
37
		}
38
39 1 1. strength : replaced int return with 0 for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::strength → NO_COVERAGE
		return dominatedCount;
40
	}
41
42
	public static <T extends Comparable<T>> int rawFitness(final Comparator<T> dominance, final double[] strengths,
43
			final int index, final T fitness, final Population<T> population) {
44
		Validate.isTrue(index >= 0);
45
		Validate.isTrue(index < population.size());
46
47
		Objects.requireNonNull(strengths);
48
		Objects.requireNonNull(fitness);
49
		Objects.requireNonNull(population);
50
		Validate.isTrue(population.size() > 0);
51
		Validate.isTrue(population.size() == strengths.length);
52
53 1 1. rawFitness : Substituted 0 with 1 → NO_COVERAGE
		int rawFitness = 0;
54
55 6 1. rawFitness : removed conditional - replaced comparison check with false → NO_COVERAGE
2. rawFitness : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE
3. rawFitness : changed conditional boundary → NO_COVERAGE
4. rawFitness : removed conditional - replaced comparison check with true → NO_COVERAGE
5. rawFitness : negated conditional → NO_COVERAGE
6. rawFitness : Substituted 0 with 1 → NO_COVERAGE
		for (int j = 0; j < population.size(); j++) {
56 1 1. rawFitness : removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE
			final T fitnessJ = population.getFitness(j);
57
58 3 1. rawFitness : negated conditional → NO_COVERAGE
2. rawFitness : removed conditional - replaced equality check with true → NO_COVERAGE
3. rawFitness : removed conditional - replaced equality check with false → NO_COVERAGE
			if (index != j) {
59 5 1. rawFitness : changed conditional boundary → NO_COVERAGE
2. rawFitness : removed call to java/util/Comparator::compare → NO_COVERAGE
3. rawFitness : removed conditional - replaced comparison check with true → NO_COVERAGE
4. rawFitness : negated conditional → NO_COVERAGE
5. rawFitness : removed conditional - replaced comparison check with false → NO_COVERAGE
				if (dominance.compare(fitness, fitnessJ) < 0) {
60 1 1. rawFitness : Replaced double addition with subtraction → NO_COVERAGE
					rawFitness += strengths[j];
61
				}
62
			}
63
		}
64
65 1 1. rawFitness : replaced int return with 0 for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::rawFitness → NO_COVERAGE
		return rawFitness;
66
	}
67
68
	public static <T extends Comparable<T>> List<Pair<Integer, Double>> kthDistances(final double[][] distanceObjectives,
69
			final int index, final T fitness, final Population<T> combinedPopulation) {
70
		Objects.requireNonNull(distanceObjectives);
71
		Validate.isTrue(index >= 0);
72
		Validate.isTrue(index < combinedPopulation.size());
73
74
		Objects.requireNonNull(fitness);
75
		Objects.requireNonNull(combinedPopulation);
76
		Validate.isTrue(combinedPopulation.size() > 0);
77
78 4 1. kthDistances : replaced return value with Collections.emptyList for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::kthDistances → NO_COVERAGE
2. kthDistances : removed call to java/util/stream/IntStream::range → NO_COVERAGE
3. kthDistances : Substituted 0 with 1 → NO_COVERAGE
4. kthDistances : removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE
		return IntStream.range(0, combinedPopulation.size())
79 1 1. kthDistances : removed call to java/util/stream/IntStream::boxed → NO_COVERAGE
				.boxed()
80 6 1. lambda$kthDistances$0 : removed call to java/lang/Double::compare → NO_COVERAGE
2. lambda$kthDistances$0 : removed call to java/lang/Integer::intValue → NO_COVERAGE
3. kthDistances : removed call to java/util/stream/Stream::sorted → NO_COVERAGE
4. lambda$kthDistances$0 : removed call to java/lang/Integer::intValue → NO_COVERAGE
5. kthDistances : replaced call to java/util/stream/Stream::sorted with receiver → NO_COVERAGE
6. lambda$kthDistances$0 : replaced int return with 0 for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::lambda$kthDistances$0 → NO_COVERAGE
				.sorted((a, b) -> Double.compare(distanceObjectives[index][a], distanceObjectives[index][b]))
81 6 1. kthDistances : replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE
2. lambda$kthDistances$1 : removed call to java/lang/Integer::intValue → NO_COVERAGE
3. lambda$kthDistances$1 : removed call to org/apache/commons/lang3/tuple/ImmutablePair::of → NO_COVERAGE
4. lambda$kthDistances$1 : replaced return value with null for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::lambda$kthDistances$1 → NO_COVERAGE
5. kthDistances : removed call to java/util/stream/Stream::map → NO_COVERAGE
6. lambda$kthDistances$1 : removed call to java/lang/Double::valueOf → NO_COVERAGE
				.map(i -> ImmutablePair.of(i, distanceObjectives[index][i]))
82 2 1. kthDistances : removed call to java/util/stream/Collectors::toList → NO_COVERAGE
2. kthDistances : removed call to java/util/stream/Stream::collect → NO_COVERAGE
				.collect(Collectors.toList());
83
84
	}
85
86
}

Mutations

29

1.1
Location : strength
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

31

1.1
Location : strength
Killed by : none
removed conditional - replaced comparison check with true → NO_COVERAGE

2.2
Location : strength
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE

3.3
Location : strength
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

4.4
Location : strength
Killed by : none
removed conditional - replaced comparison check with false → NO_COVERAGE

5.5
Location : strength
Killed by : none
negated conditional → NO_COVERAGE

6.6
Location : strength
Killed by : none
changed conditional boundary → NO_COVERAGE

32

1.1
Location : strength
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE

34

1.1
Location : strength
Killed by : none
removed conditional - replaced comparison check with true → NO_COVERAGE

2.2
Location : strength
Killed by : none
removed call to java/util/Comparator::compare → NO_COVERAGE

3.3
Location : strength
Killed by : none
negated conditional → NO_COVERAGE

4.4
Location : strength
Killed by : none
changed conditional boundary → NO_COVERAGE

5.5
Location : strength
Killed by : none
removed conditional - replaced comparison check with false → NO_COVERAGE

35

1.1
Location : strength
Killed by : none
Removed increment 1 → NO_COVERAGE

2.2
Location : strength
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

39

1.1
Location : strength
Killed by : none
replaced int return with 0 for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::strength → NO_COVERAGE

53

1.1
Location : rawFitness
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

55

1.1
Location : rawFitness
Killed by : none
removed conditional - replaced comparison check with false → NO_COVERAGE

2.2
Location : rawFitness
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE

3.3
Location : rawFitness
Killed by : none
changed conditional boundary → NO_COVERAGE

4.4
Location : rawFitness
Killed by : none
removed conditional - replaced comparison check with true → NO_COVERAGE

5.5
Location : rawFitness
Killed by : none
negated conditional → NO_COVERAGE

6.6
Location : rawFitness
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

56

1.1
Location : rawFitness
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::getFitness → NO_COVERAGE

58

1.1
Location : rawFitness
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : rawFitness
Killed by : none
removed conditional - replaced equality check with true → NO_COVERAGE

3.3
Location : rawFitness
Killed by : none
removed conditional - replaced equality check with false → NO_COVERAGE

59

1.1
Location : rawFitness
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : rawFitness
Killed by : none
removed call to java/util/Comparator::compare → NO_COVERAGE

3.3
Location : rawFitness
Killed by : none
removed conditional - replaced comparison check with true → NO_COVERAGE

4.4
Location : rawFitness
Killed by : none
negated conditional → NO_COVERAGE

5.5
Location : rawFitness
Killed by : none
removed conditional - replaced comparison check with false → NO_COVERAGE

60

1.1
Location : rawFitness
Killed by : none
Replaced double addition with subtraction → NO_COVERAGE

65

1.1
Location : rawFitness
Killed by : none
replaced int return with 0 for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::rawFitness → NO_COVERAGE

78

1.1
Location : kthDistances
Killed by : none
replaced return value with Collections.emptyList for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::kthDistances → NO_COVERAGE

2.2
Location : kthDistances
Killed by : none
removed call to java/util/stream/IntStream::range → NO_COVERAGE

3.3
Location : kthDistances
Killed by : none
Substituted 0 with 1 → NO_COVERAGE

4.4
Location : kthDistances
Killed by : none
removed call to net/bmahe/genetics4j/core/Population::size → NO_COVERAGE

79

1.1
Location : kthDistances
Killed by : none
removed call to java/util/stream/IntStream::boxed → NO_COVERAGE

80

1.1
Location : lambda$kthDistances$0
Killed by : none
removed call to java/lang/Double::compare → NO_COVERAGE

2.2
Location : lambda$kthDistances$0
Killed by : none
removed call to java/lang/Integer::intValue → NO_COVERAGE

3.3
Location : kthDistances
Killed by : none
removed call to java/util/stream/Stream::sorted → NO_COVERAGE

4.4
Location : lambda$kthDistances$0
Killed by : none
removed call to java/lang/Integer::intValue → NO_COVERAGE

5.5
Location : kthDistances
Killed by : none
replaced call to java/util/stream/Stream::sorted with receiver → NO_COVERAGE

6.6
Location : lambda$kthDistances$0
Killed by : none
replaced int return with 0 for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::lambda$kthDistances$0 → NO_COVERAGE

81

1.1
Location : kthDistances
Killed by : none
replaced call to java/util/stream/Stream::map with receiver → NO_COVERAGE

2.2
Location : lambda$kthDistances$1
Killed by : none
removed call to java/lang/Integer::intValue → NO_COVERAGE

3.3
Location : lambda$kthDistances$1
Killed by : none
removed call to org/apache/commons/lang3/tuple/ImmutablePair::of → NO_COVERAGE

4.4
Location : lambda$kthDistances$1
Killed by : none
replaced return value with null for net/bmahe/genetics4j/moo/spea2/replacement/SPEA2Utils::lambda$kthDistances$1 → NO_COVERAGE

5.5
Location : kthDistances
Killed by : none
removed call to java/util/stream/Stream::map → NO_COVERAGE

6.6
Location : lambda$kthDistances$1
Killed by : none
removed call to java/lang/Double::valueOf → NO_COVERAGE

82

1.1
Location : kthDistances
Killed by : none
removed call to java/util/stream/Collectors::toList → NO_COVERAGE

2.2
Location : kthDistances
Killed by : none
removed call to java/util/stream/Stream::collect → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.25.7 support