Loading...
Searching...
No Matches
GeodesicProposalTrust.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
6#pragma once
7#include <cmath>
8#include <stdexcept>
9
11
12namespace gpr::quantum {
13// Coordinates share one continuous mass-weighted chart. Restricting every
14// inner evaluation preserves the model's descent trajectory within the
15// native displacement bound; clipping its terminal chord need not do so.
17 ZeroEnergyGeodesicPotential model, std::vector<Eigen::VectorXd> center,
18 double radius)
19{
20 if (center.empty() || !(radius > 0) || !std::isfinite(radius) ||
21 !model.evaluate || !model.searchHessians)
22 throw std::invalid_argument(
23 "A finite positive geodesic proposal domain and model are "
24 "required");
25 const auto d = center.front().size();
26 for (const auto& q: center)
27 if (d <= 0 || q.size() != d || !q.allFinite())
28 throw std::invalid_argument(
29 "Consistent finite geodesic domain centers required");
30 auto check = [center = std::move(center),
31 radius](const std::vector<Eigen::VectorXd>& q) {
32 if (q.size() != center.size())
33 throw std::invalid_argument(
34 "Geodesic proposal domain image count differs");
35 for (std::size_t j = 0; j < q.size(); ++j) {
36 if (q[j].size() != center[j].size() || !q[j].allFinite())
37 throw std::invalid_argument(
38 "Geodesic proposal domain coordinates differ");
39 if ((q[j] - center[j]).norm() > radius * (1 + 1e-12))
40 throw std::domain_error(
41 "Geodesic model trial exceeds the native displacement "
42 "domain");
43 }
44 };
45 auto evaluate = model.evaluate;
46 auto hessians = model.searchHessians;
47 model.evaluate = [check, evaluate](const auto& q) {
48 check(q);
49 return evaluate(q);
50 };
51 model.searchHessians = [check, hessians](const auto& q) {
52 check(q);
53 return hessians(q);
54 };
55 return model;
56}
57} // namespace gpr::quantum
Models for quantum-path (instanton) searches: arc and tail actions, amplitude continuation.
ZeroEnergyGeodesicPotential restrictGeodesicProposal(ZeroEnergyGeodesicPotential model, std::vector< Eigen::VectorXd > center, double radius)
std::function< std::vector< Eigen::MatrixXd >(const std::vector< Eigen::VectorXd > &)> searchHessians
std::function< std::vector< PotentialEvaluation >(const std::vector< Eigen::VectorXd > &)> evaluate