@@ -366,8 +366,9 @@ <h4>Use case №1: Find global minimium of an objective/cost function</h4>
366366from scipy.optimize import rosen
367367
368368result = sambo.minimize(
369- rosen, bounds=[(-2, 2)]*2, method='shgo',
370- constraints=lambda x: sum(x**2) <= 2**len(x))
369+ rosen, bounds=[(-2., 2.)] * 2, # Mind the dots
370+ constraints=lambda x: sum(x**2) <= 2**len(x),
371+ max_iter=50, method='shgo')
371372
372373plot_convergence(result)
373374plot_objective(result) # Partial dependence
@@ -427,17 +428,21 @@ <h4>Use case №2: Sequential surrogate model-based "Ask-and-Tell" optimization<
427428 ... # Abstract long and laborious process
428429 return rosen(x)
429430
431+ bounds = [(-2., 2.)] * 4 # 4D
430432optimizer = Optimizer(
431- fun=None, # Implies ask-and-tell interface
432- bounds=[(-2, 2)]*2 ,
433+ fun=None, # Implies Ask-And-Tell interface
434+ bounds=bounds ,
433435 estimator='gp', # or bring your own
434436)
435437
436- for i in range(100):
438+ n_iter = 50
439+ for i in range(n_iter):
437440 suggested_x = optimizer.ask(1)
438441 y = [evaluate(x) for x in suggested_x]
439442 optimizer.tell(y)
440443
444+ best_x, best_fvals = optimizer.top_k()
445+ # Continue the optimization ...
441446result: OptimizeResult = optimizer.run()
442447</ code > </ pre >
443448 < div class ="snippet snippet-plot " data-plot ="- SMBO estimators ">
0 commit comments