-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7992b32
commit 6646026
Showing
2 changed files
with
78 additions
and
0 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
53 changes: 53 additions & 0 deletions
53
examples/benchmarks/example_benchmarks_sixhumpcamel_bo_ei.py
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,53 @@ | ||
# example_benchmarks_sixhumpcamel_ei | ||
# author: Jungtaek Kim (jtkim@postech.ac.kr) | ||
# last updated: October 04, 2018 | ||
|
||
import numpy as np | ||
import os | ||
|
||
from bayeso import bo | ||
from bayeso import benchmarks | ||
from bayeso.utils import utils_bo | ||
from bayeso.utils import utils_plotting | ||
from bayeso.utils import utils_benchmarks | ||
|
||
INFO_TARGET = benchmarks.INFO_SIXHUMPCAMEL | ||
STR_FUN_TARGET = 'sixhumpcamel' | ||
PATH_SAVE = '../figures/benchmarks/' | ||
|
||
|
||
def fun_target(X): | ||
return benchmarks.sixhumpcamel(X) | ||
|
||
def main(): | ||
int_bo = 5 | ||
int_iter = 50 | ||
int_init = 3 | ||
|
||
int_dim = 2 | ||
|
||
bounds = utils_benchmarks.get_bounds(INFO_TARGET, int_dim) | ||
model_bo = bo.BO(bounds, debug=True) | ||
list_Y = [] | ||
list_time = [] | ||
for ind_bo in range(0, int_bo): | ||
print('BO Iteration', ind_bo) | ||
X_final, Y_final, time_final = utils_bo.optimize_many_with_random_init(model_bo, fun_target, int_init, int_iter, str_initial_method_bo='uniform', str_initial_method_ao='uniform', int_samples_ao=100) | ||
print(X_final) | ||
print(Y_final) | ||
print(time_final) | ||
list_Y.append(Y_final) | ||
list_time.append(time_final) | ||
|
||
arr_Y = np.array(list_Y) | ||
arr_Y = np.expand_dims(np.squeeze(arr_Y), axis=0) | ||
arr_time = np.array(list_time) | ||
arr_time = np.expand_dims(arr_time, axis=0) | ||
utils_plotting.plot_minimum(arr_Y, [STR_FUN_TARGET], int_init, True, path_save=PATH_SAVE, str_postfix=STR_FUN_TARGET) | ||
utils_plotting.plot_minimum_time(arr_time, arr_Y, [STR_FUN_TARGET], int_init, True, path_save=PATH_SAVE, str_postfix=STR_FUN_TARGET) | ||
|
||
if __name__ == '__main__': | ||
if not os.path.isdir(PATH_SAVE): | ||
os.makedirs(PATH_SAVE) | ||
main() | ||
|