Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gpCAM.py #1465

Open
wants to merge 1 commit into
base: experimental/jlnav_plus_shuds_asktell
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions libensemble/gen_classes/gpCAM.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def ask_numpy(self, n_trials: int) -> npt.NDArray:
input_set=np.column_stack((self.lb, self.ub)),
n=n_trials,
pop_size=n_trials,
acquisition_function="total correlation",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should prob be passed as option, with sensible default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But also there is "MINIMIZE", "MAXIMIZE" keywords. If we added 'EXPLORE', that would probably be "total correlation".

acquisition_function="expected improvement",
max_iter=self.ask_max_iter, # Larger takes longer. gpCAM default is 20.
)["x"]
print(f"Ask time:{time.time() - start}")
Expand All @@ -85,14 +85,18 @@ def ask_numpy(self, n_trials: int) -> npt.NDArray:
def tell_numpy(self, calc_in: npt.NDArray) -> None:
if calc_in is not None:
if "x" in calc_in.dtype.names: # SH should we require x in?
self.x_new = np.atleast_2d(calc_in["x"])
self.x_new = np.expand_dims(calc_in["x"], 1)
self.y_new = np.atleast_2d(calc_in["f"]).T
nan_indices = [i for i, fval in enumerate(self.y_new) if np.isnan(fval[0])]
self.x_new = np.delete(self.x_new, nan_indices, axis=0)
self.y_new = np.delete(self.y_new, nan_indices, axis=0)

self.all_x = np.vstack((self.all_x, self.x_new))
self.all_y = np.vstack((self.all_y, self.y_new))
if len(self.all_x) == 0 and len(self.all_y) == 0:
self.all_x = self.x_new
self.all_y = self.y_new
else:
self.all_x = np.concat((self.all_x, self.x_new))
self.all_y = np.concat((self.all_y, self.y_new))

noise_var = self.noise * np.ones(len(self.all_y))
if self.my_gp is None:
Expand Down
Loading