Approximate the constraint function using the internal GPR model. Parameters ---------- X : np.ndarray of shape (n_samples, n_features) Parameters for which to estimate the constraint function value. Returns ------- np.ndarray of
(self, X: NDArray[Float])
| 221 | return result.reshape(X_shape[:-1]) |
| 222 | |
| 223 | def approx(self, X: NDArray[Float]) -> NDArray[Float]: |
| 224 | """ |
| 225 | Approximate the constraint function using the internal GPR model. |
| 226 | |
| 227 | Parameters |
| 228 | ---------- |
| 229 | X : np.ndarray of shape (n_samples, n_features) |
| 230 | Parameters for which to estimate the constraint function value. |
| 231 | |
| 232 | Returns |
| 233 | ------- |
| 234 | np.ndarray of shape (n_samples, n_constraints) |
| 235 | Constraint function value estimates. |
| 236 | """ |
| 237 | X_shape = X.shape |
| 238 | X = X.reshape((-1, self._model[0].n_features_in_)) |
| 239 | if len(self._model) == 1: |
| 240 | return self._model[0].predict(X).reshape(X_shape[:-1]) |
| 241 | |
| 242 | result = np.column_stack([gp.predict(X) for gp in self._model]) |
| 243 | return result.reshape(*X_shape[:-1], len(self._lb)) |
| 244 | |
| 245 | def allowed(self, constraint_values: NDArray[Float]) -> NDArray[np.bool_]: |
| 246 | """Check whether `constraint_values` fulfills the specified limits. |