-
Notifications
You must be signed in to change notification settings - Fork 6
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
90deaf0
commit 59edd11
Showing
26 changed files
with
204 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
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,57 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
||
from bayeso_benchmarks.benchmark_base import Function | ||
|
||
|
||
def fun_target(bx, dim_bx): | ||
assert len(bx.shape) == 1 | ||
assert bx.shape[0] == dim_bx | ||
|
||
A = np.array([ | ||
[-32.0, -16.0, 0.0, 16.0, 32.0, -32.0, -16.0, 0.0, 16.0, 32.0, -32.0, -16.0, 0.0, 16.0, 32.0, -32.0, -16.0, 0.0, 16.0, 32.0, -32.0, -16.0, 0.0, 16.0, 32.0], | ||
[-32.0, -32.0, -32.0, -32.0, -32.0, -16.0, -16.0, -16.0, -16.0, -16.0, 0.0, 0.0, 0.0, 0.0, 0.0, 16.0, 16.0, 16.0, 16.0, 16.0, 32.0, 32.0, 32.0, 32.0, 32.0], | ||
]) | ||
y = 0.002 | ||
|
||
for ind in range(0, 25): | ||
cur_y = 1.0 / (ind + 1.0 + (bx[0] - A[0, ind])**6 + (bx[1] - A[1, ind])**6) | ||
y += cur_y | ||
y = y**(-1) | ||
|
||
return y | ||
|
||
|
||
class DeJong5(Function): | ||
def __init__(self): | ||
dim_bx = 2 | ||
bounds = np.array([ | ||
[-65.536, 65.536], | ||
[-65.536, 65.536], | ||
]) | ||
global_minimizers = np.array([ | ||
[-32.10428207, -32.13705826], | ||
[-32.07150588, -32.13705826], | ||
[-32.03872968, -32.13705826], | ||
[-32.00595349, -32.13705826], | ||
[-31.97317729, -32.13705826], | ||
[-31.9404011, -32.13705826], | ||
[-31.90762491, -32.13705826], | ||
[-32.13705826, -32.10428207], | ||
[-32.10428207, -32.10428207], | ||
[-32.07150588, -32.10428207], | ||
[-32.03872968, -32.10428207], | ||
[-32.00595349, -32.10428207], | ||
[-31.97317729, -32.10428207], | ||
[-31.9404011, -32.10428207], | ||
[-31.90762491, -32.10428207], | ||
[-31.87484871, -32.10428207], | ||
]) | ||
global_minimum = 0.9980038753198021 | ||
function = lambda bx: fun_target(bx, dim_bx) | ||
|
||
Function.__init__(self, dim_bx, bounds, global_minimizers, global_minimum, function) |
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,32 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: February 9, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
||
from bayeso_benchmarks.benchmark_base import Function | ||
|
||
|
||
def fun_target(bx, dim_bx): | ||
assert len(bx.shape) == 1 | ||
assert bx.shape[0] == dim_bx | ||
|
||
y = -1.0 * (1 + np.cos(12.0 * np.sqrt(bx[0]**2 + bx[1]**2))) / (0.5 * (bx[0]**2 + bx[1]**2) + 2.0) | ||
return y | ||
|
||
|
||
class DropWave(Function): | ||
def __init__(self): | ||
dim_bx = 2 | ||
bounds = np.array([ | ||
[-5.12, 5.12], | ||
[-5.12, 5.12], | ||
]) | ||
global_minimizers = np.array([ | ||
[0.0, 0.0], | ||
]) | ||
global_minimum = -1.0 | ||
function = lambda bx: fun_target(bx, dim_bx) | ||
|
||
Function.__init__(self, dim_bx, bounds, global_minimizers, global_minimum, function) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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,43 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from bayeso_benchmarks.two_dim_dejong5 import * | ||
|
||
class_fun = DeJong5 | ||
|
||
TEST_EPSILON = 1e-3 | ||
|
||
|
||
def test_init(): | ||
obj_fun = class_fun() | ||
|
||
def test_validate_properties(): | ||
obj_fun = class_fun() | ||
obj_fun.validate_properties() | ||
|
||
def test_output(): | ||
obj_fun = class_fun() | ||
bounds = obj_fun.get_bounds() | ||
|
||
grids = obj_fun.get_grids(3) | ||
truths_grids = np.array([ | ||
[499.99985236], | ||
[499.99917292], | ||
[499.99985236], | ||
[499.99917292], | ||
[12.67050581], | ||
[499.99917292], | ||
[499.99985236], | ||
[499.99917292], | ||
[499.99985236], | ||
]) | ||
|
||
print(grids) | ||
print(obj_fun.output(grids)) | ||
print(np.abs(obj_fun.output(grids) - truths_grids) < TEST_EPSILON) | ||
assert np.all(np.abs(obj_fun.output(grids) - truths_grids) < TEST_EPSILON) |
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,43 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from bayeso_benchmarks.two_dim_dropwave import * | ||
|
||
class_fun = DropWave | ||
|
||
TEST_EPSILON = 1e-3 | ||
|
||
|
||
def test_init(): | ||
obj_fun = class_fun() | ||
|
||
def test_validate_properties(): | ||
obj_fun = class_fun() | ||
obj_fun.validate_properties() | ||
|
||
def test_output(): | ||
obj_fun = class_fun() | ||
bounds = obj_fun.get_bounds() | ||
|
||
grids = obj_fun.get_grids(3) | ||
truths_grids = np.array([ | ||
[-0.05229446], | ||
[-0.07797539], | ||
[-0.05229446], | ||
[-0.07797539], | ||
[-1.0], | ||
[-0.07797539], | ||
[-0.05229446], | ||
[-0.07797539], | ||
[-0.05229446], | ||
]) | ||
|
||
print(grids) | ||
print(obj_fun.output(grids)) | ||
print(np.abs(obj_fun.output(grids) - truths_grids) < TEST_EPSILON) | ||
assert np.all(np.abs(obj_fun.output(grids) - truths_grids) < TEST_EPSILON) |