cortex (macula_tweann v0.18.1)

View Source

Neural network coordinator for TWEANN networks.

The cortex is the central coordinator of a neural network. It manages the lifecycle of all neurons, sensors, and actuators, and orchestrates the signal flow through the network during evaluation cycles.

Cortex Lifecycle

1. Spawned with network topology information 2. Spawns all sensors, neurons, and actuators 3. Initiates evaluation cycles by triggering sensors 4. Waits for all actuators to complete 5. Collects fitness from actuators 6. Reports fitness or initiates next cycle 7. Handles backup requests for weight storage

Evaluation Cycle

1. Cortex sends sync to all sensors 2. Sensors read input and forward to neurons 3. Neurons process and forward through network 4. Actuators collect outputs and report to cortex 5. Cortex aggregates results

Summary

Functions

Request backup of all neuron weights.

Initialize the cortex and enter the main loop.

Start a cortex process.

Trigger a synchronization cycle.

Terminate the cortex and all its components.

Functions

backup(CortexPid)

-spec backup(pid()) -> ok.

Request backup of all neuron weights.

The cortex will collect weights from all neurons and send them to the exoself for storage.

init(Opts)

-spec init(map()) -> no_return().

Initialize the cortex and enter the main loop.

start_link(Opts)

-spec start_link(map()) -> {ok, pid()}.

Start a cortex process.

Options: - id - Unique identifier for this cortex - exoself_pid - PID to report results to (optional) - sensor_pids - List of sensor PIDs - neuron_pids - List of neuron PIDs - actuator_pids - List of actuator PIDs - max_cycles - Maximum evaluation cycles (default: infinity)

sync(CortexPid)

-spec sync(pid()) -> ok.

Trigger a synchronization cycle.

This starts an evaluation cycle by signaling all sensors.

terminate(CortexPid)

-spec terminate(pid()) -> ok.

Terminate the cortex and all its components.