GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
SurrogatePathTrust.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
6
#pragma once
7
#include <algorithm>
8
#include <cmath>
9
#include <stdexcept>
10
11
#include "
gpr/quantum/PotentialPath.h
"
12
13
namespace
gpr::quantum
{
14
// Reflected full gradients repeat each half-ring residual twice. This merit
15
// therefore equals the squared norm of the stacked half-ring residual.
16
inline
double
surrogatePathResidualMerit
(
const
PotentialPathResult
& result)
17
{
18
const
auto
& gradient = result.
fullGradient
;
19
if
(gradient.empty() || gradient.size() % 2 || gradient.front().size() == 0)
20
throw
std::invalid_argument(
21
"Nonempty even reflected residuals required"
);
22
const
auto
dimension = gradient.front().size();
23
double
merit = 0;
24
for
(
const
auto
& value: gradient) {
25
if
(value.size() != dimension || !value.allFinite())
26
throw
std::invalid_argument(
27
"Finite matching reflected residual dimensions required"
);
28
merit += .5 * value.squaredNorm();
29
}
30
if
(!std::isfinite(merit))
31
throw
std::invalid_argument(
"Finite reflected residual merit required"
);
32
return
merit;
33
}
34
35
struct
SurrogatePathTrustDecision
{
36
bool
accepted
{},
agreementDefined
{};
37
double
actualReduction
{},
predictedReduction
{},
agreementRatio
{},
38
nextRadius
{};
39
};
40
41
// Acceptance certifies native merit descent and feasibility. Force tolerances
42
// and stationarity qualification remain properties of the caller's assessment.
43
inline
SurrogatePathTrustDecision
assessSurrogatePathTrust
(
44
double
nativeCurrentMerit,
double
nativeTrialMerit,
45
double
modelCurrentMerit,
double
modelTrialMerit,
double
radius,
46
double
maximumRadius,
bool
boundary,
bool
feasible)
47
{
48
for
(
double
merit: {nativeCurrentMerit, nativeTrialMerit, modelCurrentMerit,
49
modelTrialMerit})
50
if
(!(merit >= 0) || !std::isfinite(merit))
51
throw
std::invalid_argument(
52
"Finite nonnegative trust merits required"
);
53
if
(!(radius > 0) || !std::isfinite(radius) || !(maximumRadius >= radius) ||
54
!std::isfinite(maximumRadius))
55
throw
std::invalid_argument(
56
"Finite positive trust radius within its maximum required"
);
57
SurrogatePathTrustDecision
decision;
58
decision.
actualReduction
= nativeCurrentMerit - nativeTrialMerit;
59
decision.
predictedReduction
= modelCurrentMerit - modelTrialMerit;
60
decision.
accepted
= feasible && decision.
actualReduction
> 0;
61
decision.
agreementDefined
= decision.
predictedReduction
> 0;
62
if
(decision.
agreementDefined
)
63
decision.
agreementRatio
=
64
decision.
actualReduction
/ decision.
predictedReduction
;
65
decision.
nextRadius
= radius;
66
if
(!decision.
accepted
||
67
(decision.
agreementDefined
&& decision.
agreementRatio
< .25))
68
decision.
nextRadius
= .5 * radius;
69
else
if
(decision.
agreementDefined
&& decision.
agreementRatio
> .75 &&
70
boundary)
71
decision.
nextRadius
=
72
radius > maximumRadius / 2 ? maximumRadius : 2 * radius;
73
return
decision;
74
}
75
76
inline
SurrogatePathTrustDecision
assessSurrogatePathTrust
(
77
const
PotentialPathResult
& nativeCurrent,
78
const
PotentialPathResult
& nativeTrial,
79
const
PotentialPathResult
& modelCurrent,
80
const
PotentialPathResult
& modelTrial,
double
radius,
double
maximumRadius,
81
bool
boundary,
bool
feasible)
82
{
83
const
double
nc =
surrogatePathResidualMerit
(nativeCurrent),
84
nt =
surrogatePathResidualMerit
(nativeTrial),
85
mc =
surrogatePathResidualMerit
(modelCurrent),
86
mt =
surrogatePathResidualMerit
(modelTrial);
87
for
(
const
auto
* result: {&nativeTrial, &modelCurrent, &modelTrial})
88
if
(result->fullGradient.size() != nativeCurrent.
fullGradient
.size() ||
89
result->fullGradient.front().size() !=
90
nativeCurrent.
fullGradient
.front().size())
91
throw
std::invalid_argument(
92
"Matching native and model reflected residual shapes required"
);
93
return
assessSurrogatePathTrust
(nc, nt, mc, mt, radius, maximumRadius,
94
boundary, feasible);
95
}
96
}
// namespace gpr::quantum
PotentialPath.h
gpr::quantum
Models for quantum-path (instanton) searches: arc and tail actions, amplitude continuation.
Definition
AffineGaussianArcModel.h:16
gpr::quantum::surrogatePathResidualMerit
double surrogatePathResidualMerit(const PotentialPathResult &result)
Definition
SurrogatePathTrust.h:16
gpr::quantum::assessSurrogatePathTrust
SurrogatePathTrustDecision assessSurrogatePathTrust(double nativeCurrentMerit, double nativeTrialMerit, double modelCurrentMerit, double modelTrialMerit, double radius, double maximumRadius, bool boundary, bool feasible)
Definition
SurrogatePathTrust.h:43
gpr::quantum::PotentialPathResult
Definition
PotentialPath.h:115
gpr::quantum::PotentialPathResult::fullGradient
std::vector< Eigen::VectorXd > fullGradient
Definition
PotentialPath.h:117
gpr::quantum::SurrogatePathTrustDecision
Definition
SurrogatePathTrust.h:35
gpr::quantum::SurrogatePathTrustDecision::nextRadius
double nextRadius
Definition
SurrogatePathTrust.h:38
gpr::quantum::SurrogatePathTrustDecision::agreementRatio
double agreementRatio
Definition
SurrogatePathTrust.h:37
gpr::quantum::SurrogatePathTrustDecision::predictedReduction
double predictedReduction
Definition
SurrogatePathTrust.h:37
gpr::quantum::SurrogatePathTrustDecision::accepted
bool accepted
Definition
SurrogatePathTrust.h:36
gpr::quantum::SurrogatePathTrustDecision::actualReduction
double actualReduction
Definition
SurrogatePathTrust.h:37
gpr::quantum::SurrogatePathTrustDecision::agreementDefined
bool agreementDefined
Definition
SurrogatePathTrust.h:36
gpr
quantum
SurrogatePathTrust.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf