Skip to content

Commit

Permalink
Merge pull request #465 from janosh/gh-464
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep authored Sep 20, 2022
2 parents 8bb265e + 21ef4e5 commit 43619d4
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions maml/apps/bowsr/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,10 @@ def min_obj(x):
# Minimize objective is the negative acquisition function
return -acquisition(x.reshape(-1, dim), gpr=gpr, y_max=y_max, noise=noise)

x0 = x_max.reshape(-1, dim)
# make sure that the initial conditions fall into the bounds
x0 = np.clip(x0, bounds[:, 0] + 3 * EPS, bounds[:, 1] - 3 * EPS)

try:
res = minimize(min_obj, x0=x0, bounds=bounds, method="L-BFGS-B")
except IndexError:
# For some reason, scipy sometimes result in a shape error for x0.
# Here, we just simply initialize based on x_max without clipping.
res = minimize(min_obj, x0=x_max.reshape(-1, dim), bounds=bounds, method="L-BFGS-B")
x0 = np.clip(x_max, bounds[:, 0] + 3 * EPS, bounds[:, 1] - 3 * EPS)

res = minimize(min_obj, x0=x0, bounds=bounds, method="L-BFGS-B")
if -float(res.fun) >= acq_max:
x_max = res.x
return _trunc(scaler.inverse_transform(x_max), decimals=3)
Expand Down

0 comments on commit 43619d4

Please sign in to comment.