exchange¶
Process agent exchange for Neuroevolution fitting.
- cneuromax.fitting.neuroevolution.utils.exchange.update_exchange_and_mutate_info(num_pops, pop_size, exchange_and_mutate_info, generation_results, seeds)[source]¶
Update the exchange and mutate information.
The selection process of the algorithm is in some sense implicit in
cneuromax
. We make use of 50% truncation selection, which is reflected in the information stored insideexchange_and_mutate_info
.In some sense, the selection process of the algorithm is performed in this function.
- Parameters:
exchange_and_mutate_info (
ndarray
[Shape
[Pop_size, Num_pops, [mpi_buffer_size, agent_pair_position, sending, seeds]],dtype
[uint32
]] |None
) – An array maintained only by the primary process (secondary processes set this toNone
) containing information for all processes on how to exchange and mutate agents. Precisions on the 3rd dimension: 0) The size of the agent when serialized, 1) The position of the agent paired for with the current agent, 2) Whether to send or receive the agent, 3) The seed to randomize the mutation and evaluation of the agent.generation_results (
ndarray
[Shape
[Pop_size, Num_pops, [fitness, num_env_steps, serialized_agent_size]],dtype
[float32
]] |None
) – Seegeneration_results
.seeds (
ndarray
[Shape
[Pop_size, Num_pops],dtype
[uint32
]] |None
) – The seeds to set the mutation and evaluation randomness for the current generation.
- Return type:
- cneuromax.fitting.neuroevolution.utils.exchange.exchange_agents(num_pops, pop_size, agents_batch, exchange_and_mutate_info_batch)[source]¶
Exchange agents between processes.
- Parameters:
agents_batch (
list
[list
[BaseAgent
]]) – Seeagents_batch
.exchange_and_mutate_info_batch (
ndarray
[Shape
[Len_agents_batch, Num_pops, [mpi_buffer_size, agent_pair_position, sending, seeds]],dtype
[uint32
]]) – Seeexchange_and_mutate_info_batch
.
- Return type: