optimize
run_minimize_with_restarts(objective, gradient, x0, bounds, n_restarts_optimizer=5, method='L-BFGS-B', maxit=100, verb=0, random_state=None)
¶
Runs multiple restarts of the minimize() function and returns the best found result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
objective |
callable
|
The objective function to minimize. |
required |
gradient |
callable
|
The gradient of the objective. |
required |
x0 |
ndarray
|
Initial guess for the optimizer. |
required |
bounds |
list
|
List of (min, max) pairs for each element in x0. |
required |
n_restarts_optimizer |
int
|
Number of random-restart attempts. |
5
|
method |
str
|
Optimization method. Default “L-BFGS-B”. |
'L-BFGS-B'
|
maxit |
int
|
Max iterations. |
100
|
verb |
int
|
Verbosity level. |
0
|
random_state |
int
|
Seed for the random-number generator to ensure reproducibility. |
None
|
Returns:
Name | Type | Description |
---|---|---|
OptimizeResult |
The best optimization result among all restarts. |
Source code in spotpython/utils/optimize.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|