Classes | |
| struct | gpr_fes_config_t |
| Free-energy surrogate configuration (ABI 1.23). More... | |
| struct | gpr_fes_rate_config_t |
| Posterior-sampled Kramers rate configuration (ABI 1.23). More... | |
| struct | gpr_fes_rate_report_t |
| Summary of the accepted posterior rate draws (ABI 1.23). More... | |
Functions | |
| int | gpr_fes_config_init (gpr_fes_config_t *out, size_t out_size) |
| Write the default gpr_fes_config_t (squared exponential, shared length scale) into the first min(out_size, sizeof) bytes of out. | |
| gpr_fes_t | gpr_fes_create (int dimension, const gpr_model_config_t *model_config, const gpr_fes_config_t *fes_config, const double *grad_noise_var, size_t grad_noise_var_len) |
| Create an untrained free-energy surrogate. | |
| void | gpr_fes_destroy (gpr_fes_t fes) |
| Destroy a handle from gpr_fes_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_fes_dimension (gpr_fes_t fes) |
| Collective-variable dimension, or 0 for NULL or a dead handle. | |
| int | gpr_fes_n_observations (gpr_fes_t fes) |
| Number of training points, or 0 before training, for NULL or for a dead handle. | |
| int | gpr_fes_noise_from_weights_checked (const double *weights, size_t weights_len, double reference_variance, double min_relative_weight, double *noise_var_out, size_t noise_var_len, int n_obs) |
| Noise variances from relative sample weights: noise[i] = reference_variance * max(w) / max(w[i], min_relative_weight *
max(w)). The result is unchanged when every weight is scaled by the same factor, and min_relative_weight caps the largest noise at reference_variance / min_relative_weight. | |
| int | gpr_fes_train_checked (gpr_fes_t fes, const double *s, size_t s_len, const double *F, size_t F_len, const double *F_noise_var, size_t F_noise_var_len, const double *grad_F, size_t grad_F_len, const double *grad_noise_var, size_t grad_noise_var_len, const uint8_t *grad_present, size_t grad_present_len, int n_obs, int dimension) |
| Replace the training data and fit the hyperparameters. | |
| int | gpr_fes_predict_batch_checked (gpr_fes_t fes, const double *s_query, size_t s_query_len, double *F_out, size_t F_len, double *grad_F_out, size_t grad_F_len, double *var_F_out, size_t var_F_len, int n_queries, int dimension) |
| Posterior mean of F at each query point, with its gradient and the latent posterior variance of F when requested. | |
| int | gpr_fes_rate_config_init (gpr_fes_rate_config_t *out, size_t out_size) |
| Write the default gpr_fes_rate_config_t into the first min(out_size, sizeof) bytes of out. | |
| int | gpr_fes_rate_path_checked (gpr_fes_t fes, const double *path, size_t path_len, int n_path, int dimension, int reactant_index, int product_index, const double *diffusion, size_t diffusion_len, const gpr_fes_rate_config_t *config, gpr_fes_rate_report_t *report) |
| Overdamped Kramers-Langer rate from path point reactant_index to product_index, with its uncertainty from joint posterior function draws. | |
A gpr_fes_t holds a Gaussian process over a free energy F(s) on a dimension-dimensional collective-variable space. It observes F at points s, each with its own noise variance, and optionally the gradient of F at some of those points. The prior is the squared-exponential kernel of the scaled distance (one length scale, or one per coordinate when ard is set) around a constant mean equal to the arithmetic mean of the observed F. F must be a free energy: a bias potential, or a biased histogram that has not been reweighted, is not one.
Ownership. gpr_fes_create returns a handle that the caller owns until it passes it to gpr_fes_destroy. Every pointer argument is read or written during the call and stays with the caller; the library copies what it keeps, including both configurations. Arrays are row-major, one row per point, and every length counts elements, not bytes.
Single writer. A gpr_fes_t has one writer at a time: gpr_fes_train_checked and gpr_fes_destroy must not overlap any other call on the same handle. A destroyed handle is refused: a second gpr_fes_destroy sets GPR_ERR_INVALID_ARG in gpr_last_status(), and any other call returns GPR_ERR_NULL_HANDLE (the query functions return 0).
Failure. Every function that returns int returns GPR_SUCCESS (0) or a negative status and leaves its outputs unwritten on failure. A train call that fails keeps the previous posterior. GPR_ERR_CHOLESKY means the training covariance does not factor at the fitted hyperparameters; GPR_ERR_OPTIMIZER means hyperparameter inference diverged.
Size-prefixed structures. gpr_fes_config_t, gpr_fes_rate_config_t and gpr_fes_rate_report_t begin with struct_size. An init function writes the first min(out_size, sizeof) bytes of the defaults and sets struct_size to that count; a call reads or writes only the first struct_size bytes, so a caller compiled against an older, shorter structure keeps working when fields are appended. Fields past struct_size take their defaults.
| int gpr_fes_config_init | ( | gpr_fes_config_t * | out, |
| size_t | out_size ) |
Write the default gpr_fes_config_t (squared exponential, shared length scale) into the first min(out_size, sizeof) bytes of out.
| gpr_fes_t gpr_fes_create | ( | int | dimension, |
| const gpr_model_config_t * | model_config, | ||
| const gpr_fes_config_t * | fes_config, | ||
| const double * | grad_noise_var, | ||
| size_t | grad_noise_var_len ) |
Create an untrained free-energy surrogate.
| model_config | Copied; NULL selects gpr_model_config_defaults(). sigma2 and jitter_sigma2 are added to the noise variance of every F observation, in the unit of F squared, and never to a gradient observation; magn_sigma2 > 0 fixes the signal variance and 0 fits it; max_iter, tol_func, tol_sol and report_level (in [0, 255]) drive the SCG fit of the signal variance and length scales, which minimises the negative log marginal likelihood plus a MAP penalty: a half-Cauchy prior on the signal standard deviation, a half-Student-t prior on each length scale over the standard deviation of the points along its coordinates, and a log barrier below a data-set ceiling on a fitted signal variance, the priors and barrier weighted by min(1e-4 + 1e-3 n, 0.5) for n training rows. max_iter 0 keeps the initial values: length scales at the standard deviation of the points along each coordinate (with ard) or the root mean of their variances (without), and the signal variance at the larger of the variance of F and the mean squared gradient component times its squared length scale. optim_alg must be GPR_OPT_SCG. const_sigma2, use_zbl_prior_mean and use_ff_prior_mean must be zero. prior_mu, prior_nu, prior_s2 and the tp_hyperprior fields are not read: the prior mean is the mean of the observed F. |
| fes_config | Copied; NULL selects gpr_fes_config_init(). |
| grad_noise_var | dimension non-negative variances, copied; entry k is added to component k of every observed gradient, in the unit of F squared per unit of coordinate k squared. NULL with length 0 selects (sigma2 + jitter_sigma2) / spread_k^2 at each train, with spread_k the standard deviation of the training points along k, so rescaling a coordinate rescales its gradient noise with it. |
| dimension | Number of collective variables; must be positive. |
| grad_noise_var_len | Length of grad_noise_var in elements. |
| void gpr_fes_destroy | ( | gpr_fes_t | fes | ) |
Destroy a handle from gpr_fes_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_fes_dimension | ( | gpr_fes_t | fes | ) |
Collective-variable dimension, or 0 for NULL or a dead handle.
| int gpr_fes_n_observations | ( | gpr_fes_t | fes | ) |
Number of training points, or 0 before training, for NULL or for a dead handle.
| int gpr_fes_noise_from_weights_checked | ( | const double * | weights, |
| size_t | weights_len, | ||
| double | reference_variance, | ||
| double | min_relative_weight, | ||
| double * | noise_var_out, | ||
| size_t | noise_var_len, | ||
| int | n_obs ) |
Noise variances from relative sample weights: noise[i] = reference_variance * max(w) / max(w[i], min_relative_weight * max(w)). The result is unchanged when every weight is scaled by the same factor, and min_relative_weight caps the largest noise at reference_variance / min_relative_weight.
This is an approximation: it treats the variance of each F estimate as inversely proportional to its weight (a histogram count, an effective sample size or a reweighting factor). It ignores correlation between samples and between neighbouring bins; use estimated variances when the estimator provides them.
| weights | n_obs positive finite weights. |
| reference_variance | Noise variance at the largest weight; positive. |
| min_relative_weight | In (0, 1]. |
| noise_var_out | n_obs variances, written only on success. |
| weights_len | Length of weights in elements. |
| noise_var_len | Length of noise_var_out in elements. |
| n_obs | Number of weights and noise variances. |
| int gpr_fes_predict_batch_checked | ( | gpr_fes_t | fes, |
| const double * | s_query, | ||
| size_t | s_query_len, | ||
| double * | F_out, | ||
| size_t | F_len, | ||
| double * | grad_F_out, | ||
| size_t | grad_F_len, | ||
| double * | var_F_out, | ||
| size_t | var_F_len, | ||
| int | n_queries, | ||
| int | dimension ) |
Posterior mean of F at each query point, with its gradient and the latent posterior variance of F when requested.
| s_query | n_queries x dimension points. |
| F_out | n_queries means. |
| grad_F_out | n_queries x dimension gradients of the mean, or NULL with length 0. |
| var_F_out | n_queries variances of the latent F (no observation noise), or NULL with length 0. |
| fes | Free-energy surrogate handle. |
| s_query_len | Length of s_query in elements. |
| F_len | Length of F_out in elements. |
| grad_F_len | Length of grad_F_out in elements. |
| var_F_len | Length of var_F_out in elements. |
| n_queries | Number of query points. |
| dimension | Number of collective variables; equals the handle dimension. |
| int gpr_fes_rate_config_init | ( | gpr_fes_rate_config_t * | out, |
| size_t | out_size ) |
Write the default gpr_fes_rate_config_t into the first min(out_size, sizeof) bytes of out.
| int gpr_fes_rate_path_checked | ( | gpr_fes_t | fes, |
| const double * | path, | ||
| size_t | path_len, | ||
| int | n_path, | ||
| int | dimension, | ||
| int | reactant_index, | ||
| int | product_index, | ||
| const double * | diffusion, | ||
| size_t | diffusion_len, | ||
| const gpr_fes_rate_config_t * | config, | ||
| gpr_fes_rate_report_t * | report ) |
Overdamped Kramers-Langer rate from path point reactant_index to product_index, with its uncertainty from joint posterior function draws.
The saddle is the stationary point of the posterior mean of F with one negative Hessian eigenvalue. The search starts at the interior path point with the highest mean and takes eigenvector-following Newton steps, uphill along the lowest Hessian mode and downhill along the others, until the gradient meets saddle_tolerance. The saddle must lie within one length scale of the path between reactant and product and not beyond either end.
Each draw samples F and its Hessian at the reactant and at the saddle jointly from the posterior. Its barrier is F(saddle) - F(reactant) and its rate is k = abs(kappa) / (2 pi) sqrt(det H_reactant / abs(det H_saddle)) exp(-beta barrier), with kappa the negative eigenvalue of beta D H_saddle and D = diag(diffusion). A draw counts only when its barrier is positive, H_reactant is positive definite and H_saddle has exactly one negative eigenvalue. Means, sample standard deviations and equal-tailed credible_mass intervals (type-7 quantiles) are over the accepted draws; the barrier interval and covariance therefore include the correlation between F at the two points.
| path | n_path x dimension points, n_path >= 3. |
| diffusion | dimension positive diagonal entries of the diffusion tensor; entry k in the squared unit of coordinate k per time. |
| config | Read up to config->struct_size; required. |
| report | Written up to min(report->struct_size, sizeof) only on success, with struct_size set to that count. |
| fes | Free-energy surrogate handle. |
| path_len | Length of path in elements. |
| n_path | Number of path points; at least three. |
| dimension | Number of collective variables; equals the handle dimension. |
| reactant_index | Zero-based index of the reactant along the path. |
| product_index | Zero-based index of the product along the path. |
| diffusion_len | Length of diffusion in elements. |
| int gpr_fes_train_checked | ( | gpr_fes_t | fes, |
| const double * | s, | ||
| size_t | s_len, | ||
| const double * | F, | ||
| size_t | F_len, | ||
| const double * | F_noise_var, | ||
| size_t | F_noise_var_len, | ||
| const double * | grad_F, | ||
| size_t | grad_F_len, | ||
| const double * | grad_noise_var, | ||
| size_t | grad_noise_var_len, | ||
| const uint8_t * | grad_present, | ||
| size_t | grad_present_len, | ||
| int | n_obs, | ||
| int | dimension ) |
Replace the training data and fit the hyperparameters.
| s | n_obs x dimension collective-variable points. |
| F | n_obs free energies. |
| F_noise_var | n_obs non-negative noise variances of F, or NULL with length 0 for zero. |
| grad_F | n_obs x dimension gradients of F. |
| grad_noise_var | n_obs x dimension non-negative gradient noise variances. |
| grad_present | n_obs flags, 1 where the row's gradient is observed and 0 where it is not; the gradient entries of a 0 row are not read. grad_F, grad_noise_var and grad_present are all NULL with length 0 (values only) or all given. |
| fes | Free-energy surrogate handle. |
| s_len | Length of s in elements. |
| F_len | Length of F in elements. |
| F_noise_var_len | Length of F_noise_var in elements. |
| grad_F_len | Length of grad_F in elements. |
| grad_noise_var_len | Length of grad_noise_var in elements. |
| grad_present_len | Length of grad_present in elements. |
| n_obs | Number of training observations. |
| dimension | Number of collective variables; equals the handle dimension. |