-
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. With a configuration file whose access mode is changed.
- Loading branch information
Dimitri Rusin
committed
Nov 20, 2023
1 parent
137c938
commit 307418e
Showing
5 changed files
with
98 additions
and
9 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:,}") |