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
23namespace gpr {
24
26inline constexpr double kRFFEnergyNoiseFloor = 1e-6;
28inline constexpr double kRFFGradientNoiseFloor = 1e-4;
30inline constexpr double kRFFForceConvergenceTolerance = 0.0514221;
32inline constexpr std::uint64_t kRFFValidationMemoryCapBytes =
33 256ull * 1024ull * 1024ull;
35inline constexpr int kRFFFeaturesAuto = -1;
36
44 int joint_rows = 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
56 bool accepted = false;
57 bool deferred = false;
58 int features = 0;
65 int joint_rows = 0;
66 double force_tol_fraction = 0.0;
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
87class RFFFeatureSelectionError : public std::runtime_error {
88public:
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
102private:
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_
const RFFFeatureSelection & report() const noexcept
RFFFeatureSelectionError(RFFFeatureSelection report)
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition Macros.h:16
std::string formatRFFFeatureSelection(const RFFFeatureSelection &report)
RFFValidationPlan planRFFFeatureValidation(int n_geometries, int cartesian_dimension, std::uint64_t memory_cap_bytes)
constexpr std::uint64_t kRFFValidationMemoryCapBytes
Exact validation Gram, and the D-by-D normal matrix, stay under this.
constexpr double kRFFForceConvergenceTolerance
Band force tolerance the random-feature error is not allowed to cross.
constexpr double kRFFGradientNoiseFloor
Gradient-channel floor used by the production random-feature model.
std::vector< int > rffFarthestPointOrder(const Eigen::MatrixXd &positions)
constexpr double kRFFEnergyNoiseFloor
Energy-channel floor used by the production random-feature model.
constexpr int kRFFFeaturesAuto
Sentinel stored in integer feature-count fields for the automatic rule.
STL namespace.
Measured result of one automatic selection. Unmeasured errors stay NaN.