elixir_evaluator_bridge (faber_neuroevolution v1.2.4)
View SourceBridge module for calling Elixir evaluators from Erlang.
This module implements the neuroevolution_evaluator behaviour and provides a bridge to call Elixir evaluator modules from the Erlang neuroevolution_server.
Usage
Configure neuroevolution_server with this module as the evaluator. Set evaluator_module to elixir_evaluator_bridge and provide elixir_module and elixir_options in evaluator_options.
The Elixir module must export: - evaluate/2 - Takes (IndividualMap, Options), returns ok tuple or error
Summary
Types
-type fitness() :: float() | undefined.
-type generation() :: non_neg_integer().
-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()}.
-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()}.
-type individual_id() :: term().
-type metrics() :: map().
-type network() :: term().
Functions
Calculate fitness from metrics.
This is used when fitness needs to be computed from raw metrics. The Elixir evaluator typically returns fitness directly in the metrics map.
-spec evaluate(individual(), map()) -> {ok, individual()} | {error, term()}.
Evaluate an individual using an Elixir module.
The Options map must contain: - elixir_module: The Elixir module atom (e.g., 'Elixir.MyApp.Evaluator') - elixir_options: Options to pass to the Elixir evaluator (optional) - games: Number of evaluation games/episodes (optional, passed to Elixir) - notify_pid: PID to notify of progress (optional)