18 """Store a GENE genome per elite and decode one dense actor per proposal.
20 Use the native neural MAP-Elites rollout budget and Iso+LineDD
21 variation. Deterministic continuous policies and categorical
22 policies use the usual Torch actor after decoding. The returned
23 policy can be exported through its standard save method.
25 :param env_factory: Callable returning a single Gymnasium environment.
26 :param archive: Empty best-only scalar Grid or CVTGrid maximizing fitness.
27 :param coordinate_size: Coordinates evolved per neuron.
28 :param initial_std: Standard deviation for new geometric genomes.
29 :param kwargs: Descriptor, actor architecture, and evaluation settings
30 for :class:`NeuralMAPElites`.
33 def __init__(self, env_factory, archive, *, coordinate_size=3, initial_std=.4, **kwargs):
34 coordinate_size = _integer(coordinate_size,
"coordinate_size")
35 if not 0. < initial_std < np.inf:
36 raise ValueError(
"initial_std must be finite and positive.")
38 super().__init__(env_factory, archive, **kwargs)
39 layers = [module
for module
in self.
_actor._network
if isinstance(module, nn.Linear)]
43 def _genetic_parameters(self):
46 return super()._genetic_parameters()
48 def _prepare(self, cursor, budget):
53 def _offer(self, episodes, emitter, **kwargs):
54 kwargs.setdefault(
"parameters", self.
_genome)
55 return super()._offer(episodes, emitter, **kwargs)
61 def policy_for(self, individual, *, device=None, seed=0):
62 """Return an independent actor with the decoded parameters."""