Skip to content

Commit

Permalink
Merge pull request CyberAgentAILab#171 from CyberAgentAILab/update-re…
Browse files Browse the repository at this point in the history
…adme

update readme
  • Loading branch information
nomuramasahir0 authored Jan 22, 2024
2 parents bec4841 + 34e45f9 commit f242ced
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 177 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ jobs:
pip install -U pip setuptools
pip install --progress-bar off optuna numpy scipy
pip install --progress-bar off -U .
- run: python examples/quadratic_function.py
- run: python examples/ipop_cmaes.py
- run: python examples/bipop_cmaes.py
- run: python examples/quadratic_2d_function.py
- run: python examples/ipop_cma.py
- run: python examples/bipop_cma.py
- run: python examples/ellipsoid_function.py
- run: python examples/optuna_sampler.py
- run: python examples/ws_cma_es.py
- run: python examples/cmaes_with_margin_binary.py
- run: python examples/cmaes_with_margin_integer.py
- run: python examples/lra_cma.py
- run: python examples/ws_cma.py
- run: python examples/cma_with_margin_binary.py
- run: python examples/cma_with_margin_integer.py
examples-cmawm-without-scipy:
runs-on: ubuntu-latest
steps:
Expand All @@ -47,5 +48,5 @@ jobs:
run: |
pip install -U pip setuptools
pip install --progress-bar off -U .
- run: python examples/cmaes_with_margin_binary.py
- run: python examples/cmaes_with_margin_integer.py
- run: python examples/cma_with_margin_binary.py
- run: python examples/cma_with_margin_integer.py
282 changes: 113 additions & 169 deletions README.md

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions examples/lra_cma.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import numpy as np
from cmaes import CMA


def rastrigin(x):
dim = len(x)
if dim < 2:
raise ValueError("dimension must be greater one")
return 10 * dim + sum(x**2 - 10 * np.cos(2 * np.pi * x))


if __name__ == "__main__":
dim = 40
optimizer = CMA(mean=3 * np.ones(dim), sigma=2.0, seed=10, lr_adapt=True)

for generation in range(50000):
solutions = []
for _ in range(optimizer.population_size):
x = optimizer.ask()
value = rastrigin(x)
if generation % 500 == 0:
print(f"#{generation} {value}")
solutions.append((x, value))
optimizer.tell(solutions)

if optimizer.should_stop():
break
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f242ced

Please sign in to comment.