class gpr::bo::FreeEnergySurrogate¶
Overview¶
#include <gpr/bo/FreeEnergySurrogate.h>
class FreeEnergySurrogate {
public:
// construction
FreeEnergySurrogate(int dimension, const FreeEnergySurrogateConfig& config);
// methods
int dimension() const;
int observationCount() const;
bool trained() const;
const FreeEnergySurrogateConfig& config() const;
void train(const FreeEnergyObservations& observations);
double marginalObjective(const FreeEnergyObservations& observations, const Eigen::VectorXd& log_hyperparameters, Eigen::VectorXd* gradient) const;
double mapObjective(const FreeEnergyObservations& observations, const Eigen::VectorXd& log_hyperparameters, Eigen::VectorXd* gradient) const;
void predict(const Eigen::MatrixXd& queries, Eigen::VectorXd& value, Eigen::MatrixXd* gradient, Eigen::VectorXd* variance) const;
Eigen::MatrixXd meanHessian(const Eigen::VectorXd& point) const;
FreeEnergyPathPosterior pathPosterior(const Eigen::MatrixXd& path) const;
KramersRateSummary pathRate(const Eigen::MatrixXd& path, int reactant, int product, const KramersRateConfig& config) const;
const Eigen::VectorXd& lengthscales() const;
double signalVariance() const;
double priorMean() const;
const Eigen::VectorXd& gradientNoiseVariance() const;
const FreeEnergyFitReport& fitReport() const;
static double priorCovariance(const std::vector<int>& left_axes, const Eigen::VectorXd& x, const std::vector<int>& right_axes, const Eigen::VectorXd& y, const Eigen::VectorXd& lengthscales, double signal_variance);
};
Detailed Documentation¶
Methods¶
void train(const FreeEnergyObservations& observations)
Replace the training data and refit. On an exception the previous posterior is kept.
double marginalObjective(const FreeEnergyObservations& observations, const Eigen::VectorXd& log_hyperparameters, Eigen::VectorXd* gradient) const
Negative log marginal likelihood of observations at log hyperparameters [log signal variance, log length scale…] (one length scale unless ard), with its gradient when requested. Infinite where the covariance does not factor.
double mapObjective(const FreeEnergyObservations& observations, const Eigen::VectorXd& log_hyperparameters, Eigen::VectorXd* gradient) const
The objective train() hands to SCG: marginalObjective plus the MAP penalty of funcmin::applyMapPenalty, weighted by the barrier strength min(1e-4 + 1e-3 n, 0.5) for n training rows. The penalty holds a half-Cauchy prior on the signal standard deviation, a half-Student-t (4 degrees of freedom) prior on each length scale over the standard deviation of the points along its coordinates, and, when the signal variance is fitted, a log barrier below a ceiling set by the data. The gradient covers the fitted parameters only (zero for a fixed signal variance). Infinite outside the barrier or where the covariance does not factor.
void predict(const Eigen::MatrixXd& queries, Eigen::VectorXd& value, Eigen::MatrixXd* gradient, Eigen::VectorXd* variance) const
Posterior mean of F at each query row; optionally its gradient (n x d) and the latent posterior variance of F.
Eigen::MatrixXd meanHessian(const Eigen::VectorXd& point) const
Posterior mean Hessian of F at one point.
KramersRateSummary pathRate(const Eigen::MatrixXd& path, int reactant, int product, const KramersRateConfig& config) const
Overdamped Kramers-Langer rate from reactant to product along path, sampled from the joint posterior of F and its Hessians at the reactant path point and at the saddle of the posterior mean.
The saddle search starts at the interior path point with the highest posterior mean and takes Newton steps on the mean, uphill along the lowest Hessian mode and downhill along the others, each at most half a length scale, for at most 100 steps. It succeeds at a point whose gradient meets config.saddle_tolerance, whose mean Hessian has exactly one negative eigenvalue, and whose nearest point on the path between reactant and product lies within one length scale and is not an end of that stretch; otherwise it throws FreeEnergySaddleNotFoundError. A saddle whose mean F is not above the reactant throws FreeEnergyRateUnsupportedError.
Each draw’s rate is 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(config.diffusion).
const Eigen::VectorXd& gradientNoiseVariance() const
Variance added to each gradient component in the last train, one entry per coordinate; empty when that train observed no gradient.
static double priorCovariance(const std::vector<int>& left_axes, const Eigen::VectorXd& x, const std::vector<int>& right_axes, const Eigen::VectorXd& y, const Eigen::VectorXd& lengthscales, double signal_variance)
Prior covariance between a derivative of F at x and one at y. Each axis list holds zero, one or two coordinate indices: the value, a gradient component or a Hessian entry.