|
6 | 6 | import json |
7 | 7 |
|
8 | 8 |
|
9 | | -def acq_max(ac, gp, y_max, bounds, random_state, constraint=None, n_warmup=10000, n_iter=10): |
| 9 | +def acq_max(ac, gp, y_max, bounds, random_state, constraint=None, n_warmup=10000, n_iter=10, y_max_params=None): |
10 | 10 | """ |
11 | 11 | A function to find the maximum of the acquisition function |
12 | 12 |
|
13 | 13 | It uses a combination of random sampling (cheap) and the 'L-BFGS-B' |
14 | 14 | optimization method. First by sampling `n_warmup` (1e5) points at random, |
15 | | - and then running L-BFGS-B from `n_iter` (250) random starting points. |
| 15 | + and then running L-BFGS-B from `n_iter` (10) random starting points. |
16 | 16 |
|
17 | 17 | Parameters |
18 | 18 | ---------- |
@@ -40,6 +40,9 @@ def acq_max(ac, gp, y_max, bounds, random_state, constraint=None, n_warmup=10000 |
40 | 40 | :param n_iter: |
41 | 41 | number of times to run scipy.minimize |
42 | 42 |
|
| 43 | + :param y_max_params: |
| 44 | + Function parameters that produced the maximum known value given by `y_max`. |
| 45 | +
|
43 | 46 | Returns |
44 | 47 | ------- |
45 | 48 | :return: x_max, The arg max of the acquisition function. |
@@ -87,7 +90,15 @@ def adjusted_ac(x): |
87 | 90 |
|
88 | 91 | # Explore the parameter space more thoroughly |
89 | 92 | x_seeds = random_state.uniform(bounds[:, 0], bounds[:, 1], |
90 | | - size=(n_iter, bounds.shape[0])) |
| 93 | + size=(1+n_iter+int(not y_max_params is None), |
| 94 | + bounds.shape[0])) |
| 95 | + # Add the best candidate from the random sampling to the seeds so that the |
| 96 | + # optimization algorithm can try to walk up to that particular local maxima |
| 97 | + x_seeds[0] = x_max |
| 98 | + if not y_max_params is None: |
| 99 | + # Add the provided best sample to the seeds so that the optimization |
| 100 | + # algorithm is aware of it and will attempt to find its local maxima |
| 101 | + x_seeds[1] = y_max_params |
91 | 102 |
|
92 | 103 | for x_try in x_seeds: |
93 | 104 | # Find the minimum of minus the acquisition function |
|
0 commit comments