innovation (macula_tweann v0.18.1)
View SourceInnovation number tracking for NEAT-style evolution.
This module manages innovation numbers that uniquely identify structural changes in neural networks. Innovation numbers enable: - Meaningful crossover between networks with different topologies - Historical alignment of genes during reproduction - Tracking which structural changes are the "same" across lineages
Key concepts from NEAT (Stanley and Miikkulainen, 2002): - Each new link gets a unique innovation number - When a link is split to add a neuron, the new node and its links get tracked - Same structural change (same from/to) always gets the same innovation
Storage: Uses ETS for innovation tracking and the counters module for atomic counter increments (faster than Mnesia dirty_update_counter).
Summary
Functions
Get innovation info for a specific innovation number.
Get existing link innovation without creating one.
Get existing node innovation without creating one.
Get or create innovation number for a link.
Get or create innovation numbers for a node split.
Initialize innovation tracking with ETS and atomic counter.
Get the next innovation number.
Reset all innovation tracking.
Functions
-spec get_innovation_info(pos_integer()) -> {link, term(), term()} | {node, term(), term(), pos_integer(), pos_integer()} | not_found.
Get innovation info for a specific innovation number.
Returns {link, FromId, ToId} or {node, FromId, ToId, InInn, OutInn} or not_found if the innovation doesn't exist.
-spec get_link_innovation(FromId :: term(), ToId :: term()) -> pos_integer() | undefined.
Get existing link innovation without creating one.
Returns the innovation number if the link exists, undefined otherwise.
-spec get_node_innovation(FromId :: term(), ToId :: term()) -> {pos_integer(), pos_integer(), pos_integer()} | undefined.
Get existing node innovation without creating one.
Returns {NodeInn, InInn, OutInn} if the node split exists, undefined otherwise.
-spec get_or_create_link_innovation(FromId :: term(), ToId :: term()) -> pos_integer().
Get or create innovation number for a link.
If this exact link (from -> to) was seen before, returns the same innovation number. Otherwise, creates a new one. This ensures that the same structural change in different lineages gets the same historical marker.
-spec get_or_create_node_innovation(FromId :: term(), ToId :: term()) -> {pos_integer(), pos_integer(), pos_integer()}.
Get or create innovation numbers for a node split.
When a link is split to add a neuron, we need three innovation numbers: 1. For the new node itself 2. For the new link from the original source to the new node 3. For the new link from the new node to the original target
Returns {NodeInnovation, InLinkInnovation, OutLinkInnovation}
-spec init() -> ok.
Initialize innovation tracking with ETS and atomic counter.
Creates ETS tables for innovation tracking and initializes the atomic counter. Should be called after genotype:init_db().
-spec next_innovation() -> pos_integer().
Get the next innovation number.
Atomically increments and returns the global innovation counter.
-spec reset() -> ok.
Reset all innovation tracking.
Clears all innovation tables and resets the counter. Useful for starting a fresh evolutionary run.