Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jungtaekkim committed Nov 20, 2024
1 parent 9d1afb1 commit c49cd75
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 140 deletions.
33 changes: 3 additions & 30 deletions examples/05_benchmarks/example_benchmarks_ackley_bo_ei.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
#
# author: Jungtaek Kim ([email protected])
# last updated: August 17, 2023
# author: Jungtaek Kim ([email protected])
# last updated: November 20, 2024
#

import numpy as np
import os

from bayeso import bo
from bayeso_benchmarks import Ackley
from bayeso import wrappers
from bayeso.utils import utils_bo
from bayeso.utils import utils_plotting


STR_FUN_TARGET = "ackley"
NUM_DIM = 3

obj_fun = Ackley(NUM_DIM)
obj_fun = Ackley(3)


def fun_target(X):
return obj_fun.output(X)


path_save = None

if path_save is not None and not os.path.isdir(path_save):
os.makedirs(path_save)

num_bo = 5
num_iter = 10
num_init = 5
Expand Down Expand Up @@ -61,20 +51,3 @@ def fun_target(X):
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_vs_iter(
arr_Y,
[STR_FUN_TARGET],
num_init,
True,
path_save=path_save,
str_postfix=STR_FUN_TARGET,
)
utils_plotting.plot_minimum_vs_time(
arr_time,
arr_Y,
[STR_FUN_TARGET],
num_init,
True,
path_save=path_save,
str_postfix=STR_FUN_TARGET,
)
31 changes: 2 additions & 29 deletions examples/05_benchmarks/example_benchmarks_bohachevsky_bo_ei.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
#
# author: Jungtaek Kim ([email protected])
# last updated: August 17, 2023
# author: Jungtaek Kim ([email protected])
# last updated: November 20, 2024
#

import numpy as np
import os

from bayeso import bo
from bayeso_benchmarks import Bohachevsky
import bayeso.wrappers as wrappers
from bayeso.utils import utils_bo
from bayeso.utils import utils_plotting


STR_FUN_TARGET = "bohachevksy"

obj_fun = Bohachevsky()


def fun_target(X):
return obj_fun.output(X)


path_save = None

if path_save is not None and not os.path.isdir(path_save):
os.makedirs(path_save)

num_bo = 5
num_iter = 10
num_init = 5
Expand Down Expand Up @@ -63,21 +54,3 @@ def fun_target(X):
Ys = np.expand_dims(np.squeeze(Ys), axis=0)
times = np.array(list_time)
times = np.expand_dims(times, axis=0)

utils_plotting.plot_minimum_vs_iter(
Ys,
[STR_FUN_TARGET],
num_init,
True,
path_save=path_save,
str_postfix=STR_FUN_TARGET,
)
utils_plotting.plot_minimum_vs_time(
times,
Ys,
[STR_FUN_TARGET],
num_init,
True,
path_save=path_save,
str_postfix=STR_FUN_TARGET,
)
30 changes: 2 additions & 28 deletions examples/05_benchmarks/example_benchmarks_branin_bo_ei.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
#
# author: Jungtaek Kim ([email protected])
# last updated: August 17, 2023
# author: Jungtaek Kim ([email protected])
# last updated: November 20, 2024
#

import numpy as np
import os

from bayeso import bo
from bayeso_benchmarks.two_dim_branin import Branin
from bayeso.wrappers import wrappers_bo_function
from bayeso.utils import utils_bo
from bayeso.utils import utils_plotting


STR_FUN_TARGET = "branin"

obj_fun = Branin()


def fun_target(X):
return obj_fun.output(X)


path_save = None

if path_save is not None and not os.path.isdir(path_save):
os.makedirs(path_save)

num_bo = 5
num_iter = 10
num_init = 5
Expand Down Expand Up @@ -59,20 +50,3 @@ def fun_target(X):
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_vs_iter(
arr_Y,
[STR_FUN_TARGET],
num_init,
True,
path_save=path_save,
str_postfix=STR_FUN_TARGET,
)
utils_plotting.plot_minimum_vs_time(
arr_time,
arr_Y,
[STR_FUN_TARGET],
num_init,
True,
path_save=path_save,
str_postfix=STR_FUN_TARGET,
)
8 changes: 2 additions & 6 deletions examples/05_benchmarks/example_benchmarks_branin_gp.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
#
# author: Jungtaek Kim ([email protected])
# last updated: August 17, 2023
# author: Jungtaek Kim ([email protected])
# last updated: November 20, 2024
#

import numpy as np

from bayeso import bo
from bayeso import acquisition
from bayeso.gp import gp
from bayeso.utils import utils_common
from bayeso.utils import utils_plotting
from bayeso_benchmarks.two_dim_branin import Branin


STR_FUN_TARGET = "branin"

obj_fun = Branin()


Expand Down
21 changes: 2 additions & 19 deletions examples/05_benchmarks/example_benchmarks_branin_ts.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
#
# author: Jungtaek Kim ([email protected])
# last updated: August 17, 2023
# author: Jungtaek Kim ([email protected])
# last updated: November 20, 2024
#

import numpy as np
import os

from bayeso import thompson_sampling as ts
from bayeso_benchmarks import Branin
from bayeso.utils import utils_bo
from bayeso.utils import utils_plotting


STR_FUN_TARGET = "branin"

obj_fun = Branin()


def fun_target(X):
return obj_fun.output(X)


path_save = None

if path_save is not None and not os.path.isdir(path_save):
os.makedirs(path_save)

num_bo = 5
num_init = 1
num_iter = 50
Expand All @@ -49,11 +40,3 @@ def fun_target(X):

arr_Y = np.array(list_Y)
arr_Y = np.expand_dims(np.squeeze(arr_Y), axis=0)
utils_plotting.plot_minimum_vs_iter(
arr_Y,
[STR_FUN_TARGET],
num_init,
True,
path_save=path_save,
str_postfix=STR_FUN_TARGET,
)
30 changes: 2 additions & 28 deletions examples/05_benchmarks/example_benchmarks_hartmann6d_bo_ei.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
#
# author: Jungtaek Kim ([email protected])
# last updated: August 17, 2023
# author: Jungtaek Kim ([email protected])
# last updated: November 20, 2024
#

import numpy as np
import os

from bayeso import bo
from bayeso_benchmarks.six_dim_hartmann6d import Hartmann6D
from bayeso.wrappers import wrappers_bo_function
from bayeso.utils import utils_bo
from bayeso.utils import utils_plotting


STR_FUN_TARGET = "hartmann6d"

obj_fun = Hartmann6D()


def fun_target(X):
return obj_fun.output(X)


path_save = None

if path_save is not None and not os.path.isdir(path_save):
os.makedirs(path_save)

num_bo = 5
num_iter = 10
num_init = 5
Expand Down Expand Up @@ -59,20 +50,3 @@ def fun_target(X):
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_vs_iter(
arr_Y,
[STR_FUN_TARGET],
num_init,
True,
path_save=path_save,
str_postfix=STR_FUN_TARGET,
)
utils_plotting.plot_minimum_vs_time(
arr_time,
arr_Y,
[STR_FUN_TARGET],
num_init,
True,
path_save=path_save,
str_postfix=STR_FUN_TARGET,
)

0 comments on commit c49cd75

Please sign in to comment.