bridge_evaluator (faber_neuroevolution v1.2.4)

View Source

Bridge Evaluator - Adapts Agent SDK to neuroevolution_evaluator behaviour.

This module bridges the Agent SDK's agent_bridge with the neuroevolution system's evaluator interface. It allows agent_trainer to use agent_bridge configurations with neuroevolution_server.

Usage

This module is used internally by agent_trainer. You don't need to use it directly. Configure your training via agent_trainer:train/2.

How It Works

1. agent_trainer stores the validated bridge in evaluator_options 2. This module extracts the bridge and env_config from options 3. For each individual, it extracts the network and runs an episode 4. Returns the individual with populated metrics and fitness

See also: agent_trainer, neuroevolution_evaluator.

Summary

Functions

Calculates fitness from metrics (not used - fitness comes from bridge).

Evaluates an individual using the agent bridge.

Types

fitness/0

-type fitness() :: float() | undefined.

generation/0

-type generation() :: non_neg_integer().

genome/0

-type genome() ::
          #genome{connection_genes ::
                      [#connection_gene{innovation :: pos_integer() | undefined,
                                        from_id :: term(),
                                        to_id :: term(),
                                        weight :: float(),
                                        enabled :: boolean()}],
                  input_count :: non_neg_integer(),
                  hidden_count :: non_neg_integer(),
                  output_count :: non_neg_integer()}.

individual/0

-type individual() ::
          #individual{id :: individual_id(),
                      network :: network(),
                      genome :: genome() | undefined,
                      parent1_id :: individual_id() | undefined,
                      parent2_id :: individual_id() | undefined,
                      fitness :: fitness(),
                      metrics :: metrics(),
                      generation_born :: generation(),
                      birth_evaluation :: non_neg_integer(),
                      max_age :: pos_integer(),
                      is_survivor :: boolean(),
                      is_offspring :: boolean()}.

individual_id/0

-type individual_id() :: term().

metrics/0

-type metrics() :: map().

network/0

-type network() :: term().

Functions

calculate_fitness(Metrics)

-spec calculate_fitness(Metrics) -> float() when Metrics :: map().

Calculates fitness from metrics (not used - fitness comes from bridge).

This is a fallback in case the neuroevolution server calls it directly. Normally, fitness is calculated by agent_evaluator via the bridge.

evaluate(Individual, Options)

-spec evaluate(Individual, Options) -> {ok, Individual} | {error, term()}
                  when Individual :: individual(), Options :: map().

Evaluates an individual using the agent bridge.

Extracts the network from the individual, runs it through the bridge's sense-think-act cycle, and returns the individual with metrics populated.