NeatNodeLayoutValidation.java

1
package net.bmahe.genetics4j.neat.spec;
2
3
import java.util.HashSet;
4
import java.util.List;
5
import java.util.Objects;
6
7
import org.apache.commons.lang3.Validate;
8
9
class NeatNodeLayoutValidation {
10
11
	private NeatNodeLayoutValidation() {
12
	}
13
14
	static void validate(final List<Integer> inputNodeIds, final List<Integer> outputNodeIds,
15
			final long hiddenNodeIdStartInclusive, final long hiddenNodeIdEndExclusive) {
16
		Objects.requireNonNull(inputNodeIds);
17
		Objects.requireNonNull(outputNodeIds);
18
		Validate.isTrue(inputNodeIds.isEmpty() == false, "At least one input node is required");
19
		Validate.isTrue(outputNodeIds.isEmpty() == false, "At least one output node is required");
20
		Validate.isTrue(hiddenNodeIdStartInclusive >= 0, "Hidden-node range start must be non-negative");
21
		Validate.isTrue(hiddenNodeIdStartInclusive < hiddenNodeIdEndExclusive, "Hidden-node range must not be empty");
22
		Validate.isTrue(
23
				hiddenNodeIdEndExclusive <= NeatNodeLayout.MAX_NODE_ID_EXCLUSIVE,
24
					"Hidden-node range exceeds the non-negative int domain");
25
26 1 1. validate : removed call to java/util/HashSet::<init> → KILLED
		final var inputIds = new HashSet<Integer>();
27
		for (final Integer nodeId : inputNodeIds) {
28 1 1. validate : removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayoutValidation::validateExternalId → KILLED
			validateExternalId(nodeId, hiddenNodeIdStartInclusive, hiddenNodeIdEndExclusive);
29
			Validate.isTrue(inputIds.add(nodeId), "Duplicate input node ID: %d", nodeId);
30
		}
31
32 1 1. validate : removed call to java/util/HashSet::<init> → KILLED
		final var outputIds = new HashSet<Integer>();
33
		for (final Integer nodeId : outputNodeIds) {
34 1 1. validate : removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayoutValidation::validateExternalId → SURVIVED
			validateExternalId(nodeId, hiddenNodeIdStartInclusive, hiddenNodeIdEndExclusive);
35
			Validate.isTrue(outputIds.add(nodeId), "Duplicate output node ID: %d", nodeId);
36
			Validate.isTrue(inputIds.contains(nodeId) == false, "Node ID is both an input and output: %d", nodeId);
37
		}
38
	}
39
40
	private static void validateExternalId(final Integer nodeId, final long hiddenNodeIdStartInclusive,
41
			final long hiddenNodeIdEndExclusive) {
42
		Objects.requireNonNull(nodeId);
43
		Validate.isTrue(nodeId >= 0, "External node ID must be non-negative: %d", nodeId);
44
		Validate.isTrue(
45 12 1. validateExternalId : removed conditional - replaced comparison check with false → SURVIVED
2. validateExternalId : removed call to java/lang/Integer::intValue → SURVIVED
3. validateExternalId : changed conditional boundary → SURVIVED
4. validateExternalId : negated conditional → KILLED
5. validateExternalId : negated conditional → KILLED
6. validateExternalId : removed conditional - replaced comparison check with true → KILLED
7. validateExternalId : removed conditional - replaced comparison check with false → KILLED
8. validateExternalId : Substituted 0 with 1 → KILLED
9. validateExternalId : Substituted 1 with 0 → KILLED
10. validateExternalId : removed conditional - replaced comparison check with true → KILLED
11. validateExternalId : removed call to java/lang/Integer::intValue → KILLED
12. validateExternalId : changed conditional boundary → KILLED
				nodeId < hiddenNodeIdStartInclusive || nodeId >= hiddenNodeIdEndExclusive,
46
					"External node ID %d conflicts with the hidden-node range",
47 1 1. validateExternalId : removed call to java/lang/Integer::intValue → SURVIVED
					nodeId);
48
	}
49
}

Mutations

26

1.1
Location : validate
Killed by : net.bmahe.genetics4j.neat.chromosomes.NeatChromosomeTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.chromosomes.NeatChromosomeTest]/[method:preservesExplicitNodeDeclarationOrder()]
removed call to java/util/HashSet::<init> → KILLED

28

1.1
Location : validate
Killed by : net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest]/[method:rejectsInvalidExternalIdsAndRanges()]
removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayoutValidation::validateExternalId → KILLED

32

1.1
Location : validate
Killed by : net.bmahe.genetics4j.neat.chromosomes.NeatChromosomeTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.chromosomes.NeatChromosomeTest]/[method:preservesExplicitNodeDeclarationOrder()]
removed call to java/util/HashSet::<init> → KILLED

34

1.1
Location : validate
Killed by : none
removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayoutValidation::validateExternalId → SURVIVED
Covering tests

45

1.1
Location : validateExternalId
Killed by : net.bmahe.genetics4j.neat.chromosomes.NeatChromosomeTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.chromosomes.NeatChromosomeTest]/[method:nullConnections()]
negated conditional → KILLED

2.2
Location : validateExternalId
Killed by : net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest]/[method:rejectsInvalidExternalIdsAndRanges()]
negated conditional → KILLED

3.3
Location : validateExternalId
Killed by : none
removed conditional - replaced comparison check with false → SURVIVED
Covering tests

4.4
Location : validateExternalId
Killed by : net.bmahe.genetics4j.neat.chromosomes.NeatChromosomeTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.chromosomes.NeatChromosomeTest]/[method:nullConnections()]
removed conditional - replaced comparison check with true → KILLED

5.5
Location : validateExternalId
Killed by : net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest]/[method:rejectsInvalidExternalIdsAndRanges()]
removed conditional - replaced comparison check with false → KILLED

6.6
Location : validateExternalId
Killed by : net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest]/[method:rejectsInvalidExternalIdsAndRanges()]
Substituted 0 with 1 → KILLED

7.7
Location : validateExternalId
Killed by : net.bmahe.genetics4j.neat.chromosomes.NeatChromosomeTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.chromosomes.NeatChromosomeTest]/[method:nullConnections()]
Substituted 1 with 0 → KILLED

8.8
Location : validateExternalId
Killed by : none
removed call to java/lang/Integer::intValue → SURVIVED Covering tests

9.9
Location : validateExternalId
Killed by : net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest]/[method:rejectsInvalidExternalIdsAndRanges()]
removed conditional - replaced comparison check with true → KILLED

10.10
Location : validateExternalId
Killed by : none
changed conditional boundary → SURVIVED Covering tests

11.11
Location : validateExternalId
Killed by : net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest]/[method:rejectsInvalidExternalIdsAndRanges()]
removed call to java/lang/Integer::intValue → KILLED

12.12
Location : validateExternalId
Killed by : net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.spec.NeatNodeLayoutTest]/[method:rejectsInvalidExternalIdsAndRanges()]
changed conditional boundary → KILLED

47

1.1
Location : validateExternalId
Killed by : none
removed call to java/lang/Integer::intValue → SURVIVED
Covering tests

Active mutators

Tests examined


Report generated by PIT 1.23.1 support