Skip to content
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

@shuds13 shuds13 Dec 3, 2024

Choose a reason for hiding this comment

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

For uncertainty reduction, the default "variance" simply finds N best points, but they may be close to each other. "total correlation" is more expensive but points found are self-avoiding, which is what we usually want.

But also there is "MINIMIZE", "MAXIMIZE" keywords, that I guess we need to incorporate.

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