Bases: MAPElites
Implements Multi-Objectives MAP Elites.
Most methods in this class are inherited from MAPElites.
The same scoring function can be passed into both MAPElites and this class.
We have overridden init such that it takes into account the specificities
of the Multi-Objective repertoire, particularly the pareto_front_max_length.
In particular, we create a wrapper around the provided repertoire_init function
to properly handle the pareto_front_max_length parameter when initializing
the MOMERepertoire.
Source code in qdax/core/mome.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 | class MOME(MAPElites):
"""Implements Multi-Objectives MAP Elites.
Most methods in this class are inherited from MAPElites.
The same scoring function can be passed into both MAPElites and this class.
We have overridden __init__ such that it takes into account the specificities
of the Multi-Objective repertoire, particularly the pareto_front_max_length.
In particular, we create a wrapper around the provided repertoire_init function
to properly handle the pareto_front_max_length parameter when initializing
the MOMERepertoire.
"""
def __init__(
self,
scoring_function: Callable[
[Genotype, RNGKey], Tuple[Fitness, Descriptor, ExtraScores]
],
emitter: Emitter,
metrics_function: Callable[[MOMERepertoire], Metrics],
pareto_front_max_length: int,
repertoire_init: Callable[
[Genotype, Fitness, Descriptor, Centroid, int, Optional[ExtraScores]],
MOMERepertoire,
] = MOMERepertoire.init,
) -> None:
self.pareto_front_max_length = pareto_front_max_length
self._scoring_function = scoring_function
self._emitter = emitter
self._metrics_function = metrics_function
# This is a workaround to make the repertoire_init function work with the
# pareto_front_max_length argument.
def _repertoire_init(
genotypes: Genotype,
fitnesses: Fitness,
descriptors: Descriptor,
centroids: Centroid,
extra_scores: Optional[ExtraScores] = None,
) -> MOMERepertoire:
return repertoire_init(
genotypes,
fitnesses,
descriptors,
centroids,
self.pareto_front_max_length,
extra_scores,
)
self._repertoire_init = _repertoire_init
|