-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script to run the HEBO algorithm on a BBOB function.
The change from huawei-noah/HEBO#61 (comment) is integrated here.
- Loading branch information
Dimitri Rusin
committed
Nov 16, 2023
1 parent
137c938
commit ecd59e6
Showing
6 changed files
with
106 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ worksapce/ | |
|
||
# catboost | ||
catboost_info/ | ||
|
||
.conda_environment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env fish | ||
|
||
true | ||
and conda activate base | ||
and rm -rf ./.conda_environment | ||
and conda env create --prefix ./.conda_environment --file conda.yaml | ||
and conda activate ./.conda_environment | ||
and pip install --default-timeout=300 -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
channels: | ||
- defaults | ||
dependencies: | ||
- pip=23.3 | ||
- python=3.9.18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# -*- coding: utf-8 -*- | ||
"""HEBO_on_BBOB.ipynb | ||
Automatically generated by Colaboratory. | ||
Original file is located at | ||
https://colab.research.google.com/drive/1XftMKU7-tWj0cdWjH7XsfiDPBIKXAWZk | ||
""" | ||
|
||
import hebo | ||
import ioh | ||
import numpy | ||
|
||
ioh_logger = ioh.logger.Analyzer( | ||
[ioh.logger.trigger.ALWAYS], | ||
additional_properties = [ | ||
# ioh.logger.property.EVALUATIONS, | ||
# ioh.logger.property.RAWY, | ||
ioh.logger.property.RAWYBEST, | ||
ioh.logger.property.TRANSFORMEDY, | ||
ioh.logger.property.TRANSFORMEDYBEST, | ||
# ioh.logger.property.CURRENTBESTY, | ||
# ioh.logger.property.CURRENTY, | ||
# ioh.logger.property.PENALTY, | ||
# ioh.logger.property.VIOLATION, | ||
], | ||
algorithm_name = "HEBO", | ||
folder_name = "HEBO", | ||
root = "HEBO_on_BBOB", | ||
) | ||
|
||
# WARNING: The initial states of the tool to generate random numbers are NOT fixed within these parameters. | ||
BBOB_SEARCH_SPACE_LOWER_BOUND = -5 | ||
BBOB_SEARCH_SPACE_UPPER_BOUND = 5 | ||
num_variables_list = [60] | ||
fids = [1] | ||
instances = [0] | ||
num_runs = 10 | ||
run_budget = 80 | ||
total_num_runs = num_runs * len(instances) * len(fids) * len(num_variables_list) | ||
run_index = 0 | ||
for fid in fids: | ||
for instance in instances: | ||
for num_variables in num_variables_list: | ||
for run_index in range(num_runs): | ||
bbob_problem = ioh.get_problem( | ||
fid = fid, | ||
instance = instance, | ||
dimension = num_variables, | ||
) | ||
bbob_problem.attach_logger(ioh_logger) | ||
|
||
hebo_space = hebo.design_space.design_space.DesignSpace().parse([ | ||
{ | ||
'name': f'x{variable_index}', | ||
'type': 'num', | ||
'lb': BBOB_SEARCH_SPACE_LOWER_BOUND, | ||
'ub': BBOB_SEARCH_SPACE_UPPER_BOUND, | ||
} | ||
for variable_index in range(num_variables) | ||
]) | ||
|
||
hebo_optimizer = hebo.optimizers.hebo.HEBO(hebo_space) | ||
for i in range(run_budget): | ||
recommendations_DataFrame = hebo_optimizer.suggest(n_suggestions = 1) | ||
recommendations_list = recommendations_DataFrame.iloc[0].tolist() | ||
recommendation = numpy.array([bbob_problem(recommendations_list)]) | ||
hebo_optimizer.observe(recommendations_DataFrame, recommendation) | ||
|
||
run_index += 1 | ||
print(f"Done: {run_index}/{total_num_runs:,}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
numpy>=1.16,<1.25 | ||
pandas>=1.0.1 | ||
torch>=1.9.0 | ||
pymoo>=0.6.0 | ||
scikit-learn>=0.22 | ||
gpytorch>=1.4.0 | ||
GPy>=1.9.9 | ||
catboost>=0.24.4 | ||
xgboost | ||
lightgbm | ||
disjoint-set | ||
disjoint-set==0.7.4 | ||
gpytorch==1.11 | ||
ioh==0.3.12 | ||
jupyter==1.0.0 | ||
pandas==2.1.3 | ||
pymoo==0.6.0.1 | ||
scikit-learn==1.3.2 | ||
torch==2.1.1 |