GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
RFFFeatureSelection.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) gpridge developers
3
// See LICENSE for details.
4
5
// A-posteriori choice of the random-feature count. The count is not a
6
// fixed accuracy floor: a uniform bound on this kernel asks for 1e12 to
7
// 1e19 features on the 811-geometry gradient GP (PR 223). The selector
8
// doubles a power-of-two count until the random-feature posterior matches
9
// the exact GP on a deterministic farthest-point subset that fits in the
10
// validation memory cap.
11
12
#ifndef GPR_ML_RFF_FEATURE_SELECTION_H_
13
#define GPR_ML_RFF_FEATURE_SELECTION_H_
14
15
#include <Eigen/Core>
16
#include <cstdint>
17
#include <limits>
18
#include <stdexcept>
19
#include <string>
20
#include <utility>
21
#include <vector>
22
23
namespace
gpr
{
24
26
inline
constexpr
double
kRFFEnergyNoiseFloor
= 1e-6;
28
inline
constexpr
double
kRFFGradientNoiseFloor
= 1e-4;
30
inline
constexpr
double
kRFFForceConvergenceTolerance
= 0.0514221;
32
inline
constexpr
std::uint64_t
kRFFValidationMemoryCapBytes
=
33
256ull * 1024ull * 1024ull;
35
inline
constexpr
int
kRFFFeaturesAuto
= -1;
36
39
struct
RFFValidationPlan
{
40
int
full_geometries
= 0;
41
int
cartesian_dimension
= 0;
42
int
fit_geometries
= 0;
43
int
holdout_geometries
= 0;
44
int
joint_rows
= 0;
45
int
feature_start
= 0;
46
int
feature_limit
= 0;
47
std::int64_t
exact_gram_bytes
= 0;
48
std::int64_t
full_gram_bytes
= 0;
49
std::int64_t
memory_cap_bytes
= 0;
50
bool
deferred
=
false
;
51
bool
admissible
=
false
;
52
};
53
55
struct
RFFFeatureSelection
{
56
bool
accepted
=
false
;
57
bool
deferred
=
false
;
58
int
features
= 0;
59
int
start_features
= 0;
60
int
limit_features
= 0;
61
int
fit_geometries
= 0;
62
int
holdout_geometries
= 0;
63
int
full_geometries
= 0;
64
int
cartesian_dimension
= 0;
65
int
joint_rows
= 0;
66
double
force_tol_fraction
= 0.0;
67
double
force_convergence_tolerance
=
kRFFForceConvergenceTolerance
;
68
double
energy_tolerance
= 0.0;
69
double
force_tolerance
= 0.0;
70
double
energy_noise
= 0.0;
71
double
gradient_noise
= 0.0;
72
double
max_energy_error
= std::numeric_limits<double>::quiet_NaN();
73
double
max_force_error
= std::numeric_limits<double>::quiet_NaN();
74
double
max_energy_oracle_error
= std::numeric_limits<double>::quiet_NaN();
75
double
max_force_oracle_error
= std::numeric_limits<double>::quiet_NaN();
76
double
exact_energy_oracle_error
= std::numeric_limits<double>::quiet_NaN();
77
double
exact_force_oracle_error
= std::numeric_limits<double>::quiet_NaN();
78
std::int64_t
exact_gram_bytes
= 0;
79
std::int64_t
memory_cap_bytes
= 0;
80
std::int64_t
full_gram_bytes
= 0;
81
std::string
status
;
82
std::string
detail
;
83
};
84
87
class
RFFFeatureSelectionError
:
public
std::runtime_error {
88
public
:
89
explicit
RFFFeatureSelectionError
(
RFFFeatureSelection
report
)
90
:
std
::runtime_error(
report
.detail.empty()
91
?
std
::string(
"RFF feature selection failed"
)
92
:
report
.detail),
93
report_(
std
::move(
report
))
94
{
95
}
96
97
[[nodiscard]]
const
RFFFeatureSelection
&
report
() const noexcept
98
{
99
return
report_;
100
}
101
102
private
:
103
RFFFeatureSelection
report_;
104
};
105
112
[[nodiscard]] RFFValidationPlan
planRFFFeatureValidation
(
113
int
n_geometries,
int
cartesian_dimension,
114
std::uint64_t memory_cap_bytes =
kRFFValidationMemoryCapBytes
);
115
118
[[nodiscard]] std::vector<int>
rffFarthestPointOrder
(
119
const
Eigen::MatrixXd& positions);
120
121
[[nodiscard]] std::string
formatRFFFeatureSelection
(
122
const
RFFFeatureSelection& report);
123
124
}
// namespace gpr
125
126
#endif
// GPR_ML_RFF_FEATURE_SELECTION_H_
gpr::RFFFeatureSelectionError::report
const RFFFeatureSelection & report() const noexcept
Definition
RFFFeatureSelection.h:97
gpr::RFFFeatureSelectionError::RFFFeatureSelectionError
RFFFeatureSelectionError(RFFFeatureSelection report)
Definition
RFFFeatureSelection.h:89
gpr
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition
Macros.h:16
gpr::formatRFFFeatureSelection
std::string formatRFFFeatureSelection(const RFFFeatureSelection &report)
Definition
RFFSelection.cpp:273
gpr::planRFFFeatureValidation
RFFValidationPlan planRFFFeatureValidation(int n_geometries, int cartesian_dimension, std::uint64_t memory_cap_bytes)
Definition
RFFSelection.cpp:171
gpr::kRFFValidationMemoryCapBytes
constexpr std::uint64_t kRFFValidationMemoryCapBytes
Exact validation Gram, and the D-by-D normal matrix, stay under this.
Definition
RFFFeatureSelection.h:32
gpr::kRFFForceConvergenceTolerance
constexpr double kRFFForceConvergenceTolerance
Band force tolerance the random-feature error is not allowed to cross.
Definition
RFFFeatureSelection.h:30
gpr::kRFFGradientNoiseFloor
constexpr double kRFFGradientNoiseFloor
Gradient-channel floor used by the production random-feature model.
Definition
RFFFeatureSelection.h:28
gpr::rffFarthestPointOrder
std::vector< int > rffFarthestPointOrder(const Eigen::MatrixXd &positions)
Definition
RFFSelection.cpp:235
gpr::kRFFEnergyNoiseFloor
constexpr double kRFFEnergyNoiseFloor
Energy-channel floor used by the production random-feature model.
Definition
RFFFeatureSelection.h:26
gpr::kRFFFeaturesAuto
constexpr int kRFFFeaturesAuto
Sentinel stored in integer feature-count fields for the automatic rule.
Definition
RFFFeatureSelection.h:35
std
STL namespace.
gpr::RFFFeatureSelection
Measured result of one automatic selection. Unmeasured errors stay NaN.
Definition
RFFFeatureSelection.h:55
gpr::RFFFeatureSelection::full_gram_bytes
std::int64_t full_gram_bytes
Definition
RFFFeatureSelection.h:80
gpr::RFFFeatureSelection::fit_geometries
int fit_geometries
Definition
RFFFeatureSelection.h:61
gpr::RFFFeatureSelection::max_energy_oracle_error
double max_energy_oracle_error
Definition
RFFFeatureSelection.h:74
gpr::RFFFeatureSelection::memory_cap_bytes
std::int64_t memory_cap_bytes
Definition
RFFFeatureSelection.h:79
gpr::RFFFeatureSelection::full_geometries
int full_geometries
Definition
RFFFeatureSelection.h:63
gpr::RFFFeatureSelection::gradient_noise
double gradient_noise
Definition
RFFFeatureSelection.h:71
gpr::RFFFeatureSelection::exact_gram_bytes
std::int64_t exact_gram_bytes
Definition
RFFFeatureSelection.h:78
gpr::RFFFeatureSelection::detail
std::string detail
Definition
RFFFeatureSelection.h:82
gpr::RFFFeatureSelection::status
std::string status
Definition
RFFFeatureSelection.h:81
gpr::RFFFeatureSelection::features
int features
Definition
RFFFeatureSelection.h:58
gpr::RFFFeatureSelection::cartesian_dimension
int cartesian_dimension
Definition
RFFFeatureSelection.h:64
gpr::RFFFeatureSelection::exact_energy_oracle_error
double exact_energy_oracle_error
Definition
RFFFeatureSelection.h:76
gpr::RFFFeatureSelection::energy_noise
double energy_noise
Definition
RFFFeatureSelection.h:70
gpr::RFFFeatureSelection::accepted
bool accepted
Definition
RFFFeatureSelection.h:56
gpr::RFFFeatureSelection::energy_tolerance
double energy_tolerance
Definition
RFFFeatureSelection.h:68
gpr::RFFFeatureSelection::force_convergence_tolerance
double force_convergence_tolerance
Definition
RFFFeatureSelection.h:67
gpr::RFFFeatureSelection::start_features
int start_features
Definition
RFFFeatureSelection.h:59
gpr::RFFFeatureSelection::deferred
bool deferred
Definition
RFFFeatureSelection.h:57
gpr::RFFFeatureSelection::force_tolerance
double force_tolerance
Definition
RFFFeatureSelection.h:69
gpr::RFFFeatureSelection::max_force_oracle_error
double max_force_oracle_error
Definition
RFFFeatureSelection.h:75
gpr::RFFFeatureSelection::max_energy_error
double max_energy_error
Definition
RFFFeatureSelection.h:72
gpr::RFFFeatureSelection::force_tol_fraction
double force_tol_fraction
Definition
RFFFeatureSelection.h:66
gpr::RFFFeatureSelection::max_force_error
double max_force_error
Definition
RFFFeatureSelection.h:73
gpr::RFFFeatureSelection::exact_force_oracle_error
double exact_force_oracle_error
Definition
RFFFeatureSelection.h:77
gpr::RFFFeatureSelection::joint_rows
int joint_rows
Definition
RFFFeatureSelection.h:65
gpr::RFFFeatureSelection::limit_features
int limit_features
Definition
RFFFeatureSelection.h:60
gpr::RFFFeatureSelection::holdout_geometries
int holdout_geometries
Definition
RFFFeatureSelection.h:62
gpr::RFFValidationPlan
Definition
RFFFeatureSelection.h:39
gpr::RFFValidationPlan::admissible
bool admissible
Definition
RFFFeatureSelection.h:51
gpr::RFFValidationPlan::feature_start
int feature_start
Definition
RFFFeatureSelection.h:45
gpr::RFFValidationPlan::exact_gram_bytes
std::int64_t exact_gram_bytes
Definition
RFFFeatureSelection.h:47
gpr::RFFValidationPlan::holdout_geometries
int holdout_geometries
Definition
RFFFeatureSelection.h:43
gpr::RFFValidationPlan::joint_rows
int joint_rows
Definition
RFFFeatureSelection.h:44
gpr::RFFValidationPlan::feature_limit
int feature_limit
Definition
RFFFeatureSelection.h:46
gpr::RFFValidationPlan::full_gram_bytes
std::int64_t full_gram_bytes
Definition
RFFFeatureSelection.h:48
gpr::RFFValidationPlan::full_geometries
int full_geometries
Definition
RFFFeatureSelection.h:40
gpr::RFFValidationPlan::memory_cap_bytes
std::int64_t memory_cap_bytes
Definition
RFFFeatureSelection.h:49
gpr::RFFValidationPlan::fit_geometries
int fit_geometries
Definition
RFFFeatureSelection.h:42
gpr::RFFValidationPlan::cartesian_dimension
int cartesian_dimension
Definition
RFFFeatureSelection.h:41
gpr::RFFValidationPlan::deferred
bool deferred
Definition
RFFFeatureSelection.h:50
gpr
ml
RFFFeatureSelection.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf