66from scipy .optimize import minimize
77
88
9- def acq_max (ac , gp , y_max , bounds , random_state ):
9+ def acq_max (ac , gp , y_max , bounds , random_state , n_warmup = 100000 , n_iter = 250 ):
1010 """
1111 A function to find the maximum of the acquisition function
1212
1313 It uses a combination of random sampling (cheap) and the 'L-BFGS-B'
14- optimization method. First by sampling 1e5 points at random, and then
15- running L-BFGS-B from 250 random starting points.
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.
1616
1717 Parameters
1818 ----------
@@ -28,6 +28,14 @@ def acq_max(ac, gp, y_max, bounds, random_state):
2828 :param bounds:
2929 The variables bounds to limit the search of the acq max.
3030
31+ :param random_state:
32+ instance of np.RandomState random number generator
33+
34+ :param n_warmup:
35+ number of times to randomly sample the aquisition function
36+
37+ :param n_iter:
38+ number of times to run scipy.minimize
3139
3240 Returns
3341 -------
@@ -36,14 +44,14 @@ def acq_max(ac, gp, y_max, bounds, random_state):
3644
3745 # Warm up with random points
3846 x_tries = random_state .uniform (bounds [:, 0 ], bounds [:, 1 ],
39- size = (100000 , bounds .shape [0 ]))
47+ size = (n_warmup , bounds .shape [0 ]))
4048 ys = ac (x_tries , gp = gp , y_max = y_max )
4149 x_max = x_tries [ys .argmax ()]
4250 max_acq = ys .max ()
4351
4452 # Explore the parameter space more throughly
4553 x_seeds = random_state .uniform (bounds [:, 0 ], bounds [:, 1 ],
46- size = (250 , bounds .shape [0 ]))
54+ size = (n_iter , bounds .shape [0 ]))
4755 for x_try in x_seeds :
4856 # Find the minimum of minus the acquisition function
4957 res = minimize (lambda x : - ac (x .reshape (1 , - 1 ), gp = gp , y_max = y_max ),
0 commit comments