Skip to content

Commit bfabfe5

Browse files
0.24.9
1 parent d3c561a commit bfabfe5

11 files changed

Lines changed: 791 additions & 306 deletions

File tree

notebooks/00_spotPython_tests.ipynb

Lines changed: 401 additions & 73 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotpython"
10-
version = "0.24.7"
10+
version = "0.24.9"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotpython/budget/ocba.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ def get_ocba(means, vars, delta, verbose=False) -> array:
4444
Examples:
4545
>>> import copy
4646
import numpy as np
47-
from spotpython.fun.objectivefunctions import analytical
48-
from spotpython.spot import spot
47+
from spotpython.fun import Analytical
48+
from spotpython.spot import Spot
4949
from spotpython.budget.ocba import get_ocba
50+
from spotpython.utils.init import fun_control_init, design_control_init, surrogate_control_init
5051
# Example is based on the example from the book:
5152
# Chun-Hung Chen and Loo Hay Lee:
5253
# Stochastic Simulation Optimization: An Optimal Computer Budget Allocation,
@@ -56,10 +57,8 @@ def get_ocba(means, vars, delta, verbose=False) -> array:
5657
# var_y = np.array([1,1,9,9,4])
5758
# get_ocba(mean_y, var_y, 50)
5859
# [11 9 19 9 2]
59-
fun = analytical().fun_linear
60-
fun_control = {"sigma": 0.001,
61-
"seed": 123}
62-
spot_1_noisy = spot.Spot(fun=fun,
60+
fun = Analytical().fun_linear
61+
fun_control = fun_control_init(
6362
lower = np.array([-1]),
6463
upper = np.array([1]),
6564
fun_evals = 20,
@@ -68,10 +67,14 @@ def get_ocba(means, vars, delta, verbose=False) -> array:
6867
ocba_delta=1,
6968
seed=123,
7069
show_models=False,
70+
sigma=0.001,
71+
)
72+
design_control = design_control_init(init_size=3, repeats=2)
73+
surrogate_control = surrogate_control_init(noise=True)
74+
spot_1_noisy = Spot(fun=fun,
7175
fun_control = fun_control,
72-
design_control={"init_size": 3,
73-
"repeats": 2},
74-
surrogate_control={"noise": True})
76+
design_control=design_control,
77+
surrogate_control=surrogate_control)
7578
spot_1_noisy.run()
7679
spot_2 = copy.deepcopy(spot_1_noisy)
7780
spot_2.mean_y = np.array([1,2,3,4,5])
@@ -81,12 +84,12 @@ def get_ocba(means, vars, delta, verbose=False) -> array:
8184
assert sum(o) == 50
8285
assert (o == np.array([[11, 9, 19, 9, 2]])).all()
8386
o
84-
spotpython tuning: -1.000367786651468 [####------] 45.00%
85-
spotpython tuning: -1.000989121350348 [######----] 60.00%
86-
spotpython tuning: -1.000989121350348 [########--] 75.00%
87-
spotpython tuning: -1.000989121350348 [#########-] 90.00%
88-
spotpython tuning: -1.000989121350348 [##########] 100.00% Done...
89-
array([11, 9, 19, 9, 2])
87+
spotpython tuning: -1.000367786651468 [####------] 45.00%
88+
spotpython tuning: -1.000989121350348 [######----] 60.00%
89+
spotpython tuning: -1.000989121350348 [########--] 75.00%
90+
spotpython tuning: -1.000989121350348 [#########-] 90.00%
91+
spotpython tuning: -1.000989121350348 [##########] 100.00% Done...
92+
array([11, 9, 19, 9, 2])
9093
"""
9194
if np.all(vars > 0) and (means.shape[0] > 2):
9295
n_designs = means.shape[0]

src/spotpython/data/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .diabetes import Diabetes
2+
from .lightdatamodule import LightDataModule
3+
4+
5+
__all__ = ["Diabetes", "LightDataModule"]

src/spotpython/design/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .spacefilling import SpaceFilling
2+
3+
__all__ = ["SpaceFilling"]

0 commit comments

Comments
 (0)