Quality Diversity Policy Gradient (QDPG)

To create an instance of QDPG, one need to use an instance of MAP-Elites with the QDPGEmitter, detailed below.

Bases: MultiEmitter

Source code in qdax/core/emitters/qdpg_emitter.py
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
70
71
72
73
74
75
76
class QDPGEmitter(MultiEmitter):
    def __init__(
        self,
        config: QDPGEmitterConfig,
        policy_network: nn.Module,
        env: QDEnv,
        score_novelty: Callable[[Archive, StateDescriptor], Reward],
        selector: Optional[Selector] = None,
    ) -> None:

        self._config = config
        self._policy_network = policy_network
        self._env = env

        # define the quality emitter
        q_emitter = QualityPGEmitter(
            config=config.qpg_config,
            policy_network=policy_network,
            env=env,
            selector=selector,
        )
        # define the diversity emitter
        d_emitter = DiversityPGEmitter(
            config=config.dpg_config,
            policy_network=policy_network,
            env=env,
            score_novelty=score_novelty,
        )

        # define the GA emitter
        variation_fn = functools.partial(
            isoline_variation, iso_sigma=config.iso_sigma, line_sigma=config.line_sigma
        )
        ga_emitter = MixingEmitter(
            mutation_fn=lambda x, r: (x, r),
            variation_fn=variation_fn,
            variation_percentage=1.0,
            batch_size=config.ga_batch_size,
            selector=selector,
        )

        super().__init__(emitters=(q_emitter, d_emitter, ga_emitter))