@@ -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 ]
0 commit comments