From 4f7b4e9e341f96d074117c9c035eccad8260ac0e Mon Sep 17 00:00:00 2001 From: Bryon Tjanaka <38124174+btjanaka@users.noreply.github.com> Date: Tue, 2 Jul 2024 04:14:28 -0700 Subject: [PATCH] Add nslc_cma_imp to sphere example (#482) ## Description An experimental algorithm that combines a ProximityArchive with local competition with an EvolutionStrategyEmitter. ## Status - [x] I have read the guidelines in [CONTRIBUTING.md](https://github.com/icaros-usc/pyribs/blob/master/CONTRIBUTING.md) - [x] I have formatted my code using `yapf` - [x] I have tested my code by running `pytest` - [x] I have linted my code with `pylint` - [x] I have added a one-line description of my change to the changelog in `HISTORY.md` - [x] This PR is ready to go --- HISTORY.md | 2 +- examples/sphere.py | 36 ++++++++++++++++++++++++++++++++++++ tests/examples.sh | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index c3aa215b7..0002a8616 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -19,7 +19,7 @@ #### Documentation -- Add novelty search with CMA-ES to sphere example ({pr}`478`) +- Add novelty search with CMA-ES to sphere example ({pr}`478`, {pr}`482`) #### Improvements diff --git a/examples/sphere.py b/examples/sphere.py index e2d156ef8..3a4d01447 100644 --- a/examples/sphere.py +++ b/examples/sphere.py @@ -47,6 +47,9 @@ GradientArborescenceEmitter using ImprovementRanker. - `ns_cma`: Novelty Search with CMA-ES; implemented using a ProximityArchive with EvolutionStrategyEmitter. Results are stored in a passive GridArchive. +- `nslc_cma_imp`: EvolutionStrategyEmitter with a ProximityArchive with local + competition turned on. Thus, the archive returns two-stage improvement + information that is fed to the EvolutionStrategyEmitter just like in CMA-ME. The parameters for each algorithm are stored in CONFIG. The parameters reproduce the experiments presented in the paper in which each algorithm is @@ -608,6 +611,8 @@ "archive": { "class": ProximityArchive, "kwargs": { + # Hyperparameters from Density Descent paper: + # https://arxiv.org/abs/2312.11331 "k_neighbors": 15, "novelty_threshold": 0.037 * 512, } @@ -627,6 +632,37 @@ "kwargs": {} } }, + "nslc_cma_imp": { + "dim": 100, + "iters": 5000, + "archive_dims": (100, 100), + "use_result_archive": True, + "is_dqd": False, + "batch_size": 36, + "archive": { + "class": ProximityArchive, + "kwargs": { + "k_neighbors": 15, + # Note: This is untuned. + "novelty_threshold": 0.037 * 100, + "local_competition": True, + } + }, + "emitters": [{ + "class": EvolutionStrategyEmitter, + "kwargs": { + "sigma0": 0.5, + "ranker": "2imp", + "selection_rule": "filter", + "restart_rule": "no_improvement" + }, + "num_emitters": 15 + }], + "scheduler": { + "class": Scheduler, + "kwargs": {} + } + }, } diff --git a/tests/examples.sh b/tests/examples.sh index ef1217c77..9901653d2 100644 --- a/tests/examples.sh +++ b/tests/examples.sh @@ -49,6 +49,7 @@ python examples/sphere.py cma_mega_adam --dim 20 --itrs 10 --outdir "${SPHERE_OU python examples/sphere.py cma_mae --dim 20 --itrs 10 --learning_rate 0.01 --outdir "${SPHERE_OUTPUT}" python examples/sphere.py cma_maega --dim 20 --itrs 10 --learning_rate 0.01 --outdir "${SPHERE_OUTPUT}" python examples/sphere.py ns_cma --dim 20 --itrs 10 --outdir "${SPHERE_OUTPUT}" +python examples/sphere.py nslc_cma_imp --dim 20 --itrs 10 --outdir "${SPHERE_OUTPUT}" # lunar_lander.py install_deps examples/lunar_lander.py