Loading...
Searching...
No Matches
TrustGuard.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5#include "TrustGuard.h"
6
7#include <stdexcept>
8
9namespace gpr {
10namespace neb {
11
13 const std::vector<Eigen::VectorXd>& accepted_positions,
14 const gpr::TrustRadius& trust, double trust_threshold)
15{
16 if (static_cast<int>(accepted_positions.size()) != path.numImages()) {
17 throw std::invalid_argument(
18 "rejectUntrustedStep requires one accepted position per image");
19 }
20
21 int offending = -1;
22 for (int i = 1; i < path.numImages() - 1; ++i) {
23 const double d = trust.distanceToTraining(path.image(i).positions);
24 if (d > trust_threshold) {
25 offending = i;
26 break;
27 }
28 }
29
30 if (offending > 0) {
31 for (int i = 1; i < path.numImages() - 1; ++i) {
32 path.image(i).positions = accepted_positions[i];
33 }
34 }
35 return offending;
36}
37
38} // namespace neb
39} // namespace gpr
Trust radius enforcement for GP surrogate models.
Definition TrustRadius.h:36
double distanceToTraining(const Eigen::VectorXd &x_new) const
Minimum Euclidean distance from x_new to any training point.
NEB path: chain of images between two endpoints.
Definition NEBPath.h:57
int numImages() const
Definition NEBPath.h:338
Image & image(int i)
Access image i.
Definition NEBPath.h:329
The nudged elastic band: path, GP-NEB driver, configuration and result, acquisition,...
int rejectUntrustedStep(NEBPath &path, const std::vector< Eigen::VectorXd > &accepted_positions, const gpr::TrustRadius &trust, double trust_threshold)
Reject a simultaneous inner-loop NEB step outside the GP trust set.
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition Macros.h:16
Eigen::VectorXd positions
Definition NEBPath.h:40