GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
LikGaussian.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
/*
6
* LikGaussian.cpp
7
*
8
* Created on: 22 Oct 2020
9
* Author: Maxim Masterov
10
* Company: SURFSara
11
*/
12
13
#include "
LikGaussian.h
"
14
15
namespace
gpr
{
16
17
double
LikGaussian::evaluateLogPrior
()
18
{
19
return
0.;
20
}
21
22
void
LikGaussian::evaluateLogPriorGradient
(
FieldMatrixd
& lpg)
23
{
24
lpg.resize(0, 0);
25
}
26
27
Eigen::VectorXd
LikGaussian::evaluateTrainingVariance
(
const
Coord
&
x
)
28
{
29
const
Eigen::Index n =
x
.rows();
30
Eigen::VectorXd variance = Eigen::VectorXd::Constant(n, sigma2);
31
32
// Heteroscedastic tag for virtual (conditioning-only) rows: any
33
// assembly row whose coordinates bitwise-match a registered virtual
34
// geometry gets extra noise on its diagonal. Both sides are pure
35
// copies of the same observation rows, so exact comparison is the
36
// correct identity test and no index bookkeeping survives row
37
// permutation or subset selection incorrectly. The repetitive
38
// layout appends the block id as a trailing column of x; only the
39
// leading coordinate columns participate in the match.
40
// Robust rows: every channel of a geometry whose leave-one-geometry-
41
// out residual exceeded the model's expectation carries the extra
42
// noise its Student-t weight prescribes (see updateRobustRowWeights).
43
const
Eigen::Index n_robust = robust_geometries_.rows();
44
if
(n_robust > 0 && robust_extra_sigma2_.size() == n_robust &&
45
(
x
.cols() == robust_geometries_.cols() ||
46
x
.cols() == robust_geometries_.cols() + 1)) {
47
const
Eigen::Index dr = robust_geometries_.cols();
48
for
(Eigen::Index i = 0; i < n; ++i) {
49
for
(Eigen::Index v = 0; v < n_robust; ++v) {
50
if
(!(robust_extra_sigma2_(v) > 0.0))
continue
;
51
if
((
x
.row(i).head(dr).array() ==
52
robust_geometries_.row(v).array())
53
.all()) {
54
variance(i) += robust_extra_sigma2_(v);
55
break
;
56
}
57
}
58
}
59
}
60
const
Eigen::Index n_virtual = virtual_geometries_.rows();
61
if
(n_virtual == 0 || !(virtual_noise_sigma2_ > 0.0))
return
variance;
62
const
Eigen::Index d = virtual_geometries_.cols();
63
if
(
x
.cols() != d &&
x
.cols() != d + 1)
return
variance;
64
const
bool
has_block_column =
x
.cols() == d + 1;
65
for
(Eigen::Index i = 0; i < n; ++i) {
66
for
(Eigen::Index v = 0; v < n_virtual; ++v) {
67
if
((
x
.row(i).head(d).array() == virtual_geometries_.row(v).array())
68
.all()) {
69
// Derivative-only constraint: the energy row of a
70
// virtual geometry is effectively removed (the raw
71
// energy scale is absorbed by the constant-offset
72
// block, so a prior-mean energy target would build an
73
// artificial wall); the derivative rows carry the soft
74
// pin noise.
75
const
bool
is_energy_row = has_block_column &&
x
(i, d) == 0.0;
76
variance(i) += is_energy_row ? kVirtualEnergyRowNoise
77
: virtual_noise_sigma2_;
78
break
;
79
}
80
}
81
}
82
return
variance;
83
}
84
85
void
LikGaussian::evaluateTrainingCovarianceMatrix
(
const
Coord
&
x
,
86
FieldMatrixd
& C)
87
{
88
C =
evaluateTrainingVariance
(
x
).asDiagonal();
89
}
90
91
}
/* namespace gpr */
x
@ x
Definition
Enums.h:28
LikGaussian.h
gpr::LikGaussian::evaluateLogPrior
double evaluateLogPrior()
Evaluate the log prior of covariance function parameters.
Definition
LikGaussian.cpp:17
gpr::LikGaussian::evaluateTrainingCovarianceMatrix
void evaluateTrainingCovarianceMatrix(const Coord &x, FieldMatrixd &C)
Evaluate training covariance matrix of inputs.
Definition
LikGaussian.cpp:85
gpr::LikGaussian::evaluateTrainingVariance
Eigen::VectorXd evaluateTrainingVariance(const Coord &x)
Noise on each assembly row, including virtual and robust geometry tags.
Definition
LikGaussian.cpp:27
gpr::LikGaussian::evaluateLogPriorGradient
void evaluateLogPriorGradient(FieldMatrixd &lpg)
Evaluate gradient of the log prior with respect to the parameters.
Definition
LikGaussian.cpp:22
gpr
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition
Macros.h:16
gpr::Coord
FieldMatrixd Coord
Definition
Macros.h:35
gpr::FieldMatrixd
Eigen::Matrix< double, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixd
Definition
Macros.h:25
gpr
observation_models
LikGaussian.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf