initialize

Variable initialization for Neuroevolution fitting.

cneuromax.fitting.neuroevolution.utils.initialize.initialize_common_variables(agents_per_task, num_pops)[source]

Initializes variables common to all execution modes.

Parameters:
Return type:

tuple[int, int, ndarray[Shape[Pop_size, Num_pops, [mpi_buffer_size, agent_pair_position, sending, seeds]], dtype[uint32]] | None, ndarray[Shape[Len_agents_batch, Num_pops, [mpi_buffer_size, agent_pair_position, sending, seeds]], dtype[uint32]], ndarray[Shape[Len_agents_batch, Num_pops], dtype[uint32]], ndarray[Shape[Pop_size, Num_pops, [fitness, num_env_steps, serialized_agent_size]], dtype[float32]] | None, ndarray[Shape[Len_agents_batch, Num_pops, [fitness, num_env_steps, serialized_agent_size]], dtype[float32]], Optional[int]]

Returns:

pop_size,

len_agents_batch, exchange_and_mutate_info, exchange_and_mutate_info_batch, An array used as a buffer by all processes to receive the seeds from the primary process during the first generation only. generation_results, generation_results_batch, total_num_env_steps.

cneuromax.fitting.neuroevolution.utils.initialize.initialize_gpu_comm()[source]

Initializes a communicator for GPU work queueing.

Assuming the experiment is ran with N MPI processes & M GPUs, this function will create M communicators, each containing N/M processes. Each communicator will be used to gather mutated agents onto one process, which will then evaluate them on the GPU.

Return type:

Comm

Returns:

See ith_gpu_comm.

cneuromax.fitting.neuroevolution.utils.initialize.initialize_agents(agent, len_agents_batch, num_pops, *, pop_merge)[source]

Initializes a batch of agents.

Parameters:
Return type:

list[list[BaseAgent]]

Returns:

A 2D list of agents maintained by this process.