Skip to content

Commit 0c50bba

Browse files
committed
Update documentation
1 parent e86c7db commit 0c50bba

File tree

15 files changed

+863
-128
lines changed

15 files changed

+863
-128
lines changed

.github/CONTRIBUTING.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Contributing
2+
3+
We'd love to accept your patches and contributions to this project. When contributing to the repository, please make sure to first discuss the changes you wish to make via a [github issue](https://github.com/adaptive-intelligent-robotics/QDax/issues).
4+
5+
After the issue is discussed and the solution is determined, you will be invited to fork the repository and create a branch to implement the solution. Once ready to be merged, you can create a [Pull Request](https://github.com/adaptive-intelligent-robotics/QDax/pulls) on github and request to merge into the branch **develop**.
6+
7+
When implementing your contribution, there are just a few guidelines you need to follow.
8+
9+
10+
## Installing Pre-commit hooks
11+
12+
Pre-commits hooks have been configured for this project using the [pre-commit](https://pre-commit.com/) library:
13+
14+
- [black](https://github.com/psf/black) python formatter
15+
- [flake8](https://flake8.pycqa.org/en/latest/) python linter
16+
- [isort](https://pypi.org/project/isort/) sorts imports
17+
- [nbstripout](https://github.com/kynan/nbstripout) strips outputs from notebooks
18+
- [mypy](https://github.com/pre-commit/mirrors-mypy) checks type hints
19+
20+
To get them going on your side, make sure to have python installed, and run the following
21+
commands from the root directory of this repository:
22+
23+
```bash
24+
pip install pre-commit
25+
pre-commit install
26+
```
27+
28+
You can then run the pre-commit hooks on all files as follows:
29+
30+
```bash
31+
pre-commit run --all-files
32+
```
33+
34+
35+
## Coding conventions
36+
37+
Please respect the following conventions to contribute to the code:
38+
39+
- Use hard wrap at 88
40+
- Respect black, isort and flake8 conventions
41+
- Classes' names are Caml case (example: MyClass)
42+
- Functions and variables are in lower case with _ as separator (example: my_function, my_var)
43+
- Names are explicit: avoid mathematical notations, functions' names start with a verb
44+
- Use python typing library: each class and method should be typed (both for inputs and outputs)
45+
- Create custom types if needed
46+
- All classes and functions should have a docstring
47+
- Avoid repeating arguments and returns in docstring (should be explicit with the types) except when it is truly necessary
48+
- A function (or a class) does not take more than 5 arguments, if you need more create a data class
49+
- Avoid dictionaries to pass arguments when possible and prefer dataclasses instead
50+
- Repeat inputs names when calling a function: ex: compute_custom(arg1=arg1, arg2=my_arg2)
51+
- Use list comprehension when it is possible
52+
- Use f strings to add variables in strings: ex: print(f'my var value is {my_var}')
53+
54+
55+
## Commit messages
56+
57+
Please try to follow the conventional [commit standard](https://www.conventionalcommits.org/en/v1.0.0/).
58+
59+
60+
## Merge request and code reviews
61+
62+
All submissions, including submissions by project members, require review. We
63+
use GitHub pull requests for this purpose. Consult
64+
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
65+
information on using pull requests.
66+
67+
68+
## Community Guidelines
69+
70+
This project follows
71+
[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Generated files
2+
public/
23
*.csv
34
*.pth
45
*.png

.readthedocs.yaml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,12 @@ version: 2
88
build:
99
os: ubuntu-20.04
1010
tools:
11-
python: "3.10"
12-
apt_packages:
13-
- swig
11+
python: "3.11"
12+
jobs:
13+
pre_install:
14+
- curl -LsSf https://astral.sh/uv/install.sh | sh
15+
- echo "$HOME/.local/bin" >> $GITHUB_PATH || true
16+
- $HOME/.local/bin/uv pip install .[docs]
1417

1518
mkdocs:
16-
configuration: mkdocs.yml
17-
18-
# Optionally declare the Python requirements required to build your docs
19-
python:
20-
install:
21-
- method: pip
22-
path: .
23-
- requirements: requirements.txt
24-
- requirements: docs/requirements.txt
19+
configuration: mkdocs.yaml

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,23 @@ or with `pip`:
3333
pip install cax
3434
```
3535

36+
### Build the documentation
37+
38+
To install the documentation toolchain and build the site:
39+
40+
```bash
41+
pip install .[docs]
42+
mkdocs build
43+
```
44+
45+
For local preview with live reload:
46+
47+
```bash
48+
mkdocs serve
49+
```
50+
3651
## Basic API Usage
52+
3753
For a full and interactive example to see how QDax works, we recommend starting with the tutorial-style [Colab notebook](./examples/mapelites.ipynb). It is an example of the MAP-Elites algorithm used to evolve a population of controllers on a chosen Brax environment (Walker by default).
3854

3955
However, a summary of the main API usage is provided below:
@@ -128,8 +144,8 @@ repertoire.genotypes, repertoire.fitnesses, repertoire.descriptors
128144

129145

130146
## QDax core algorithms
131-
QDax currently supports the following algorithms:
132147

148+
QDax currently supports the following algorithms:
133149

134150
| Algorithm | Example |
135151
|-------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -149,6 +165,7 @@ QDax currently supports the following algorithms:
149165

150166

151167
## QDax baseline algorithms
168+
152169
The QDax library also provides implementations for some useful baseline algorithms:
153170

154171
| Algorithm | Example |
@@ -160,19 +177,27 @@ The QDax library also provides implementations for some useful baseline algorith
160177
| [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/examples/nsga2_spea2.ipynb) |
161178
| [Population Based Training (PBT)](https://arxiv.org/abs/1711.09846) | [![Open All Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/adaptive-intelligent-robotics/QDax/blob/main/examples/sac_pbt.ipynb) |
162179

180+
163181
## QDax Tasks
182+
164183
The QDax library also provides numerous implementations for several standard Quality-Diversity tasks.
165184

166-
All those implementations, and their descriptions are provided in the [tasks directory](./qdax/tasks).
185+
All those implementations, and their descriptions are provided in the [Tasks page](https://qdax.readthedocs.io/en/latest/api_documentation/tasks/).
186+
167187

168188
## Contributing
189+
169190
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.
170191

192+
171193
## Related Projects
194+
172195
- [EvoJAX: Hardware-Accelerated Neuroevolution](https://github.com/google/evojax). EvoJAX is a scalable, general purpose, hardware-accelerated neuroevolution toolkit. [Paper](https://arxiv.org/abs/2202.05008)
173196
- [evosax: JAX-Based Evolution Strategies](https://github.com/RobertTLange/evosax)
174197

198+
175199
## Citing QDax
200+
176201
If you use QDax in your research and want to cite it in your work, please use:
177202
```
178203
@article{chalumeau2024qdax,
@@ -186,6 +211,7 @@ If you use QDax in your research and want to cite it in your work, please use:
186211
}
187212
```
188213

214+
189215
## Contributors
190216

191217
QDax was developed and is maintained by the [Adaptive & Intelligent Robotics Lab (AIRL)](https://www.imperial.ac.uk/adaptive-intelligent-robotics/) and [InstaDeep](https://www.instadeep.com/).

docs/api_documentation/core/aurora.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AURORA class
22

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

55
The AURORA class can be used with other emitters to create variants, like [PGA-AURORA](pga_aurora.md).
66

docs/api_documentation/core/map_elites.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MAP Elites class
22

3-
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).
3+
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).
44

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

docs/caveats.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
Here is a few caveats one should be aware of when using QDax.
44

5+
56
## Use of auto reset for Brax environments
7+
68
The use of `auto_reset` can be tricky and lead to problems and/or unwanted behaviors. By defaults in our examples, we set auto reset equals True, so the samples collected in the Replay Buffer are good quality samples and stay within the distribution of interest. This is particularly important in the case of PGAME, where putting auto reset to False could lead to important decrease in data efficiency and final performance.
79

10+
811
## In-place replacement of state descriptors in QDTransition
12+
913
The state descriptor from Brax environments is stored in a dictionary. The retrievement of this data when building the QDTransition in a step is hence tricky. The state descriptor must be stored in a variable before applying a environment step, because an in-place replacement is going to occur during the step function of Brax.
1014

1115
One should take inspiration from the `play_step` function from our examples.

docs/guides/CONTRIBUTING.md

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,3 @@
1-
# Contributing
1+
<!-- This page includes the .github/CONTRIBUTING.md to avoid duplication. -->
22

3-
We'd love to accept your patches and contributions to this project. When contributing to the repository, please make sure to first discuss the changes you wish to make via a [github issue](https://github.com/adaptive-intelligent-robotics/QDax/issues).
4-
5-
After the issue is discussed and the solution is determined, you will be invited to fork the repository and create a branch to implement the solution. Once ready to be merged, you can create a [Pull Request](https://github.com/adaptive-intelligent-robotics/QDax/pulls) on github and request to merge into the branch **develop**.
6-
7-
When implementing your contribution, there are just a few guidelines you need to follow.
8-
9-
## Installing Pre-commit hooks
10-
11-
Pre-commits hooks have been configured for this project using the [pre-commit](https://pre-commit.com/) library:
12-
13-
- [black](https://github.com/psf/black) python formatter
14-
- [flake8](https://flake8.pycqa.org/en/latest/) python linter
15-
- [isort](https://pypi.org/project/isort/) sorts imports
16-
- [nbstripout](https://github.com/kynan/nbstripout) strips outputs from notebooks
17-
- [mypy](https://github.com/pre-commit/mirrors-mypy) checks type hints
18-
19-
To get them going on your side, make sure to have python installed, and run the following
20-
commands from the root directory of this repository:
21-
22-
```bash
23-
pip install pre-commit
24-
pre-commit install
25-
```
26-
27-
You can then run the pre-commit hooks on all files as follows:
28-
29-
```bash
30-
pre-commit run --all-files
31-
```
32-
33-
## Coding conventions
34-
35-
Please respect the following conventions to contribute to the code:
36-
37-
- Use hard wrap at 88
38-
- Respect black, isort and flake8 conventions
39-
- Classes' names are Caml case (example: MyClass)
40-
- Functions and variables are in lower case with _ as separator (example: my_function, my_var)
41-
- Names are explicit: avoid mathematical notations, functions' names start with a verb
42-
- Use python typing library: each class and method should be typed (both for inputs and outputs)
43-
- Create custom types if needed
44-
- All classes and functions should have a docstring
45-
- Avoid repeating arguments and returns in docstring (should be explicit with the types) except when it is truly necessary
46-
- A function (or a class) does not take more than 5 arguments, if you need more create a data class
47-
- Avoid dictionaries to pass arguments when possible and prefer dataclasses instead
48-
- Repeat inputs names when calling a function: ex: compute_custom(arg1=arg1, arg2=my_arg2)
49-
- Use list comprehension when it is possible
50-
- Use f strings to add variables in strings: ex: print(f'my var value is {my_var}')
51-
52-
## Commit messages
53-
54-
Please try to follow the conventional [commit standard](https://www.conventionalcommits.org/en/v1.0.0/).
55-
56-
## Merge request and code reviews
57-
58-
All submissions, including submissions by project members, require review. We
59-
use GitHub pull requests for this purpose. Consult
60-
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
61-
information on using pull requests.
62-
63-
## Community Guidelines
64-
65-
This project follows
66-
[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
3+
--8<-- ".github/CONTRIBUTING.md"

docs/overview.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,34 @@
33
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 algorithms available.
44
For instance, MAP-Elites is designed to work with a few modular and simple components: `container`, `emitter`, and `scoring_function`.
55

6+
67
## Key concepts
8+
79
### Container
10+
811
The `container` specifies the structure of archive of solutions to keep and the addition conditions associated with the archive.
912

13+
1014
### Emitter
15+
1116
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.
1217

18+
1319
### Scoring Function
20+
1421
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.
1522

23+
1624
## Design Choices
25+
1726
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.
1827

1928
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.
2029
More importantly, QDax handles the archive management which is the key idea of QD algorithms and not present or needed in standard optimization algorithms or evolutionary strategies.
2130

31+
2232
## Code Example
33+
2334
```python
2435
# Initializes repertoire and emitter state
2536
repertoire, emitter_state, key = map_elites.init(init_variables, centroids, key)

docs/requirements.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)