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

Safe CMA-ES (GECCO 2024) #187

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
3 changes: 2 additions & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install dependencies
run: |
pip install -U pip setuptools
pip install --progress-bar off optuna numpy scipy
pip install --progress-bar off optuna numpy scipy gpytorch torch
pip install --progress-bar off -U .
- run: python examples/quadratic_2d_function.py
- run: python examples/ipop_cma.py
Expand All @@ -34,6 +34,7 @@ jobs:
- run: python examples/ws_cma.py
- run: python examples/cma_with_margin_binary.py
- run: python examples/cma_with_margin_integer.py
- run: python examples/safecma.py
examples-cmawm-without-scipy:
runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install --progress-bar off numpy matplotlib scipy mypy flake8 black
pip install --progress-bar off numpy matplotlib scipy mypy flake8 black gpytorch torch
- run: flake8 . --show-source --statistics
- run: black --check .
- run: mypy cmaes
Expand All @@ -38,7 +38,7 @@ jobs:
architecture: x64
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools numpy scipy hypothesis
python -m pip install --upgrade pip setuptools numpy scipy hypothesis gpytorch torch
pip install --progress-bar off .
- run: python -m unittest
test-numpy2:
Expand All @@ -51,7 +51,7 @@ jobs:
architecture: x64
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools scipy hypothesis
python -m pip install --upgrade pip setuptools scipy hypothesis gpytorch torch
python -m pip install --pre --upgrade numpy
pip install --progress-bar off .
- run: python -m unittest
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,4 @@ Rate Adaptation: Can CMA-ES with Default Population Size Solve Multimodal
and Noisy Problems?, GECCO, 2023.](https://arxiv.org/abs/2304.03473)
* [Nomura and Shibata 2024] [M. Nomura, M. Shibata, cmaes : A Simple yet Practical Python Library for CMA-ES, arXiv:2402.01373, 2024.](https://arxiv.org/abs/2402.01373)
* [Ros and Hansen 2008] [R. Ros, N. Hansen, A Simple Modification in CMA-ES Achieving Linear Time and Space Complexity, PPSN, 2008.](https://hal.inria.fr/inria-00287367/document)
* [Uchida et al. 2024] [K. Uchida, R. Hamano, M. Nomura, S. Saito, S. Shirakawa, CMA-ES for Safe Optimization, GECCO, 2024.](https://arxiv.org/abs/2405.10534)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you provide a brief description and usage for SafeCMA (like LRA-CMA-ES)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be clearer to explicitly state that the current implementation assumes no noise.

5 changes: 5 additions & 0 deletions cmaes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
from ._dxnesic import DXNESIC # NOQA
from ._catcma import CatCMA # NOQA

try:
from ._safe_cma import SafeCMA # NOQA
except ImportError:
pass # Implementation of Safe CMA-ES requires scipy, gpytorch, and torch

Comment on lines +9 to +13
Copy link
Collaborator

@c-bata c-bata Nov 12, 2024

Choose a reason for hiding this comment

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

It seems that the current approach is somewhat tricky, as users may be confused if cmaes.SafeCMA doesn’t exist in certain Python environments.

How about simply removing SafeCMA from __init__.py and renaming cmaes/_safe_cma.py to cmaes/safe_cma.py?

Suggested change
try:
from ._safe_cma import SafeCMA # NOQA
except ImportError:
pass # Implementation of Safe CMA-ES requires scipy, gpytorch, and torch

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the great suggestion! It looks good to me.

@kento031
Could you make this modification if it’s okay?

__version__ = "0.11.1"
Loading