From b27c924d54c606736207f705daab690bdedb161b Mon Sep 17 00:00:00 2001 From: Lisa Date: Thu, 4 Jul 2024 09:53:53 +0200 Subject: [PATCH 1/6] change indexing to retrieve current fitness in intra batch comp --- qdax/core/containers/unstructured_repertoire.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qdax/core/containers/unstructured_repertoire.py b/qdax/core/containers/unstructured_repertoire.py index f4cc0c98..e7793825 100644 --- a/qdax/core/containers/unstructured_repertoire.py +++ b/qdax/core/containers/unstructured_repertoire.py @@ -104,7 +104,7 @@ def intra_batch_comp( # We want to eliminate the same individual (distance 0) fitness = jnp.where(knn_relevant_indices == current_index, False, fitness) current_fitness = jnp.squeeze( - eval_scores.at[knn_relevant_indices.at[0].get()].get() + eval_scores.at[current_index].get() ) # Is the fitness of the other individual higher? From 4b0776684a9d2774d906e0b222923ca516cec6bf Mon Sep 17 00:00:00 2001 From: lc1021 Date: Thu, 19 Sep 2024 15:37:25 +0000 Subject: [PATCH 2/6] Reformat from pre-commit hooks --- qdax/core/containers/unstructured_repertoire.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qdax/core/containers/unstructured_repertoire.py b/qdax/core/containers/unstructured_repertoire.py index cdbc3be3..4a1c0cdb 100644 --- a/qdax/core/containers/unstructured_repertoire.py +++ b/qdax/core/containers/unstructured_repertoire.py @@ -110,9 +110,7 @@ def intra_batch_comp( # We want to eliminate the same individual (distance 0) fitness = jnp.where(knn_relevant_indices == current_index, False, fitness) - current_fitness = jnp.squeeze( - eval_scores.at[current_index].get() - ) + current_fitness = jnp.squeeze(eval_scores.at[current_index].get()) # Is the fitness of the other individual higher? # If both are True then we discard the current individual since this individual From 57889d71a8e76544f45623b5df3bb122ee29f811 Mon Sep 17 00:00:00 2001 From: lc1021 Date: Thu, 19 Sep 2024 15:46:12 +0000 Subject: [PATCH 3/6] Move cmaes.py from core to baselines --- qdax/{core => baselines}/cmaes.py | 0 qdax/core/emitters/cma_emitter.py | 2 +- qdax/core/emitters/cma_mega_emitter.py | 2 +- qdax/core/emitters/cma_rnd_emitter.py | 2 +- tests/core_test/cmaes_test.py | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename qdax/{core => baselines}/cmaes.py (100%) diff --git a/qdax/core/cmaes.py b/qdax/baselines/cmaes.py similarity index 100% rename from qdax/core/cmaes.py rename to qdax/baselines/cmaes.py diff --git a/qdax/core/emitters/cma_emitter.py b/qdax/core/emitters/cma_emitter.py index 315dcd9b..e3b476dd 100644 --- a/qdax/core/emitters/cma_emitter.py +++ b/qdax/core/emitters/cma_emitter.py @@ -7,7 +7,7 @@ import jax import jax.numpy as jnp -from qdax.core.cmaes import CMAES, CMAESState +from qdax.baselines.cmaes import CMAES, CMAESState from qdax.core.containers.mapelites_repertoire import ( MapElitesRepertoire, get_cells_indices, diff --git a/qdax/core/emitters/cma_mega_emitter.py b/qdax/core/emitters/cma_mega_emitter.py index c3f87fed..976f528b 100644 --- a/qdax/core/emitters/cma_mega_emitter.py +++ b/qdax/core/emitters/cma_mega_emitter.py @@ -6,7 +6,7 @@ import jax import jax.numpy as jnp -from qdax.core.cmaes import CMAES, CMAESState +from qdax.baselines.cmaes import CMAES, CMAESState from qdax.core.containers.mapelites_repertoire import ( MapElitesRepertoire, get_cells_indices, diff --git a/qdax/core/emitters/cma_rnd_emitter.py b/qdax/core/emitters/cma_rnd_emitter.py index 27e4f0db..0715c437 100644 --- a/qdax/core/emitters/cma_rnd_emitter.py +++ b/qdax/core/emitters/cma_rnd_emitter.py @@ -6,7 +6,7 @@ import jax import jax.numpy as jnp -from qdax.core.cmaes import CMAESState +from qdax.baselines.cmaes import CMAESState from qdax.core.containers.mapelites_repertoire import MapElitesRepertoire from qdax.core.emitters.cma_emitter import CMAEmitter, CMAEmitterState from qdax.custom_types import Descriptor, ExtraScores, Fitness, Genotype, RNGKey diff --git a/tests/core_test/cmaes_test.py b/tests/core_test/cmaes_test.py index 16321fd4..daa7ce9d 100644 --- a/tests/core_test/cmaes_test.py +++ b/tests/core_test/cmaes_test.py @@ -4,7 +4,7 @@ import jax.numpy as jnp import pytest -from qdax.core.cmaes import CMAES +from qdax.baselines.cmaes import CMAES def test_cmaes() -> None: From 32bc57f8c10c31a5784e90e5ef3f58937037038d Mon Sep 17 00:00:00 2001 From: lc1021 Date: Thu, 19 Sep 2024 15:57:55 +0000 Subject: [PATCH 4/6] Change corresponding api docs --- docs/api_documentation/core/cmaes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api_documentation/core/cmaes.md b/docs/api_documentation/core/cmaes.md index 257bb89b..5c85704a 100644 --- a/docs/api_documentation/core/cmaes.md +++ b/docs/api_documentation/core/cmaes.md @@ -1,3 +1,3 @@ # CMAES class -::: qdax.core.cmaes.CMAES +::: qdax.baselines.cmaes.CMAES From db462b701cb1de31fd479625aadf9c4023b610a9 Mon Sep 17 00:00:00 2001 From: lc1021 Date: Thu, 19 Sep 2024 16:01:29 +0000 Subject: [PATCH 5/6] Change categorisation in docs to baselines --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 9207b4f2..b447e83f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -154,11 +154,11 @@ nav: - DADS: api_documentation/core/dads.md - SAC: api_documentation/core/sac.md - TD3: api_documentation/core/td3.md - - CMAES: api_documentation/core/cmaes.md - Genetic Algorithm: api_documentation/core/genetic_algorithm.md - NSGA2: api_documentation/core/nsga2.md - SPEA2: api_documentation/core/spea2.md - PBT: api_documentation/core/pbt.md + - CMAES: api_documentation/core/cmaes.md - Containers: api_documentation/core/containers.md - Emitters: api_documentation/core/emitters.md - Neuroevolution: api_documentation/core/neuroevolution.md From b6912b26f0e19d708fc5eb23bec50d9641683b41 Mon Sep 17 00:00:00 2001 From: lc1021 Date: Thu, 19 Sep 2024 16:01:42 +0000 Subject: [PATCH 6/6] Change ref in example notebook --- examples/cmaes.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/cmaes.ipynb b/examples/cmaes.ipynb index ba059cdc..023b2e27 100644 --- a/examples/cmaes.ipynb +++ b/examples/cmaes.ipynb @@ -55,7 +55,7 @@ "import matplotlib.pyplot as plt\n", "from matplotlib.patches import Ellipse\n", "\n", - "from qdax.core.cmaes import CMAES" + "from qdax.baselines.cmaes import CMAES" ] }, {