Trust radius enforcement for GP surrogate models. More...
#include <gpr/ml/TrustRadius.h>
Public Member Functions | |
| TrustRadius ()=default | |
| void | setTrainingData (const EigenMatrix &R_train) |
| Store training positions for distance queries. | |
| void | setAtomsConfiguration (const AtomsConfiguration &atoms_config) |
| Store atomic metadata for permutation-aware distance metrics. | |
| void | setDistanceMetric (DistanceMetricType metric) |
| Select the atomic distance metric for trust checks. | |
| double | distanceToTraining (const Eigen::VectorXd &x_new) const |
| Minimum Euclidean distance from x_new to any training point. | |
| bool | isWithinTrust (const Eigen::VectorXd &x_new, double radius) const |
| Check whether x_new is within the trust radius of training data. | |
| bool | projectLineToTrustBoundary (const Eigen::VectorXd &x_current, const Eigen::VectorXd &x_trial, double radius, Eigen::VectorXd &x_projected) const |
| Project a trial point along a line segment to the trust boundary. | |
| double | certifiedLineStep (const Eigen::VectorXd &x_from, const Eigen::VectorXd &x_to, double radius) const |
| Largest certified fraction of the segment x_from -> x_to that stays within the trust radius, without bisection. | |
| std::vector< int > | kNearestIndices (const Eigen::VectorXd &x_new, int k) const |
| Indices of the k training points nearest to x_new. | |
| int | nTraining () const |
Trust radius enforcement for GP surrogate models.
Stores training data positions and provides distance queries and displacement clipping relative to a trust radius boundary.
Definition at line 36 of file TrustRadius.h.
|
default |
| double gpr::TrustRadius::certifiedLineStep | ( | const Eigen::VectorXd & | x_from, |
| const Eigen::VectorXd & | x_to, | ||
| double | radius ) const |
Largest certified fraction of the segment x_from -> x_to that stays within the trust radius, without bisection.
Along x(t) = x_from + t * (x_to - x_from), the configured distance metric is Lipschitz in t: d(x(t)) <= d(x_from) + t * L(step), where L(step) is the EMD rate: the maximum over atom types T of the mean displacement norm within T (per-atom triangle inequality, grouped by type exactly as dist_emd) for the EMD metric, or ||step||_2 for the plain Euclidean fallback. Solving d(x(t*)) <= radius for the worst case gives t* = clamp((radius - d(x_from)) / L(step), 0, 1), which is a conservative (never unsafe) certificate: the true boundary may sit further along the segment, since a specific training-row assignment can only move less than the worst-case bound.
The certificate only bounds an INCREASE in distance along the segment: when x_from itself is already outside radius, t* evaluates to 0 rather than certifying any recovery. Callers must check distanceToTraining(x_from) <= radius themselves if they need that distinction.
Returns 0.0 for RMSD/MAX_1D_LOG (no such rate is established for those metrics), for non-finite radius/distances, or for mismatched x_from/x_to sizes.
Definition at line 169 of file TrustRadius.cpp.
| double gpr::TrustRadius::distanceToTraining | ( | const Eigen::VectorXd & | x_new | ) | const |
Minimum Euclidean distance from x_new to any training point.
| x_new | Query point |
Definition at line 33 of file TrustRadius.cpp.
| bool gpr::TrustRadius::isWithinTrust | ( | const Eigen::VectorXd & | x_new, |
| double | radius ) const |
Check whether x_new is within the trust radius of training data.
| x_new | Query point |
| radius | Trust radius threshold |
Definition at line 197 of file TrustRadius.cpp.
| std::vector< int > gpr::TrustRadius::kNearestIndices | ( | const Eigen::VectorXd & | x_new, |
| int | k ) const |
Indices of the k training points nearest to x_new.
Ranks every stored training row by the configured distance metric (EMD/RMSD/MAX_1D_LOG with an AtomsConfiguration, or the Euclidean vector norm otherwise) and returns the indices of the k smallest, sorted ascending so the result is a stable set. The result has min(k, nTraining()) entries; it is empty when there is no training data.
| x_new | Query point |
| k | Neighbourhood size |
Definition at line 77 of file TrustRadius.cpp.
|
inline |
Definition at line 145 of file TrustRadius.h.
| bool gpr::TrustRadius::projectLineToTrustBoundary | ( | const Eigen::VectorXd & | x_current, |
| const Eigen::VectorXd & | x_trial, | ||
| double | radius, | ||
| Eigen::VectorXd & | x_projected ) const |
Project a trial point along a line segment to the trust boundary.
The configured distance metric defines the metric ball. If x_trial is outside radius and x_current is inside radius, this returns the largest point on the line segment x_current + alpha * (x_trial - x_current), alpha in [0,1], that remains inside the trust set. For the EMD metric (and the plain Euclidean fallback with no atomic metric configured) alpha is the closed-form certifiedLineStep bound, evaluated once. For RMSD/MAX_1D_LOG, where that Lipschitz certificate is not established, this falls back to mantissa-width bisection.
x_projected was moved to a boundary point; false when no projection was needed or no trusted anchor exists. Definition at line 203 of file TrustRadius.cpp.
| void gpr::TrustRadius::setAtomsConfiguration | ( | const AtomsConfiguration & | atoms_config | ) |
Store atomic metadata for permutation-aware distance metrics.
Definition at line 21 of file TrustRadius.cpp.
| void gpr::TrustRadius::setDistanceMetric | ( | DistanceMetricType | metric | ) |
Select the atomic distance metric for trust checks.
Calling this switches distanceToTraining away from Euclidean vector norm.
Definition at line 27 of file TrustRadius.cpp.
| void gpr::TrustRadius::setTrainingData | ( | const EigenMatrix & | R_train | ) |
Store training positions for distance queries.
| R_train | Matrix of training positions (n_samples x dim). Each row is one training point. |
Definition at line 16 of file TrustRadius.cpp.