Skip to content

Commit

Permalink
docs: enhance the current documentation + gather baselines in separat…
Browse files Browse the repository at this point in the history
…e folder (#57)

Clean docs - udpate css and create baseline folder in qdax

Co-authored-by: Thomas <t.pierrot@instadeep.com>
  • Loading branch information
felixchalumeau and ranzenTom authored Jul 9, 2022
1 parent 8aafcb3 commit a950722
Show file tree
Hide file tree
Showing 41 changed files with 311 additions and 244 deletions.
48 changes: 0 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,54 +81,6 @@ The QDax library also provides implementations for some useful baseline algorith
| [NSGA2](https://ieeexplore.ieee.org/document/996017) | [![Open All Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/adaptive-intelligent-robotics/QDax/blob/main/nsga2_spea2_example.ipynb) |
| [SPEA2](https://www.semanticscholar.org/paper/SPEA2%3A-Improving-the-strength-pareto-evolutionary-Zitzler-Laumanns/b13724cb54ae4171916f3f969d304b9e9752a57f) | [![Open All Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/adaptive-intelligent-robotics/QDax/blob/main/nsga2_spea2_example.ipynb) |


## QDax Overview

QDax has been designed to be modular yet flexible so it's easy for anyone to use and extend on the different state-of-the-art QD algortihms available.
For instance, MAP-Elites is designed to work with a few modular and simple components: `container`, `emitter`, and `scoring_function`.

The `container` specifies the structure of archive of solutions to keep and the addition conditions associated with the archive.

The `emitter` component is responsible for generating new solutions to be evaluated. For example, new solutions can be generated with random mutations, gradient descent, or sampling from distributions as in evolutionary strategies.

The `scoring_function` defines the problem/task we want to solve and functions to evaluate the solutions. For example, the `scoring_function` can be used to represent standard black-box optimization tasks such as rastrigin or RL tasks.

With this modularity, a user can easily swap out any one of the components and pass it to the `MAPElites` class, avoiding having to re-implement all the steps of the algorithm.

Under one layer of abstraction, users have a bit more flexibility. QDax has similarities to the simple and commonly found `ask`/`tell` interface. The `ask` function is similar to the `emit` function in QDax and the `tell` function is similar to the `update` function in QDax. Likewise, the `eval` of solutions is analogous to the `scoring function` in QDax.
More importantly, QDax handles the archive management which is the key idea of QD algorihtms and not present or needed in standard optimization algorihtms or evolutionary strategies.

```python
# Initializes repertoire and emitter state
repertoire, emitter_state, random_key = map_elites.init(init_variables, centroids, random_key)

for i in range(num_iterations):

# generate new population with the emitter
genotypes, random_key = map_elites._emitter.emit(
repertoire, emitter_state, random_key
)

# scores/evaluates the population
fitnesses, descriptors, extra_scores, random_key = map_elites._scoring_function(
genotypes, random_key
)

# update repertoire
repertoire = repertoire.add(genotypes, descriptors, fitnesses)

# update emitter state
emitter_state = map_elites._emitter.state_update(
emitter_state=emitter_state,
repertoire=repertoire,
genotypes=genotypes,
fitnesses=fitnesses,
descriptors=descriptors,
extra_scores=extra_scores,
)
```


## Contributing
Issues and contributions are welcome. Please refer to the [contribution guide](https://qdax.readthedocs.io/en/latest/guides/CONTRIBUTING/) in the documentation for more details.

Expand Down
5 changes: 5 additions & 0 deletions docs/api_documentation/core/cma_mega.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Covariance Matrix Adaptation MAP-Elites via Gradient Arborescence (CMA-MEGA)

To create an instance of CMA-MEGA, one need to use an instance of [MAP-Elites](map_elites.md) with the CMAMEGAEmitter, detailed below.

::: qdax.core.emitters.cma_mega_emitter.CMAMEGAEmitter
2 changes: 1 addition & 1 deletion docs/api_documentation/core/dads.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# DADS class

::: qdax.core.dads.DADS
::: qdax.baselines.dads.DADS
2 changes: 1 addition & 1 deletion docs/api_documentation/core/diayn.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# DIAYN class

::: qdax.core.diayn.DIAYN
::: qdax.baselines.diayn.DIAYN
2 changes: 1 addition & 1 deletion docs/api_documentation/core/genetic_algorithm.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Genetic Algorithm class

::: qdax.core.genetic_algorithm.GeneticAlgorithm
::: qdax.baselines.genetic_algorithm.GeneticAlgorithm
4 changes: 4 additions & 0 deletions docs/api_documentation/core/map_elites.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# MAP Elites class

This class implement the base mechanism of MAP-Elites. It must be used with an emitter. To get the usual MAP-Elites algorithm, one must use the [mixing emitter](emitters.md#qdax.core.emitters.standard_emitters.MixingEmitter).

The MAP-Elites class can be used with other emitters to create variants, like [PGAME](pgame.md), [CMA-MEGA](cma_mega.md) and [OMG-MEGA](omg_mega.md).

::: qdax.core.map_elites.MAPElites
2 changes: 1 addition & 1 deletion docs/api_documentation/core/nsga2.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# NSGA2 class

::: qdax.core.nsga2.NSGA2
::: qdax.baselines.nsga2.NSGA2
5 changes: 5 additions & 0 deletions docs/api_documentation/core/omg_mega.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Objective and Measure Gradient MAP-Elites via Gradient Arborescence (OMGMEGA)

To create an instance of OMGMEGA, one need to use an instance of [MAP-Elites](map_elites.md) with the OMGMEGAEmitter, detailed below.

::: qdax.core.emitters.omg_mega_emitter.OMGMEGAEmitter
5 changes: 5 additions & 0 deletions docs/api_documentation/core/pgame.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Policy Gradient Assisted MAP Elites (PGAME)

To create an instance of PGAME, one need to use an instance of [MAP-Elites](map_elites.md) with the PGAMEEmitter, detailed below.

::: qdax.core.emitters.pga_me_emitter.PGAMEEmitter
2 changes: 1 addition & 1 deletion docs/api_documentation/core/sac.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SAC class

::: qdax.core.sac.SAC
::: qdax.baselines.sac.SAC
4 changes: 2 additions & 2 deletions docs/api_documentation/core/smerl.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SMERL classes for DIAYN and DADS

::: qdax.core.diayn_smerl.DIAYNSMERL
::: qdax.baselines.diayn_smerl.DIAYNSMERL

::: qdax.core.dads_smerl.DADSSMERL
::: qdax.baselines.dads_smerl.DADSSMERL
2 changes: 1 addition & 1 deletion docs/api_documentation/core/spea2.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SPEA2 class

::: qdax.core.spea2.SPEA2
::: qdax.baselines.spea2.SPEA2
2 changes: 1 addition & 1 deletion docs/api_documentation/core/td3.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# TD3 class

::: qdax.core.td3.TD3
::: qdax.baselines.td3.TD3
37 changes: 37 additions & 0 deletions docs/css/mkdocstrings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.field-list {
margin-left: 2% !important;
padding: 4% !important;
border-left-style: solid !important;
border-left-color: #2980B9 !important;
}

.doc-method {
margin-top: 5%;
padding-top: 5%;
border-top-style: solid !important;
border-top-color: #c9c9c9 !important;
}

.doc-children {
margin-left: 2% !important;
}

.doc-class,
.doc-function {
margin-bottom: 10% !important;
padding-bottom: 5%;
border-bottom-style: solid !important;
border-bottom-color: #4e4a4a !important;
}

.doc-attribute {
margin-bottom: 5% !important;
}

details.quote {
margin-top: 2%;
}

.wy-nav-content {
max-width: 1000px !important;
}
Loading

0 comments on commit a950722

Please sign in to comment.