class gpr::neb::LocalCartesianGP¶
Overview¶
Squared-exponential Gaussian process with partial gradients. More…
#include <gpr/neb/LocalGP.h>
class LocalCartesianGP {
public:
// structs
struct Observation;
// construction
LocalCartesianGP(Eigen::Index input_dim, std::vector<Eigen::Index> gradient_dofs);
// methods
Eigen::Index inputDim() const;
Eigen::Index gradientDim() const;
const std::vector<Eigen::Index>& gradientDofs() const;
int size() const;
void setNoise(double energy_sigma, double gradient_sigma);
void setWindow(int max_observations);
void setLengthScaleBounds(double lower, double upper);
void setHyperparameters(double signal_variance, double length_scale);
void setHyperparametersFromData(double factor);
bool add(const Eigen::VectorXd& x, double energy, const Eigen::VectorXd& local_gradient, double duplicate_distance = 1e-7);
double fit(int max_iterations, const std::function<bool()>& stop_requested = {});
void condition();
bool ready() const;
void predict(const Eigen::VectorXd& x, double& energy, Eigen::VectorXd& local_gradient) const;
double energyVariance(const Eigen::VectorXd& x) const;
double signalVariance() const;
double lengthScale() const;
double mean() const;
double negativeLogMarginalLikelihood() const;
double objective(const Eigen::Vector2d& theta, Eigen::Vector2d& gradient) const;
};
Detailed Documentation¶
Squared-exponential Gaussian process with partial gradients.
The input is the full Cartesian vector of a band image, so two images that differ only in their substrate are distinct inputs and the data stay consistent. Every observation supplies the energy and the gradient on a fixed subset of coordinates, the atoms that carry the band’s motion, so an observation adds one row per local coordinate plus one. The kernel is isotropic with one length scale, the mean is the highest retained energy, and the noise is fixed per channel. The factorisation grows by appended rows between window evictions.
Methods¶
void setNoise(double energy_sigma, double gradient_sigma)
Standard deviation of the energy and gradient channels.
void setWindow(int max_observations)
Retain at most this many observations; the oldest quarter leaves together once the window overflows.
void setLengthScaleBounds(double lower, double upper)
Admissible length scale range in input units.
void setHyperparameters(double signal_variance, double length_scale)
Seed hyperparameters before the first fit.
void setHyperparametersFromData(double factor)
Length scale from the median nearest-neighbour spacing of the retained inputs times factor, and the signal variance from the spread of the retained energies.
bool add(const Eigen::VectorXd& x, double energy, const Eigen::VectorXd& local_gradient, double duplicate_distance = 1e-7)
Append an observation.
x is the full input and local_gradient the gradient on the gradient coordinates. An input within duplicate_distance of a retained observation replaces that observation. Nonfinite values are rejected and the model is unchanged.
double fit(int max_iterations, const std::function<bool()>& stop_requested = {})
Maximise the marginal likelihood over (signal variance, length scale) with at most max_iterations quasi-Newton iterations, then condition. Returns the negative log marginal likelihood.
void condition()
Condition the posterior on the retained observations with the current hyperparameters, appending rows when the retained set only grew since the last conditioning.
void predict(const Eigen::VectorXd& x, double& energy, Eigen::VectorXd& local_gradient) const
Posterior mean energy and gradient on the gradient coordinates.
double energyVariance(const Eigen::VectorXd& x) const
Posterior energy variance at x.
double negativeLogMarginalLikelihood() const
Negative log marginal likelihood at the current hyperparameters.
double objective(const Eigen::Vector2d& theta, Eigen::Vector2d& gradient) const
Negative log marginal likelihood and its gradient with respect to (log signal variance, log length scale).