NodeIdManagerRegistry.java

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

Mutations

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::inputNodeIds → 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 : 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

22

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

23

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

27

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

38

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.23.1 support