Package net.bmahe.genetics4j.neat
Class NeatUtils
java.lang.Object
net.bmahe.genetics4j.neat.NeatUtils
Utility class providing core algorithmic operations for the NEAT (NeuroEvolution of Augmenting Topologies) algorithm.
NeatUtils contains essential algorithms and helper methods for implementing NEAT neural network evolution, including network topology analysis, compatibility distance calculation, speciation, and structural operations. These utilities support the NEAT algorithm's key features of topology innovation, structural mutation, and species-based population organization.
Key functionality areas:
- Network topology analysis: Computing network layers, forward/backward connections, and dead node detection
- Compatibility distance: Measuring genetic similarity between neural networks for speciation
- Speciation management: Organizing populations into species based on genetic similarity
- Structural analysis: Analyzing network connectivity patterns and structural properties
NEAT algorithm integration:
- Innovation tracking: Support for historical marking and innovation numbers
- Structural mutations: Utilities for add-node and add-connection operations
- Network evaluation: Layer-based network evaluation ordering
- Population diversity: Species-based diversity maintenance
Core NEAT concepts implemented:
- Genetic similarity: Compatibility distance based on excess, disjoint, and weight differences
- Topological innovation: Structural changes tracked through innovation numbers
- Speciation: Dynamic species formation based on genetic distance thresholds
- Network evaluation: Feed-forward evaluation through computed network layers
Algorithmic foundations:
- Graph algorithms: Topological sorting, connectivity analysis, and layer computation
- Genetic distance metrics: NEAT-specific compatibility distance calculation
- Population clustering: Species formation and maintenance algorithms
- Network optimization: Dead node removal and structural simplification
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic float
compatibilityDistance
(List<Connection> firstConnections, List<Connection> secondConnections, float c1, float c2, float c3) static float
compatibilityDistance
(Genotype genotype1, Genotype genotype2, int chromosomeIndex, float c1, float c2, float c3) static Map
<Integer, Set<Connection>> computeBackwardConnections
(List<Connection> connections) computeBackwardLinks
(List<Connection> connections) computeDeadNodes
(List<Connection> connections, Map<Integer, Set<Integer>> forwardConnections, Map<Integer, Set<Integer>> backwardConnections, Set<Integer> outputNodeIndices) Working backward from the output nodes, we identify the nodes that did not get visited as dead nodescomputeForwardLinks
(List<Connection> connections) partitionLayersNodes
(Set<Integer> inputNodeIndices, Set<Integer> outputNodeIndices, List<Connection> connections) static <T extends Comparable<T>>
List<Species<T>> speciate
(RandomGenerator random, SpeciesIdGenerator speciesIdGenerator, List<Species<T>> seedSpecies, Population<T> population, BiPredicate<Individual<T>, Individual<T>> speciesPredicate)
-
Constructor Details
-
NeatUtils
private NeatUtils()
-
-
Method Details
-
computeDeadNodes
public static Set<Integer> computeDeadNodes(List<Connection> connections, Map<Integer, Set<Integer>> forwardConnections, Map<Integer, Set<Integer>> backwardConnections, Set<Integer> outputNodeIndices) Working backward from the output nodes, we identify the nodes that did not get visited as dead nodes- Parameters:
connections
-forwardConnections
-backwardConnections
-outputNodeIndices
-- Returns:
-
computeForwardLinks
-
computeBackwardLinks
-
computeBackwardConnections
-
partitionLayersNodes
-
compatibilityDistance
public static float compatibilityDistance(List<Connection> firstConnections, List<Connection> secondConnections, float c1, float c2, float c3) -
compatibilityDistance
-
speciate
public static <T extends Comparable<T>> List<Species<T>> speciate(RandomGenerator random, SpeciesIdGenerator speciesIdGenerator, List<Species<T>> seedSpecies, Population<T> population, BiPredicate<Individual<T>, Individual<T>> speciesPredicate)
-