Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (algo): Add MAP-Elites Low-Spread #152

Merged
merged 26 commits into from
Aug 23, 2023

Conversation

btjanaka
Copy link
Collaborator

@btjanaka btjanaka commented Aug 11, 2023

Related issues: [refer to issues] Resolves #151

[Introduce the overall change made in the PR and list the associated modifications below]

Add MAP-Elites Low-Spread: https://dl.acm.org/doi/abs/10.1145/3583131.3590433

This PR introduces:

  • MELSRepertoire in mels_repertoire.py
    • Tests in mels_repertoire_test.py
  • MELS in mels.py
    • Tests in mels_test.py
  • Spread type in types.py
  • multi_sample_scoring_function in sampling.py

Questions

  1. Should we store all n_evals fitnesses and descriptors in the repertoire, or should we just store the aggregated fitness and descriptors? We can also store both the aggregate and the separate values. Storing separate values would require passing in n_evals to MELSRepertoire.init_default so that we can define the shapes of fitnesses and descriptors.
  2. Should we check if one individual dominates the others if inserting multiple individuals into the same cell?
  3. What link should I use for citations? Currently I am using the ACM Digital Library link. I can also use the arXiv link: https://arxiv.org/abs/2303.16207 if preferred.

Checks

  • a clear description of the PR has been added
  • sufficient tests have been written
  • relevant section added to the documentation
  • example notebook added to the repo
  • clean docstrings and comments have been written
  • if any issue/observation has been discovered, a new issue has been opened

Future improvements

[List here potential observations made and/or improvements that could be made in the future. If relevant, open issues for those.]

@btjanaka btjanaka changed the base branch from main to develop August 11, 2023 21:55
@btjanaka btjanaka marked this pull request as ready for review August 14, 2023 22:41
@Lookatator
Copy link
Member

Hi @btjanaka ! Thank you very much for this (super well-documented) PR.

I added @Egiob and @manon-but-yes as reviewers for this PR; they are probably the best people to judge it.

I had an overview of the code and it looks great! I have mainly one high-level comment regarding the implementation of the reevaluation scoring function (and where it should be implemented). I will add it as a comment.

@btjanaka
Copy link
Collaborator Author

Hi @Lookatator, thank you for taking a look at this PR! I addressed your comment on the pairwise distance calculation, but I do not see the comment on scoring function evaluation. Did you make the comment in the tests or the notebook? (the scoring function is in both those places).

@Egiob
Copy link
Collaborator

Egiob commented Aug 16, 2023

Hi guys! I will do a pass by the end of the week 😄

@Lookatator
Copy link
Member

Hi @Lookatator, thank you for taking a look at this PR! I addressed your comment on the pairwise distance calculation, but I do not see the comment on scoring function evaluation. Did you make the comment in the tests or the notebook? (the scoring function is in both those places).

Sorry for the late reply @btjanaka , I did not have the time to post it yesterday, and I also was hesitating to add additional comments regarding the repertoire management (I think the calculation of the mode and of the spread should be done in the algorithm, and the repertoire addition condition should be receiving the same kinds of inputs as the MOMERepertoire). On further consideration, I will keep those comments for another PR, whose purpose will be to make the repertoire of MELS more modular.

qdax/core/mels.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@Egiob Egiob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @btjanaka, thanks for the very-clean PR, amazing work! I've left a couple of small suggestions, but all good for me 👍

tests/core_test/containers_test/mels_repertoire_test.py Outdated Show resolved Hide resolved
from qdax.types import Centroid, Descriptor, ExtraScores, Fitness, Genotype, Spread


def _dispersion(descriptors: jnp.ndarray) -> jnp.ndarray:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion: perhaps these functions belong elsewhere in a utils/ file ? I feel like they can be used by other methods as scores or metrics

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if it becomes something used in multiple places, perhaps it can then be refactored? Since it is a private function, it seems it can be moved around pretty easily.

qdax/core/mels.py Outdated Show resolved Hide resolved
@btjanaka
Copy link
Collaborator Author

Thank you @Egiob! I've resolved all your comments except for the one about moving _dispersion

@btjanaka
Copy link
Collaborator Author

@Lookatator Is there anything else I should do to get this PR merged?

@manon-but-yes
Copy link
Collaborator

Hi @btjanaka thank you for this PR! Apologies for the delay I just got back to work.

qdax/core/mels.py Outdated Show resolved Hide resolved
@manon-but-yes manon-but-yes self-requested a review August 23, 2023 09:24
@Lookatator Lookatator changed the base branch from develop to feat/mels August 23, 2023 13:07
@Lookatator Lookatator merged commit 79939ee into adaptive-intelligent-robotics:feat/mels Aug 23, 2023
4 of 5 checks passed
@Lookatator
Copy link
Member

@btjanaka I merged it into a local branch to check potential style issues before merging into develop :)

btjanaka added a commit that referenced this pull request Aug 23, 2023
@btjanaka btjanaka deleted the mels branch August 23, 2023 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add MAP-Elites Low-Spread
5 participants