NodeIdManagerRegistry.java

1
package net.bmahe.genetics4j.neat;
2
3
import java.util.List;
4
import java.util.Objects;
5
import java.util.concurrent.ConcurrentHashMap;
6
7
import net.bmahe.genetics4j.neat.spec.NeatNodeLayout;
8
9
/**
10
 * Maintains one population-scoped {@link NodeIdManager} per semantic node layout.
11
 *
12
 * <p>Layouts are keyed by their ordered input IDs, ordered output IDs, and hidden-node range rather than their concrete
13
 * implementation class. Semantically equivalent layout implementations therefore share allocation history.
14
 */
15
public class NodeIdManagerRegistry {
16
17
	private record LayoutKey(List<Integer> inputNodeIds, List<Integer> outputNodeIds, long hiddenStart, long hiddenEnd) {
18
		private LayoutKey(final NeatNodeLayout layout) {
19 2 1. <init> : removed call to java/util/List::copyOf → SURVIVED
2. <init> : removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayout::inputNodeIds → KILLED
			this(List.copyOf(layout.inputNodeIds()),
20 2 1. <init> : removed call to java/util/List::copyOf → SURVIVED
2. <init> : removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayout::outputNodeIds → KILLED
					List.copyOf(layout.outputNodeIds()),
21 1 1. <init> : removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayout::hiddenNodeIdStartInclusive → SURVIVED
					layout.hiddenNodeIdStartInclusive(),
22 1 1. <init> : removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayout::hiddenNodeIdEndExclusive → SURVIVED
					layout.hiddenNodeIdEndExclusive());
23
		}
24
	}
25
26 2 1. <init> : Removed assignment to member variable managers → KILLED
2. <init> : removed call to java/util/concurrent/ConcurrentHashMap::<init> → KILLED
	private final ConcurrentHashMap<LayoutKey, NodeIdManager> managers = new ConcurrentHashMap<>();
27
28
	/**
29
	 * Returns the shared node-ID manager for a layout, creating it when first requested.
30
	 *
31
	 * @param nodeLayout node layout used by a population
32
	 * @return the shared manager for the layout's semantic key
33
	 * @throws NullPointerException if {@code nodeLayout} is {@code null}
34
	 */
35
	public NodeIdManager managerFor(final NeatNodeLayout nodeLayout) {
36
		Objects.requireNonNull(nodeLayout);
37 6 1. managerFor : removed call to net/bmahe/genetics4j/neat/NodeIdManagerRegistry$LayoutKey::<init> → KILLED
2. lambda$managerFor$0 : removed call to net/bmahe/genetics4j/neat/NodeIdManager::<init> → KILLED
3. lambda$managerFor$0 : replaced return value with null for net/bmahe/genetics4j/neat/NodeIdManagerRegistry::lambda$managerFor$0 → KILLED
4. managerFor : removed call to java/util/concurrent/ConcurrentHashMap::computeIfAbsent → KILLED
5. managerFor : replaced call to java/util/concurrent/ConcurrentHashMap::computeIfAbsent with argument → KILLED
6. managerFor : replaced return value with null for net/bmahe/genetics4j/neat/NodeIdManagerRegistry::managerFor → KILLED
		return managers.computeIfAbsent(new LayoutKey(nodeLayout), ignored -> new NodeIdManager(nodeLayout));
38
	}
39
}

Mutations

19

1.1
Location : <init>
Killed by : net.bmahe.genetics4j.neat.NodeIdManagerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.NodeIdManagerTest]/[method:registryUsesSemanticLayoutKeys()]
removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayout::inputNodeIds → KILLED

2.2
Location : <init>
Killed by : none
removed call to java/util/List::copyOf → SURVIVED
Covering tests

20

1.1
Location : <init>
Killed by : net.bmahe.genetics4j.neat.NodeIdManagerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.NodeIdManagerTest]/[method:registryUsesSemanticLayoutKeys()]
removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayout::outputNodeIds → KILLED

2.2
Location : <init>
Killed by : none
removed call to java/util/List::copyOf → SURVIVED
Covering tests

21

1.1
Location : <init>
Killed by : none
removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayout::hiddenNodeIdStartInclusive → SURVIVED
Covering tests

22

1.1
Location : <init>
Killed by : none
removed call to net/bmahe/genetics4j/neat/spec/NeatNodeLayout::hiddenNodeIdEndExclusive → SURVIVED
Covering tests

26

1.1
Location : <init>
Killed by : net.bmahe.genetics4j.neat.NodeIdManagerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.NodeIdManagerTest]/[method:registryUsesSemanticLayoutKeys()]
Removed assignment to member variable managers → KILLED

2.2
Location : <init>
Killed by : net.bmahe.genetics4j.neat.NodeIdManagerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.NodeIdManagerTest]/[method:registryUsesSemanticLayoutKeys()]
removed call to java/util/concurrent/ConcurrentHashMap::<init> → KILLED

37

1.1
Location : managerFor
Killed by : net.bmahe.genetics4j.neat.NodeIdManagerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.NodeIdManagerTest]/[method:registryUsesSemanticLayoutKeys()]
removed call to net/bmahe/genetics4j/neat/NodeIdManagerRegistry$LayoutKey::<init> → KILLED

2.2
Location : lambda$managerFor$0
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.SparseStructuralMutationTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.SparseStructuralMutationTest]/[method:homologousSplitsAcrossChromosomesReuseHiddenNodeId()]
removed call to net/bmahe/genetics4j/neat/NodeIdManager::<init> → KILLED

3.3
Location : lambda$managerFor$0
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.SparseStructuralMutationTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.SparseStructuralMutationTest]/[method:homologousSplitsAcrossChromosomesReuseHiddenNodeId()]
replaced return value with null for net/bmahe/genetics4j/neat/NodeIdManagerRegistry::lambda$managerFor$0 → KILLED

4.4
Location : managerFor
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.SparseStructuralMutationTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.SparseStructuralMutationTest]/[method:homologousSplitsAcrossChromosomesReuseHiddenNodeId()]
removed call to java/util/concurrent/ConcurrentHashMap::computeIfAbsent → KILLED

5.5
Location : managerFor
Killed by : net.bmahe.genetics4j.neat.NodeIdManagerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.NodeIdManagerTest]/[method:registryUsesSemanticLayoutKeys()]
replaced call to java/util/concurrent/ConcurrentHashMap::computeIfAbsent with argument → KILLED

6.6
Location : managerFor
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.SparseStructuralMutationTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.SparseStructuralMutationTest]/[method:homologousSplitsAcrossChromosomesReuseHiddenNodeId()]
replaced return value with null for net/bmahe/genetics4j/neat/NodeIdManagerRegistry::managerFor → KILLED

Active mutators

Tests examined


Report generated by PIT 1.25.7 support