Skip to content

Commit

Permalink
Merge pull request #122 from Helmholtz-AI-Energy/maintenance/enhanced…
Browse files Browse the repository at this point in the history
…_tests

Maintenance/enhanced tests
  • Loading branch information
oskar-taubert authored May 2, 2024
2 parents ae82527 + 30b8bc6 commit 075f384
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 260 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
coverage xml
genbadge coverage -i coverage.xml -o coverage.svg
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v16
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
with:
files: coverage.svg
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,20 @@ next generation using the fitness values of all candidates it evaluated and rece
It was already successfully applied in several accepted scientific publications. Applications include grid load
forecasting, remote sensing, and structural molecular biology:

> D. Coquelin, R. Sedona, M. Riedel, and M. Götz. **Evolutionary Optimization of Neural Architectures in Remote Sensing
> Classification Problems**. IEEE International Geoscience and Remote Sensing Symposium IGARSS, Brussels, Belgium,
> pp. 1587-1590 (2021). https://doi.org/10.1109/IGARSS47720.2021.9554309
> O. Taubert, F. von der Lehr, A. Bazarova, et al. **RNA contact prediction by data efficient deep learning**. Commun
> Biol 6, 913 (2023). https://doi.org/10.1038/s42003-023-05244-9
> D. Coquelin, K. Flügel, M. Weiel, et al. **Harnessing Orthogonality to Train Low-Rank Neural Networks**. arXiv
> preprint (2023). https://doi.org/10.48550/arXiv.2401.08505
> Y. Funk, M. Götz, & H. Anzt. **Prediction of optimal solvers for sparse linear systems using deep learning**.
> Proceedings of the 2022 SIAM Conference on Parallel Processing for Scientific Computing (pp. 14-24). Society for
> Industrial and Applied Mathematics (2022). https://doi.org/10.1137/1.9781611977141.2
> D. Coquelin, R. Sedona, M. Riedel, and M. Götz. **Evolutionary Optimization of Neural Architectures in Remote Sensing
> Classification Problems**. IEEE International Geoscience and Remote Sensing Symposium IGARSS, Brussels, Belgium,
> pp. 1587-1590 (2021). https://doi.org/10.1109/IGARSS47720.2021.9554309
## In more technical terms

``Propulate`` is a massively parallel evolutionary hyperparameter optimizer based on the island model with asynchronous
Expand Down
2 changes: 1 addition & 1 deletion coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 4 additions & 6 deletions propulate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# -*- coding: utf-8 -*-
from pkg_resources import DistributionNotFound, get_distribution
from importlib.metadata import PackageNotFoundError, version

try:
# Change here if project is renamed and does not equal the package name
dist_name = __name__
__version__ = get_distribution(dist_name).version
except DistributionNotFound:
__version__ = version(__name__)
except PackageNotFoundError:
__version__ = "unknown"
finally:
del get_distribution, DistributionNotFound
del version, PackageNotFoundError

from . import propagators
from .islands import Islands
Expand Down
40 changes: 10 additions & 30 deletions tests/test_cmaes.py
Original file line number Diff line number Diff line change
@@ -1,56 +1,36 @@
import pathlib
import random
from typing import Tuple

import pytest

from propulate import Propulator
from propulate.propagators import BasicCMA, CMAPropagator
from propulate.propagators import ActiveCMA, BasicCMA, CMAPropagator
from propulate.utils.benchmark_functions import get_function_search_space


@pytest.fixture(
params=[
("rosenbrock", 0.0),
("step", -25.0),
("quartic", 0.0),
("rastrigin", 0.0),
("griewank", 0.0),
("schwefel", 0.0),
("bisphere", 0.0),
("birastrigin", 0.0),
("bukin", 0.0),
("eggcrate", -1.0),
("himmelblau", 0.0),
("keane", 0.6736675),
("leon", 0.0),
("sphere", 0.0), # (fname, expected)
]
)
def function_parameters(request):
"""Define benchmark function parameter sets as used in tests."""
@pytest.fixture(params=[BasicCMA(), ActiveCMA()])
def cma_adapter(request):
"""Iterate over CMA adapters (basic and active)."""
return request.param


def test_cmaes(
function_parameters: Tuple[str, float], mpi_tmp_path: pathlib.Path
) -> None:
def test_cmaes_basic(cma_adapter, mpi_tmp_path: pathlib.Path) -> None:
"""
Test Propulator to optimize a benchmark function using a CMA-ES propagator.
Test Propulator to optimize a benchmark function using CMA-ES propagators.
This test is run both sequentially and in parallel.
Parameters
----------
function_parameters : Tuple[str, float]
The tuple containing each function name along with its global minimum.
cma_adapter : CMAAdapter
The CMA adapter used, either basic or active.
mpi_tmp_path : pathlib.Path
The temporary checkpoint directory.
"""
rng = random.Random(42) # Separate random number generator for optimization.
function, limits = get_function_search_space(function_parameters[0])
function, limits = get_function_search_space("sphere")
# Set up evolutionary operator.
adapter = BasicCMA()
adapter = cma_adapter
propagator = CMAPropagator(adapter, limits, rng=rng)

# Set up Propulator performing actual optimization.
Expand Down
Loading

0 comments on commit 075f384

Please sign in to comment.