meta_reward (faber_neuroevolution v1.2.4)

View Source

Composite reward computation for meta-controller training.

This module computes a multi-objective reward signal for training the meta-controller. The reward balances multiple objectives:

1. **Convergence Speed** - How quickly fitness improves 2. **Final Fitness** - Absolute performance achieved 3. **Efficiency Ratio** - Fitness gained per computation spent 4. **Diversity Awareness** - Maintains exploration capacity 5. **Normative Structure** - Preserves capacity for future adaptation

Reward Formula

The total reward is a weighted sum:

R = w1*convergence + w2*fitness + w3*efficiency + w4*diversity + w5*normative

Where weights are configured in meta_config.reward_weights.

Normalization

All reward components are normalized to [0, 1] or [-1, 1] range for stable training. Historical data is used for normalization.

Summary

Functions

Compute composite reward for a generation.

Compute individual reward components.

Normalize a reward component value.

Types

generation_metrics/0

-type generation_metrics() ::
          #generation_metrics{generation :: pos_integer(),
                              best_fitness :: float(),
                              avg_fitness :: float(),
                              worst_fitness :: float(),
                              fitness_std_dev :: float(),
                              fitness_delta :: float(),
                              relative_improvement :: float(),
                              population_diversity :: float(),
                              strategy_entropy :: float(),
                              evaluations_used :: pos_integer(),
                              fitness_per_evaluation :: float(),
                              diversity_corridors :: float(),
                              adaptation_readiness :: float(),
                              params_used :: #{meta_param() => float()},
                              timestamp :: erlang:timestamp()}.

meta_config/0

-type meta_config() ::
          #meta_config{network_topology :: {pos_integer(), [pos_integer()], pos_integer()},
                       neuron_type :: ltc | cfc,
                       time_constant :: float(),
                       state_bound :: float(),
                       reward_weights :: #{reward_component() => float()},
                       learning_rate :: float(),
                       param_bounds :: #{meta_param() => {float(), float()}},
                       control_population_size :: boolean(),
                       control_topology :: boolean(),
                       history_window :: pos_integer(),
                       momentum :: float()}.

meta_param/0

-type meta_param() ::
          mutation_rate | mutation_strength | selection_ratio | evaluations_per_individual |
          max_concurrent_evaluations | population_size | add_node_rate | add_connection_rate |
          complexity_penalty.

meta_reward/0

-type meta_reward() ::
          #meta_reward{convergence_speed :: float(),
                       final_fitness :: float(),
                       efficiency_ratio :: float(),
                       diversity_aware :: float(),
                       normative_structure :: float(),
                       total :: float(),
                       generation :: pos_integer()}.

reward_component/0

-type reward_component() ::
          convergence_speed | final_fitness | efficiency_ratio | diversity_aware | normative_structure.

Functions

compute(Metrics, History, Config)

Compute composite reward for a generation.

compute_components(Metrics, History, Config)

-spec compute_components(generation_metrics(), [generation_metrics()], meta_config()) ->
                            #{atom() => float()}.

Compute individual reward components.

normalize_component(Component, Value, History)

-spec normalize_component(atom(), float(), [float()]) -> float().

Normalize a reward component value.

Uses tweann_nif:z_score/3 for NIF-accelerated Z-score computation.