Functions | |
| gpr_sgp_t | gpr_sgp_create (int dimension, int kernel) |
| Create a scalar surrogate with unit length scales, unit signal variance, a noise variance of 1e-8 and a zero mean. | |
| void | gpr_sgp_destroy (gpr_sgp_t sgp) |
| Destroy a handle from gpr_sgp_create. Destroying NULL or a live handle clears gpr_last_status(); a destroyed handle is not touched and sets GPR_ERR_INVALID_ARG. | |
| int | gpr_sgp_n_observations (gpr_sgp_t sgp) |
| Number of observed rows, or 0 for NULL or a dead handle. | |
| int | gpr_sgp_set_kernel (gpr_sgp_t sgp, int kernel) |
| Select the radial shape. The observations and hyperparameters stay; the surrogate needs a new gpr_sgp_fit_checked before a prediction. | |
| int | gpr_sgp_set_mean_basis (gpr_sgp_t sgp, int basis) |
| Select the mean with a gpr_bq_basis_t value: GPR_BQ_BASIS_NONE (zero, the default), GPR_BQ_BASIS_CONSTANT or GPR_BQ_BASIS_AFFINE (1 and every coordinate). The coefficients are fitted by generalized least squares together with the process at each fit. | |
| int | gpr_sgp_set_hyperparameters_checked (gpr_sgp_t sgp, const double *length_scales, size_t length_scales_len, double signal_variance, double noise_variance) |
| Set the hyperparameters. | |
| int | gpr_sgp_get_hyperparameters_checked (gpr_sgp_t sgp, double *length_scales_out, size_t length_scales_len, double *signal_variance_out, double *noise_variance_out) |
| Read the hyperparameters, as set or as the last fit left them. | |
| int | gpr_sgp_observe_checked (gpr_sgp_t sgp, const double *X, size_t X_len, const double *y, size_t y_len, const double *noise_var, size_t noise_var_len, int n_obs, int n_dims) |
| Append observed rows. | |
| int | gpr_sgp_fit_checked (gpr_sgp_t sgp, int optimize, int n_starts, double *log_marginal_likelihood_out) |
| Condition the surrogate on the observed rows. | |
| int | gpr_sgp_predict_checked (gpr_sgp_t sgp, const double *X_queries, size_t X_len, int n_queries, int n_dims, double query_noise_var, double *mean_out, size_t mean_len, double *std_out, size_t std_len) |
| Predict mean and standard deviation at query rows. | |
| gpr_psearch_t | gpr_psearch_create (const double *lower, size_t lower_len, const double *upper, size_t upper_len, const int *axis_kind, size_t axis_kind_len, int dimension, int kernel, int noisy) |
| Create a parameter search over a box. | |
| void | gpr_psearch_destroy (gpr_psearch_t search) |
| Destroy a handle from gpr_psearch_create. Destroying NULL or a live handle clears gpr_last_status(); a destroyed handle is not touched and sets GPR_ERR_INVALID_ARG. | |
| int | gpr_psearch_set_allowed_values_checked (gpr_psearch_t search, int axis, const double *values, size_t values_len, int categorical) |
| Restrict an axis to a list of values, such as the divisors of a core count. The list replaces the bounds and the kind of that axis. | |
| int | gpr_psearch_observe_checked (gpr_psearch_t search, const double *X, size_t X_len, const double *y, size_t y_len, const double *noise_var, size_t noise_var_len, const double *constraint, size_t constraint_len, int n_obs, int n_dims) |
| Report evaluated rows. | |
| int | gpr_psearch_propose_checked (gpr_psearch_t search, int q, double *X_out, size_t X_len, int n_dims, int *n_proposed_out) |
| Propose up to q parameter vectors to evaluate next. | |
| int | gpr_psearch_best_checked (gpr_psearch_t search, double *x_out, size_t x_len, double *loss_out) |
| The incumbent: the feasible evaluated row with the smallest loss, or with the smallest posterior mean for a noisy search. | |
A gpr_sgp_t is a Gaussian process on a dimension-dimensional parameter vector with one scalar output, for an oracle that returns a value and, optionally, the variance of its noise. The kernel is a radial shape of the scaled Euclidean distance with one length scale per coordinate. A gpr_psearch_t minimizes such an oracle over a box by ask and tell: the caller reports evaluated rows and receives the next batch to evaluate.
Kernel. Both handles take a gpr_bq_kernel_t value and accept GPR_BQ_KERNEL_SE, GPR_BQ_KERNEL_MATERN32_ISOTROPIC and GPR_BQ_KERNEL_MATERN52_ISOTROPIC. The product kernels are refused with GPR_ERR_UNSUPPORTED.
Noise. Rows are observed either all with a noise variance each or all without one. Without, every row shares the noise variance hyperparameter. A call that would mix the two returns GPR_ERR_INVALID_ARG.
Ownership. A create call returns a handle that the caller owns until it passes it to the matching destroy call. Every pointer argument is read or written during the call and stays with the caller. Arrays are row-major, one row per point, and every length counts elements.
Single writer. A handle has one writer at a time. A destroyed handle is refused: a second destroy sets GPR_ERR_INVALID_ARG in gpr_last_status(), and any other call returns GPR_ERR_NULL_HANDLE (gpr_sgp_n_observations returns 0).
Failure. Every function that returns int, except gpr_sgp_n_observations, returns GPR_SUCCESS (0) or a negative status, leaves its outputs unwritten on failure and keeps the previous state of the handle. GPR_ERR_CHOLESKY means a covariance did not factor, GPR_ERR_OPTIMIZER that no start of a hyperparameter fit had a finite likelihood, and GPR_ERR_NOT_TRAINED that the call needs observations, a fit or a feasible observation that the handle does not have yet.
| int gpr_psearch_best_checked | ( | gpr_psearch_t | search, |
| double * | x_out, | ||
| size_t | x_len, | ||
| double * | loss_out ) |
The incumbent: the feasible evaluated row with the smallest loss, or with the smallest posterior mean for a noisy search.
| x_out | dimension values. |
| loss_out | Optional; that loss or posterior mean. |
| gpr_psearch_t gpr_psearch_create | ( | const double * | lower, |
| size_t | lower_len, | ||
| const double * | upper, | ||
| size_t | upper_len, | ||
| const int * | axis_kind, | ||
| size_t | axis_kind_len, | ||
| int | dimension, | ||
| int | kernel, | ||
| int | noisy ) |
Create a parameter search over a box.
The search minimizes. Its surrogate is fitted to the standardized losses on the unit cube, and its hyperparameters are refitted by marginal likelihood before each proposal once there are max(2 * dimension + 2, 6) rows.
| lower,upper | Bounds of each axis, dimension values each, with upper > lower. |
| axis_kind | One gpr_psearch_axis_t value per axis, or NULL with length 0 for linear axes. A logarithmic axis needs a positive lower bound. |
| kernel | A gpr_bq_kernel_t value, see the group description. |
| noisy | Nonzero for a noisy loss: the incumbent is then the smallest posterior mean at the evaluated points instead of the smallest observed loss, and an evaluated point may be proposed again. |
| void gpr_psearch_destroy | ( | gpr_psearch_t | search | ) |
Destroy a handle from gpr_psearch_create. Destroying NULL or a live handle clears gpr_last_status(); a destroyed handle is not touched and sets GPR_ERR_INVALID_ARG.
| int gpr_psearch_observe_checked | ( | gpr_psearch_t | search, |
| const double * | X, | ||
| size_t | X_len, | ||
| const double * | y, | ||
| size_t | y_len, | ||
| const double * | noise_var, | ||
| size_t | noise_var_len, | ||
| const double * | constraint, | ||
| size_t | constraint_len, | ||
| int | n_obs, | ||
| int | n_dims ) |
Report evaluated rows.
| X | n_obs x n_dims parameter vectors. A value off the lattice of a discrete axis is moved to the nearest lattice value; a value outside the box is clamped. |
| y | n_obs losses. A row whose run produced no loss holds NaN and needs a positive constraint value. |
| noise_var | n_obs noise variances, or NULL with length 0. |
| constraint | n_obs constraint values, feasible at or below zero, or NULL with length 0. NaN marks a row without one. A caller that knows only the outcome passes -1 for a feasible row and +1 for an infeasible one. The feasibility model is a GP regression on these values, not a classifier, so with such labels the probability it yields is a ranking score. |
| int gpr_psearch_propose_checked | ( | gpr_psearch_t | search, |
| int | q, | ||
| double * | X_out, | ||
| size_t | X_len, | ||
| int | n_dims, | ||
| int * | n_proposed_out ) |
Propose up to q parameter vectors to evaluate next.
Without observations the rows are Halton points. Otherwise they maximize expected improvement, times the probability of feasibility when constraint values were reported, one after the other under the constant liar with the incumbent as the lie.
| q | Positive batch size. |
| X_out | q x n_dims values; the first *n_proposed_out rows are written. |
| n_proposed_out | Receives the number of rows, which is below q when a discrete box has fewer unevaluated points. |
| int gpr_psearch_set_allowed_values_checked | ( | gpr_psearch_t | search, |
| int | axis, | ||
| const double * | values, | ||
| size_t | values_len, | ||
| int | categorical ) |
Restrict an axis to a list of values, such as the divisors of a core count. The list replaces the bounds and the kind of that axis.
| axis | Zero-based axis index. |
| values | Distinct finite values. Their order is the order the surrogate sees unless categorical is set. |
| categorical | Nonzero: the values are unordered labels, compared only for equality. |
| gpr_sgp_t gpr_sgp_create | ( | int | dimension, |
| int | kernel ) |
Create a scalar surrogate with unit length scales, unit signal variance, a noise variance of 1e-8 and a zero mean.
| dimension | Number of coordinates, positive. |
| kernel | A gpr_bq_kernel_t value, see the group description. |
| void gpr_sgp_destroy | ( | gpr_sgp_t | sgp | ) |
Destroy a handle from gpr_sgp_create. Destroying NULL or a live handle clears gpr_last_status(); a destroyed handle is not touched and sets GPR_ERR_INVALID_ARG.
| int gpr_sgp_fit_checked | ( | gpr_sgp_t | sgp, |
| int | optimize, | ||
| int | n_starts, | ||
| double * | log_marginal_likelihood_out ) |
Condition the surrogate on the observed rows.
| optimize | Nonzero: first maximize the log marginal likelihood over the length scales, the signal variance and, when the rows carry no variance of their own, the noise variance, by L-BFGS with an analytic gradient from n_starts starting points. The first start is the current hyperparameters. |
| n_starts | Positive when optimize is nonzero; ignored otherwise. |
| log_marginal_likelihood_out | Optional; receives the log marginal likelihood of the conditioned surrogate. |
| int gpr_sgp_get_hyperparameters_checked | ( | gpr_sgp_t | sgp, |
| double * | length_scales_out, | ||
| size_t | length_scales_len, | ||
| double * | signal_variance_out, | ||
| double * | noise_variance_out ) |
Read the hyperparameters, as set or as the last fit left them.
| length_scales_out | Receives one value per coordinate. |
| length_scales_len | At least the dimension. |
| signal_variance_out | Optional. |
| noise_variance_out | Optional. |
| int gpr_sgp_n_observations | ( | gpr_sgp_t | sgp | ) |
Number of observed rows, or 0 for NULL or a dead handle.
| int gpr_sgp_observe_checked | ( | gpr_sgp_t | sgp, |
| const double * | X, | ||
| size_t | X_len, | ||
| const double * | y, | ||
| size_t | y_len, | ||
| const double * | noise_var, | ||
| size_t | noise_var_len, | ||
| int | n_obs, | ||
| int | n_dims ) |
Append observed rows.
| X | n_obs x n_dims parameter vectors, row-major. |
| y | n_obs values. |
| noise_var | n_obs non-negative noise variances, or NULL with length 0 for rows that share the noise variance hyperparameter. |
| n_dims | Must equal the dimension of the handle. |
| int gpr_sgp_predict_checked | ( | gpr_sgp_t | sgp, |
| const double * | X_queries, | ||
| size_t | X_len, | ||
| int | n_queries, | ||
| int | n_dims, | ||
| double | query_noise_var, | ||
| double * | mean_out, | ||
| size_t | mean_len, | ||
| double * | std_out, | ||
| size_t | std_len ) |
Predict mean and standard deviation at query rows.
| X_queries | n_queries x n_dims parameter vectors. |
| query_noise_var | 0 for the standard deviation of the latent (noise-free) function; a positive value is added to the variance, which gives the spread of a new run with that noise variance. |
| mean_out | n_queries values. |
| std_out | n_queries values, or NULL with length 0. |
| int gpr_sgp_set_hyperparameters_checked | ( | gpr_sgp_t | sgp, |
| const double * | length_scales, | ||
| size_t | length_scales_len, | ||
| double | signal_variance, | ||
| double | noise_variance ) |
Set the hyperparameters.
| length_scales | One positive value per coordinate, or a single value for every coordinate. |
| length_scales_len | 1 or the dimension. |
| signal_variance | Positive prior variance k(x, x). |
| noise_variance | Non-negative shared noise variance. Rows observed with their own variance ignore it. |
| int gpr_sgp_set_kernel | ( | gpr_sgp_t | sgp, |
| int | kernel ) |
Select the radial shape. The observations and hyperparameters stay; the surrogate needs a new gpr_sgp_fit_checked before a prediction.
| int gpr_sgp_set_mean_basis | ( | gpr_sgp_t | sgp, |
| int | basis ) |
Select the mean with a gpr_bq_basis_t value: GPR_BQ_BASIS_NONE (zero, the default), GPR_BQ_BASIS_CONSTANT or GPR_BQ_BASIS_AFFINE (1 and every coordinate). The coefficients are fitted by generalized least squares together with the process at each fit.