lc_chain (faber_neuroevolution v1.2.4)

View Source

Chained LTC Controller for Liquid Conglomerate.

This gen_server manages the L2→L1→L0 chain of LTC TWEANN networks. Each level is a separate neural network that learns at different timescales.

Architecture

L2 (Strategic, τ=100): Inputs: Evolution metrics (fitness, stagnation, diversity) Outputs: 4 strategic signals → L1 inputs

L1 (Tactical, τ=50): Inputs: L2's 4 outputs Outputs: 5 tactical signals → L0 inputs

L0 (Reactive, τ=10): Inputs: L1's 5 outputs + emergent metrics (evolvable sensors) Outputs: Final hyperparameters

Usage

%% Start the chain {ok, Pid} = lc_chain:start_link(Config),

%% Forward pass: compute hyperparameters EvoMetrics = #evolution_metrics{best_fitness = 0.85, ...}, EmergentMetrics = #emergent_metrics{convergence_rate = 0.02, ...}, Hyperparams = lc_chain:forward(Pid, EvoMetrics, EmergentMetrics),

%% Train: provide reward signal lc_chain:train(Pid, Reward).

Summary

Functions

Forward pass with only evolution metrics.

Forward pass through the chain.

Get last computed hyperparameters.

Get current chain state (for debugging/visualization).

Reset the chain state.

Start the LC chain with default configuration.

Start the LC chain with custom configuration.

Train the chain with a reward signal.

Types

emergent_metrics/0

-type emergent_metrics() ::
          #emergent_metrics{convergence_rate :: float(),
                            fitness_plateau_duration :: non_neg_integer(),
                            current_mutation_rate :: float(),
                            current_selection_ratio :: float(),
                            survival_rate :: float(),
                            offspring_rate :: float(),
                            elite_age :: non_neg_integer(),
                            complexity_trend :: float(),
                            avg_network_size :: float(),
                            species_extinction_rate :: float(),
                            species_creation_rate :: float(),
                            innovation_rate :: float(),
                            diversity_index :: float()}.

evolution_metrics/0

-type evolution_metrics() ::
          #evolution_metrics{best_fitness :: float(),
                             avg_fitness :: float(),
                             fitness_improvement :: float(),
                             fitness_variance :: float(),
                             stagnation_counter :: non_neg_integer(),
                             generation_progress :: float(),
                             population_diversity :: float(),
                             species_count :: pos_integer()}.

lc_chain_config/0

-type lc_chain_config() ::
          #lc_chain_config{l2_tau :: float(),
                           l1_tau :: float(),
                           l0_tau :: float(),
                           learning_rate :: float(),
                           evolve_topology :: boolean(),
                           l2_hidden_layers :: [pos_integer()],
                           l1_hidden_layers :: [pos_integer()],
                           l0_hidden_layers :: [pos_integer()],
                           activation :: tanh | sigmoid | relu,
                           gamma :: float()}.

lc_hyperparams/0

-type lc_hyperparams() ::
          #lc_hyperparams{mutation_rate :: float(),
                          mutation_strength :: float(),
                          selection_ratio :: float(),
                          add_node_rate :: float(),
                          add_connection_rate :: float()}.

lc_level_state/0

-type lc_level_state() ::
          #lc_level_state{level :: l0 | l1 | l2,
                          agent_id :: term(),
                          tau :: float(),
                          neuron_states :: #{term() => float()},
                          last_outputs :: [float()],
                          connected_sensors :: [atom()],
                          generation :: non_neg_integer()}.

Functions

code_change(OldVsn, State, Extra)

forward(ServerRef, EvoMetrics)

-spec forward(pid() | atom(), evolution_metrics()) -> lc_hyperparams().

Forward pass with only evolution metrics.

Uses default emergent metrics.

forward(ServerRef, EvoMetrics, EmergentMetrics)

-spec forward(pid() | atom(), evolution_metrics(), emergent_metrics()) -> lc_hyperparams().

Forward pass through the chain.

Computes hyperparameters by cascading through L2→L1→L0.

get_hyperparams(ServerRef)

-spec get_hyperparams(pid() | atom()) -> lc_hyperparams().

Get last computed hyperparameters.

get_state(ServerRef)

-spec get_state(pid() | atom()) -> {ok, map()}.

Get current chain state (for debugging/visualization).

handle_call(Request, From, State)

handle_cast(Msg, State)

handle_info(Info, State)

init(Config)

reset(ServerRef)

-spec reset(pid() | atom()) -> ok.

Reset the chain state.

start_link()

-spec start_link() -> {ok, pid()} | {error, term()}.

Start the LC chain with default configuration.

start_link(Config)

-spec start_link(lc_chain_config()) -> {ok, pid()} | {error, term()}.

Start the LC chain with custom configuration.

terminate(Reason, State)

train(ServerRef, Reward)

-spec train(pid() | atom(), float()) -> ok.

Train the chain with a reward signal.

Backpropagates reward through all three levels.