Skip to content

Commit

Permalink
Merge dev (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbussemaker authored Jun 20, 2024
2 parents 51594a6 + db5ee37 commit 08915b3
Show file tree
Hide file tree
Showing 18 changed files with 547 additions and 280 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ jobs:
python -m pip install --upgrade pip setuptools
pip install -r requirements-tests.txt
pip install -r requirements-assignment.txt
pip install -r requirements-hebo.txt
pip install -e .[arch_sbo,botorch,trieste,tpe,rocket,egor]
- name: Test with pytest
run: pytest sb_arch_opt --durations=0
run: pytest -v sb_arch_opt --durations=10
2 changes: 1 addition & 1 deletion .github/workflows/tests_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
run: echo "${{ steps.license_check_report.outputs.report }}"

- name: Test with pytest
run: pytest sb_arch_opt --durations=0
run: pytest -v sb_arch_opt --durations=10
3 changes: 1 addition & 2 deletions .github/workflows/tests_slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
python -m pip install --upgrade pip setuptools
pip install -r requirements-tests.txt
pip install -r requirements-assignment.txt
pip install -r requirements-hebo.txt
pip install -r requirements-ota.txt
pip install -e .[arch_sbo,botorch,trieste,tpe,rocket,egor]
pip install jupyter ipython ipykernel
Expand All @@ -54,4 +53,4 @@ jobs:
run: echo "${{ steps.license_check_report.outputs.report }}"

- name: Test with pytest
run: RUN_SLOW_TESTS=1 pytest sb_arch_opt --durations=0
run: RUN_SLOW_TESTS=1 pytest -v sb_arch_opt --durations=20
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![SBArchOpt Logo](https://github.com/jbussemaker/SBArchOpt/blob/main/docs/logo.svg)

# SBArchOpt: Surrogate-Based Architecture Optimization

[![Tests](https://github.com/jbussemaker/SBArchOpt/workflows/Tests/badge.svg)](https://github.com/jbussemaker/SBArchOpt/actions/workflows/tests.yml?query=workflow%3ATests)
Expand Down
2 changes: 1 addition & 1 deletion docs/algo/hebo.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Artificial Intelligence Research, 74, pp.1269-1349, DOI: [10.1613/jair.1.13643](
## Installation

```
pip install -r requirements-hebo.txt
pip install sb-arch-opt[hebo]
```

## Usage
Expand Down
Binary file added docs/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![SBArchOpt Logo](logo.svg)

# SBArchOpt: Surrogate-Based Architecture Optimization

SBArchOpt (es-bee-ARK-opt) provides a set of classes and interfaces for applying Surrogate-Based Optimization (SBO)
Expand Down Expand Up @@ -25,6 +27,23 @@ The library provides:
- Connectors to various external SBO libraries
- Analytical and realistic test problems that exhibit one or more of the architecture optimization challenges

## Installation

First, create a conda environment (skip if you already have one):
```
conda create --name opt python=3.9
conda activate opt
```

Then install the package:
```
conda install numpy
pip install sb-arch-opt
```

Note: there are optional dependencies for the connected optimization frameworks and test problems.
Refer to their documentation for dedicated installation instructions.

## Citing

If you use SBArchOpt in your work, please cite it:
Expand Down
75 changes: 75 additions & 0 deletions docs/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions docs/overrides/partials/copyright.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="md-copyright">
<p><img src="{{ 'logo.svg' | url }}" alt="logo" style="height: 50px" /></p>
{% if config.copyright %}
<div class="md-copyright__highlight">
{{ config.copyright }}
</div>
{% endif %}
</div>
3 changes: 3 additions & 0 deletions docs/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:root {
--md-primary-fg-color: #330a5e;
}
645 changes: 388 additions & 257 deletions docs/tutorial.ipynb

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@ site_name: SBArchOpt
site_url: https://sbarchopt.readthedocs.io/
repo_url: https://github.com/jbussemaker/SBArchOpt
docs_dir: docs
copyright: © 2024, Deutsches Zentrum für Luft- und Raumfahrt e.V.
theme:
name: material
logo: icon.png
favicon: icon.png
palette:
scheme: default
primary: custom
features:
- navigation.tabs
custom_dir: docs/overrides
extra_css:
- style.css

nav:
- 'Overview': index.md
Expand Down
1 change: 0 additions & 1 deletion requirements-hebo.txt

This file was deleted.

2 changes: 1 addition & 1 deletion sb_arch_opt/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.5.1'
__version__ = '1.5.2'
18 changes: 13 additions & 5 deletions sb_arch_opt/algo/pymoo_interface/storage_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ def initialize_cumulative(self, cumulative_pop: Population):
self._cumulative_pop = cumulative_pop
self.n_eval = len(self._get_idx_evaluated(cumulative_pop))

@property
def cumulative_pop(self) -> Optional[Population]:
return self._cumulative_pop

def eval(self, problem, pop: Population, skip_already_evaluated: bool = None, evaluate_values_of: list = None,
count_evals: bool = True, **kwargs):

Expand Down Expand Up @@ -249,6 +253,7 @@ def eval_post(self, problem, pop, advance_n_eval=True, evaluate_values_of: list
self._apply_extreme_barrier(pop, evaluate_values_of=evaluate_values_of)

# Post-evaluation storage
self._update_cumulative_pop(pop)
if self.results_folder is not None:
self._store_intermediate(problem, pop)
self._non_eval_cumulative_pop = None
Expand Down Expand Up @@ -304,6 +309,7 @@ def eval_batch_post(self, problem, pop: Population, batch_pop: Population, evalu
self._apply_extreme_barrier(batch_pop, evaluate_values_of=evaluate_values_of)
intermediate_pop = self._normalize_pop(pop, evaluate_values_of, evaluated_pop=self._evaluated_pop)

self._update_cumulative_pop(intermediate_pop)
if self.results_folder is not None:
self._store_intermediate(problem, intermediate_pop)
return intermediate_pop
Expand Down Expand Up @@ -348,16 +354,18 @@ def _normalize_pop(pop: Population, evaluate_values_of, evaluated_pop: Populatio
normalized_pop = Population.merge(evaluated_pop, normalized_pop)
return normalized_pop

def _store_intermediate(self, problem, pop: Population):
# Store pymoo population
self.store_pop(pop)

# Store cumulative pymoo population
def _update_cumulative_pop(self, pop: Population):
if self._non_eval_cumulative_pop is not None:
unique_non_eval_pop = LargeDuplicateElimination().do(self._non_eval_cumulative_pop, pop, to_itself=False)
self._cumulative_pop = Population.merge(unique_non_eval_pop, pop)
else:
self._cumulative_pop = pop

def _store_intermediate(self, problem, pop: Population):
# Store pymoo population
self.store_pop(pop)

# Store cumulative pymoo population
self.store_pop(self._cumulative_pop, cumulative=True)

# Store problem-specific results
Expand Down
6 changes: 3 additions & 3 deletions sb_arch_opt/tests/algo/test_hebo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def check_dependency():
return pytest.mark.skipif(not HAS_HEBO, reason='HEBO dependencies not installed')


@pytest.mark.skipif(int(os.getenv('RUN_SLOW_TESTS', 0)) != 1, reason='Set RUN_SLOW_TESTS=1 to run slow tests')
def test_slow_tests():
assert HAS_HEBO
# @pytest.mark.skipif(int(os.getenv('RUN_SLOW_TESTS', 0)) != 1, reason='Set RUN_SLOW_TESTS=1 to run slow tests')
# def test_slow_tests():
# assert HAS_HEBO


@check_dependency()
Expand Down
21 changes: 18 additions & 3 deletions sb_arch_opt/tests/test_tutorials.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
import os
import pytest
import testbook
from testbook.client import TestbookNotebookClient

_docs_path = f'{os.path.dirname(__file__)}/../../docs'
_t = 60*20


@pytest.mark.skipif(int(os.getenv('RUN_SLOW_TESTS', 0)) != 1, reason='Set RUN_SLOW_TESTS=1 to run slow tests')
@testbook.testbook(f'{_docs_path}/tutorial.ipynb', execute=True, timeout=_t)
def test_tutorial(tb):
pass
@testbook.testbook(f'{_docs_path}/tutorial.ipynb', execute=False, timeout=_t)
def test_tutorial(tb: TestbookNotebookClient):
code_cells = []
for cell in tb.cells:
if cell.cell_type == 'code':
code_cells.append(cell)

# Set less infills to reduce testing time
sbo_example_cell = code_cells[1]
code = sbo_example_cell.source.split('\n')
for i, line in enumerate(code):
if line.startswith('n_infill'):
code[i] = 'n_infill = 2'
break
sbo_example_cell.source = '\n'.join(code)

tb.execute()


@pytest.mark.skipif(int(os.getenv('RUN_SLOW_TESTS', 0)) != 1, reason='Set RUN_SLOW_TESTS=1 to run slow tests')
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _get_readme():
],
license='MIT',
install_requires=[
'numpy',
'numpy<2.0',
'pymoo~=0.6.1',
'scipy',
'deprecated',
Expand Down Expand Up @@ -85,9 +85,9 @@ def _get_readme():
'tpe': [
'tpe==0.0.8',
],
# 'hebo': [ # pip install -r requirements-hebo.txt
# 'HEBO', # Disabled until commit f050865fd2f554b5ca94642667257b365c753f29 has been released on PyPI
# ],
'hebo': [
'HEBO',
],
'rocket': [
'ambiance',
],
Expand Down

0 comments on commit 08915b3

Please sign in to comment.