Skip to content

Commit 83a9bbe

Browse files
renesassDifan DengeddiebergmanCarolin Benjaminstimruhkopf
authored
Version 1.4.0 (#730, #855, #869, #872)
## Features * [BOinG](https://arxiv.org/abs/2111.05834): A two-stage Bayesian optimization approach to allow the optimizer to focus on the most promising regions. * [TurBO](https://arxiv.org/abs/1910.01739): Reimplementaion of TurBO-1 algorithm. * Updated pSMAC: Can pass arbitrary SMAC facades now. Added example and fixed tests. ## Improvements * Enabled caching for multi-objectives (#872). Costs are now normalized in `get_cost` or optionally in `average_cost`/`sum_cost`/`min_cost` to receive a single float value. Therefore, the cached cost values do not need to be updated everytime a new entry to the runhistory was added. ## Interface changes * We changed the location of Gaussian processes and random forests. They are in the folders `epm/gaussian_process` and `epm/random_forest` now. * Also, we restructured the optimizer folder and therefore the location of the acquisition functions and configuration chooser. * Multi-objective functions are located in the folder `multi_objective`. * pSMAC facade was moved to the facade directory. Co-authored-by: Difan Deng <deng@dengster.tnt.uni-hannover.de> Co-authored-by: Eddie Bergman <eddiebergmanhs@gmail.com> Co-authored-by: Carolin Benjamins <benjamins@tnt.uni-hannover.de> Co-authored-by: timruhkopf <timruhkopf@gmail.com>
1 parent 99d1129 commit 83a9bbe

111 files changed

Lines changed: 7815 additions & 894 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
- name: Install dependencies
3737
run: |
38-
pip install ".[dev]"
38+
pip install ".[gpytorch,dev]"
3939
4040
- name: Make docs
4141
run: |

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ on:
2323
env:
2424
package-name: smac
2525
test-dir: tests
26-
extra-requires: "[dev]"
26+
extra-requires: "[gpytorch,dev]"
2727

2828
# Arguments used for pytest
2929
pytest-args: >-

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,6 @@ dmypy.json
137137

138138
# macOS files
139139
.DS_Store
140+
141+
# Remove docker files
142+
docker

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ efficiently decide which of two configurations performs better.
1515
SMAC3 is written in Python3 and continuously tested with Python 3.7, 3.8, 3.9, and 3.10. Its Random
1616
Forest is written in C++. In further texts, SMAC is representatively mentioned for SMAC3.
1717

18-
[Documention](https://automl.github.io/SMAC3)
18+
> [Documention](https://automl.github.io/SMAC3)
19+
20+
> [Roadmap](https://github.com/orgs/automl/projects/5/views/2)
1921
2022

2123
## Installation

changelog.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
# 1.4.0
2+
3+
## Features
4+
* [BOinG](https://arxiv.org/abs/2111.05834): A two-stage Bayesian optimization approach to allow the
5+
optimizer to focus on the most promising regions.
6+
* [TurBO](https://arxiv.org/abs/1910.01739): Reimplementaion of TurBO-1 algorithm.
7+
* Updated pSMAC: Can pass arbitrary SMAC facades now. Added example and fixed tests.
8+
9+
## Improvements
10+
* Enabled caching for multi-objectives (#872). Costs are now normalized in `get_cost`
11+
or optionally in `average_cost`/`sum_cost`/`min_cost` to receive a single float value. Therefore,
12+
the cached cost values do not need to be updated everytime a new entry to the runhistory was added.
13+
14+
## Interface changes
15+
* We changed the location of Gaussian processes and random forests. They are in the folders
16+
`epm/gaussian_process` and `epm/random_forest` now.
17+
* Also, we restructured the optimizer folder and therefore the location of the acquisition functions
18+
and configuration chooser.
19+
* Multi-objective functions are located in the folder `multi_objective`.
20+
* pSMAC facade was moved to the facade directory.
21+
22+
123
# 1.3.4
224
* Added reference to JMLR paper.
325
* Typos in documentations.

docs/details/parallelism.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Parallelism
22
===========
33

44
SMAC also provides a parallel mode to use several parallel computational resources (such as CPU cores).
5-
This variant of SMAC is called pSMAC (parallel SMAC).
5+
This variant of SMAC is called pSMAC (parallel SMAC) [1]_.
66
The general idea is that all target algorithm run evaluations are shared between the individual SMAC runs
77
such that all SMAC runs are better informed and can work together.
88

@@ -19,6 +19,12 @@ such that all SMAC runs are better informed and can work together.
1919
SMAC also supports DASH. The documentation is in progress.
2020

2121

22+
.. [1] Ramage, S. E. A. (2015). Advances in meta-algorithmic software libraries for
23+
distributed automated algorithm configuration (T). University of British
24+
Columbia. Retrieved from
25+
https://open.library.ubc.ca/collections/ubctheses/24/items/1.0167184.
26+
27+
2228
Commandline
2329
~~~~~~~~~~~
2430
To use pSMAC via the commandline interface, please specify the following two arguments:

examples/python/plot_scalarized_multi_objective.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import logging
1111

12-
from smac.optimizer.multi_objective.parego import ParEGO
12+
from smac.multi_objective.parego import ParEGO
1313

1414
logging.basicConfig(level=logging.INFO)
1515

examples/python/plot_simple_multi_objective.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ def plot(all_x):
2727
plt.figure()
2828
for x in all_x:
2929
f1, f2 = schaffer(x)
30-
plt.scatter(f1, f2, c="blue", alpha=0.1)
30+
plt.scatter(f1, f2, c="blue", alpha=0.1, zorder=3000)
31+
32+
plt.vlines([1], 0, 4, linestyles="dashed", colors=["red"])
33+
plt.hlines([1], 0, 4, linestyles="dashed", colors=["red"])
3134

3235
plt.show()
3336

examples/python/plot_svm_eips.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
from sklearn.model_selection import cross_val_score
2222

2323
from smac.configspace import ConfigurationSpace
24-
from smac.epm.uncorrelated_mo_rf_with_instances import (
25-
UncorrelatedMultiObjectiveRandomForestWithInstances,
26-
)
24+
from smac.epm.random_forest.rf_mo import MultiObjectiveRandomForest
2725
from smac.facade.smac_ac_facade import SMAC4AC
2826

2927
# EIPS related
@@ -104,7 +102,7 @@ def svm_from_cfg(cfg):
104102
model_kwargs = {"target_names": ["loss", "time"], "model_kwargs": {"seed": 1}}
105103
smac = SMAC4AC(
106104
scenario=scenario,
107-
model=UncorrelatedMultiObjectiveRandomForestWithInstances,
105+
model=MultiObjectiveRandomForest,
108106
rng=np.random.RandomState(42),
109107
model_kwargs=model_kwargs,
110108
tae_runner=svm_from_cfg,
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""
2+
Synthetic Function with BOinG as optimizer
3+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
5+
An example of applying SMAC with BO inside Grove (BOinG) to optimize a
6+
synthetic function (2d rosenbrock function).
7+
8+
BOinG optimizer requires a SMAC4BOING wrapper to optimize the target algorithm. It is a two stage BO algorithm.
9+
In the first stage, BOinG constructs an RF to capture the global loss landscape. Then in the second stage, it only
10+
optimizes inside a subregion near the candidate suggested by the RF model with a GP model to focus only on the most
11+
promising region.
12+
"""
13+
14+
import logging
15+
16+
import numpy as np
17+
from ConfigSpace import ConfigurationSpace
18+
from ConfigSpace.hyperparameters import UniformFloatHyperparameter
19+
20+
from smac.facade.smac_boing_facade import SMAC4BOING
21+
22+
# Import SMAC-utilities
23+
from smac.scenario.scenario import Scenario
24+
25+
26+
def rosenbrock_2d(x):
27+
"""The 2 dimensional Rosenbrock function as a toy model
28+
The Rosenbrock function is well know in the optimization community and
29+
often serves as a toy problem. It can be defined for arbitrary
30+
dimensions. The minimium is always at x_i = 1 with a function value of
31+
zero. All input parameters are continuous. The search domain for
32+
all x's is the interval [-5, 10].
33+
"""
34+
x1 = x["x0"]
35+
x2 = x["x1"]
36+
37+
val = 100.0 * (x2 - x1**2.0) ** 2.0 + (1 - x1) ** 2.0
38+
return val
39+
40+
41+
if __name__ == "__main__":
42+
logging.basicConfig(level=logging.INFO) # logging.DEBUG for debug output
43+
44+
# Build Configuration Space which defines all parameters and their ranges
45+
cs = ConfigurationSpace()
46+
x0 = UniformFloatHyperparameter("x0", -5, 10, default_value=-3)
47+
x1 = UniformFloatHyperparameter("x1", -5, 10, default_value=-4)
48+
cs.add_hyperparameters([x0, x1])
49+
# Scenario object
50+
scenario = Scenario(
51+
{
52+
"run_obj": "quality", # we optimize quality (alternatively runtime)
53+
"runcount-limit": 20,
54+
# max. number of function evaluations; for this example set to a low number
55+
"cs": cs, # configuration space
56+
"deterministic": "true",
57+
}
58+
)
59+
60+
# Example call of the function
61+
# It returns: Status, Cost, Runtime, Additional Infos
62+
def_value = rosenbrock_2d(cs.get_default_configuration())
63+
print("Default Value: %.2f" % def_value)
64+
65+
# Optimize, using a SMAC-object
66+
print("Optimizing! Depending on your machine, this might take a few minutes.")
67+
68+
smac = SMAC4BOING(
69+
scenario=scenario,
70+
rng=np.random.RandomState(42),
71+
tae_runner=rosenbrock_2d,
72+
)
73+
74+
smac.optimize()

0 commit comments

Comments
 (0)