Loading...
Searching...
No Matches
GPLineIntegralNEB.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
6#pragma once
7#include <algorithm>
8#include <limits>
9#include <map>
10#include <sstream>
11#include <utility>
12
13#include "LineIntegralNEB.h"
14#include "LineIntegralString.h"
17#include "gpr/neb/NEBPath.h"
18
19namespace gpr::quantum {
20// The molecular GP is the joint energy/gradient model used by GPNEB. Its
21// inverse-distance descriptor and periodic cell belong to AtomsConfiguration.
23public:
28 AtomsConfiguration configuration, MassMetric metric,
29 bool pairLocalDirectional = true, bool useHssvd = true)
30 : configuration_(std::move(configuration)),
31 metric_(std::move(metric)),
32 box_(configuration_.cell)
33 {
34 gp_.initialize(parameters, configuration_);
35 gp_.setHssvdBackend(useHssvd);
36 gp_.setPairLocalDirectionalTiles(pairLocalDirectional);
37 observationChartRadius_ =
38 .25 * geometry::uniqueImageRadius(configuration_.cell);
39 }
40 // A closed native return belongs to the model independently of acceptance.
41 std::vector<PotentialEvaluation> observeNativeBatch(
42 const std::vector<Eigen::VectorXd>& q,
43 const LineIntegralNEBBatch& native)
44 {
45 if (!native)
46 throw std::invalid_argument("Native batch callback required");
47 auto values = native(q);
48 addObservations(q, values);
49 return values;
50 }
51 // Loading owned native observations does not optimize hyperparameters.
52 // A changed data set must be fitted before any prediction is consumed.
53 std::size_t addObservations(const std::vector<Eigen::VectorXd>& q,
54 const std::vector<PotentialEvaluation>& values)
55 {
56 if (q.size() != values.size())
57 throw std::invalid_argument(
58 "Matching native GP observations required");
59 const auto before = archive_.R.rows();
60 for (std::size_t j = 0; j < q.size(); ++j)
61 if (q[j].size() != metric_.dimension() || !q[j].allFinite() ||
62 values[j].gradient.size() != metric_.dimension() ||
63 !values[j].gradient.allFinite() ||
64 !std::isfinite(values[j].energy))
65 throw std::invalid_argument(
66 "Finite matching native GP observations required");
67 std::vector<Eigen::VectorXd> pending;
68 std::vector<std::size_t> source;
69 for (std::size_t j = 0; j < q.size(); ++j) {
70 const Eigen::VectorXd x = metric_.physical(q[j]);
71 if (!x.allFinite())
72 throw std::invalid_argument(
73 "Finite physical native GP coordinates required");
74 if (findPhysicalObservation(x, &pending) >= 0) continue;
75 if (before == 0 && pending.empty()) observationAnchor_ = x;
76 const auto row = before + static_cast<Eigen::Index>(pending.size());
77 pending.push_back(x);
78 source.push_back(j);
79 observationScale_ =
80 std::max(observationScale_, x.cwiseAbs().maxCoeff());
81 if (inObservationChart(x))
82 observationCoordinates_.emplace(x[0], row);
83 else
84 outsideObservationChart_.push_back(row);
85 }
86 if (!pending.empty()) {
87 Observation added;
88 added.R.resize(pending.size(), metric_.dimension());
89 added.G.resize(pending.size(), metric_.dimension());
90 added.E.resize(pending.size(), 1);
91 for (std::size_t row = 0; row < pending.size(); ++row) {
92 added.R.row(row) = pending[row].transpose();
93 added.G.row(row) = (metric_.roots().array() *
94 values[source[row]].gradient.array())
95 .matrix()
96 .transpose();
97 added.E(row, 0) = values[source[row]].energy;
98 }
99 fitted_ = false;
100 if (before == 0)
101 archive_ = std::move(added);
102 else
103 archive_.append(added);
104 }
105 return static_cast<std::size_t>(archive_.R.rows() - before);
106 }
107 void refit(const std::vector<Eigen::VectorXd>& q,
108 const std::vector<PotentialEvaluation>& values)
109 {
110 addObservations(q, values);
111 observations_ = archive_;
112 fit();
113 }
114 // Native ownership spans the archive. A bounded posterior retains every
115 // requested site and fills its remaining rows by mass-metric proximity.
116 void refitLocal(const std::vector<Eigen::VectorXd>& q,
117 const std::vector<PotentialEvaluation>& values,
118 std::size_t maximumSites)
119 {
120 if (q.empty() || maximumSites == 0)
121 throw std::invalid_argument(
122 "Local GP fitting requires sites and a positive budget");
123 addObservations(q, values);
124 std::vector<Eigen::VectorXd> physical;
125 for (const auto& point: q)
126 physical.push_back(metric_.physical(point));
127 std::vector<Eigen::Index> selected;
128 std::vector<bool> required(archive_.R.rows(), false);
129 for (const auto& point: physical) {
130 const auto row = findPhysicalObservation(point);
131 if (row >= 0 && !required[row]) {
132 selected.push_back(row);
133 required[row] = true;
134 }
135 }
136 if (selected.size() > maximumSites)
137 throw std::invalid_argument(
138 "Local GP budget cannot exclude a requested native site");
139 std::vector<std::pair<double, Eigen::Index>> candidates;
140 for (Eigen::Index row = 0; row < archive_.R.rows(); ++row)
141 if (!required[row]) {
142 double distance = std::numeric_limits<double>::infinity();
143 const Eigen::VectorXd site = archive_.R.row(row).transpose();
144 for (const auto& point: physical) {
146 &box_, site, point);
147 distance = std::min(
148 distance, (delta.array() * metric_.roots().array())
149 .matrix()
150 .squaredNorm());
151 }
152 candidates.emplace_back(distance, row);
153 }
154 std::stable_sort(
155 candidates.begin(), candidates.end(),
156 [](const auto& a, const auto& b) { return a.first < b.first; });
157 for (const auto& candidate: candidates) {
158 if (selected.size() == maximumSites) break;
159 selected.push_back(candidate.second);
160 }
161 observations_.R.resize(selected.size(), archive_.R.cols());
162 observations_.G.resize(selected.size(), archive_.G.cols());
163 observations_.E.resize(selected.size(), archive_.E.cols());
164 for (std::size_t row = 0; row < selected.size(); ++row) {
165 observations_.R.row(row) = archive_.R.row(selected[row]);
166 observations_.G.row(row) = archive_.G.row(selected[row]);
167 observations_.E.row(row) = archive_.E.row(selected[row]);
168 }
169 fit();
170 }
171 // Fit a posterior around unevaluated band coordinates while requiring only
172 // selected archive owners. No predicted value can enter the native archive.
173 void refitArchivedLocal(const std::vector<Eigen::VectorXd>& targets,
174 const std::vector<Eigen::VectorXd>& required,
175 std::size_t maximumSites)
176 {
177 if (targets.empty() || maximumSites == 0 || archive_.R.rows() == 0)
178 throw std::invalid_argument(
179 "Archived local GP fitting requires a native archive and "
180 "positive budget");
181 std::vector<Eigen::VectorXd> physicalTargets;
182 for (const auto& point: targets) {
183 if (point.size() != metric_.dimension() || !point.allFinite())
184 throw std::invalid_argument(
185 "Finite mass-coordinate GP targets required");
186 physicalTargets.push_back(metric_.physical(point));
187 }
188 std::vector<Eigen::Index> selected;
189 std::vector<bool> included(archive_.R.rows(), false);
190 for (const auto& point: required) {
191 if (point.size() != metric_.dimension() || !point.allFinite())
192 throw std::invalid_argument(
193 "Finite required native GP archive sites required");
194 const auto row = findPhysicalObservation(metric_.physical(point));
195 if (row < 0)
196 throw std::invalid_argument(
197 "Required GP site has no native observation owner");
198 if (!included[row]) {
199 selected.push_back(row);
200 included[row] = true;
201 }
202 }
203 if (selected.size() > maximumSites)
204 throw std::invalid_argument(
205 "Local GP budget cannot exclude a required native observation");
206 std::vector<std::pair<double, Eigen::Index>> candidates;
207 for (Eigen::Index row = 0; row < archive_.R.rows(); ++row)
208 if (!included[row]) {
209 const Eigen::VectorXd site = archive_.R.row(row).transpose();
210 double distance = std::numeric_limits<double>::infinity();
211 for (const auto& point: physicalTargets) {
213 &box_, site, point);
214 distance = std::min(
215 distance, (delta.array() * metric_.roots().array())
216 .matrix()
217 .squaredNorm());
218 }
219 candidates.emplace_back(distance, row);
220 }
221 std::stable_sort(
222 candidates.begin(), candidates.end(),
223 [](const auto& a, const auto& b) { return a.first < b.first; });
224 for (const auto& candidate: candidates) {
225 if (selected.size() == maximumSites) break;
226 selected.push_back(candidate.second);
227 }
228 observations_.R.resize(selected.size(), archive_.R.cols());
229 observations_.G.resize(selected.size(), archive_.G.cols());
230 observations_.E.resize(selected.size(), archive_.E.cols());
231 for (std::size_t row = 0; row < selected.size(); ++row) {
232 observations_.R.row(row) = archive_.R.row(selected[row]);
233 observations_.G.row(row) = archive_.G.row(selected[row]);
234 observations_.E.row(row) = archive_.E.row(selected[row]);
235 }
236 fit();
237 }
238 // The fitted background is retained while an independent, anchored
239 // correction learns appended native sites. Its bounded suffix prevents
240 // the conditional factor from growing with the ownership archive.
241 bool refitWithActiveResidual(const std::vector<Eigen::VectorXd>& q,
242 const std::vector<PotentialEvaluation>& values,
243 std::size_t maximumBackgroundSites,
244 std::size_t maximumAddedSites)
245 {
246 if (q.empty() || maximumBackgroundSites == 0 || maximumAddedSites == 0)
247 throw std::invalid_argument(
248 "Active GP fitting requires sites and positive budgets");
249 addObservations(q, values);
250 auto candidate = observations_;
251 if (backgroundRows_ > 0 && static_cast<std::size_t>(backgroundRows_) <=
252 maximumBackgroundSites) {
253 for (Eigen::Index row = consumedArchiveRows_;
254 row < archive_.R.rows(); ++row) {
255 bool present = false;
256 for (Eigen::Index existing = 0; existing < candidate.R.rows();
257 ++existing)
258 if (samePhysical(candidate.R.row(existing).transpose(),
259 archive_.R.row(row).transpose())) {
260 present = true;
261 break;
262 }
263 if (!present) {
264 Observation one;
265 one.R = archive_.R.middleRows(row, 1);
266 one.G = archive_.G.middleRows(row, 1);
267 one.E = archive_.E.middleRows(row, 1);
268 candidate.append(one);
269 }
270 }
271 for (const auto& point: q) {
272 const Eigen::VectorXd x = metric_.physical(point);
273 bool present = false;
274 for (Eigen::Index row = 0; row < candidate.R.rows(); ++row)
275 if (samePhysical(candidate.R.row(row).transpose(), x)) {
276 present = true;
277 break;
278 }
279 if (present) continue;
280 for (Eigen::Index row = 0; row < archive_.R.rows(); ++row)
281 if (samePhysical(archive_.R.row(row).transpose(), x)) {
282 Observation one;
283 one.R = archive_.R.middleRows(row, 1);
284 one.G = archive_.G.middleRows(row, 1);
285 one.E = archive_.E.middleRows(row, 1);
286 candidate.append(one);
287 break;
288 }
289 }
290 const auto added = candidate.R.rows() - backgroundRows_;
291 if (added > 0 &&
292 static_cast<std::size_t>(added) <= maximumAddedSites &&
293 gp_.fitActivePosterior(
294 candidate, std::vector<bool>(configuration_.n_pt, true))) {
295 observations_ = std::move(candidate);
296 consumedArchiveRows_ = archive_.R.rows();
297 fitted_ = true;
298 return true;
299 }
300 }
301 refitLocal(q, values, std::max(maximumBackgroundSites, q.size()));
302 return false;
303 }
304 // Balanced neighbourhoods condition a fitted posterior with archived native
305 // rows. The kernel and ownership archive remain fixed; each target receives
306 // its nearest available site before another selection round begins.
308 const std::vector<Eigen::VectorXd>& targets,
309 std::size_t maximumAddedSites)
310 {
311 if (!fitted_)
312 throw std::logic_error(
313 "Fit a native background before archive conditioning");
314 if (targets.empty())
315 throw std::invalid_argument(
316 "Nonempty archive conditioning targets required");
317 std::vector<Eigen::VectorXd> physical;
318 for (const auto& target: targets) {
319 if (target.size() != metric_.dimension() || !target.allFinite())
320 throw std::invalid_argument(
321 "Finite matching archive targets required");
322 physical.push_back(metric_.physical(target));
323 if (!physical.back().allFinite())
324 throw std::overflow_error(
325 "Archive target exceeds physical coordinate range");
326 }
327 if (maximumAddedSites == 0) return 0;
328 using Neighbour = std::pair<double, Eigen::Index>;
329 std::vector<std::vector<Neighbour>> regions(targets.size());
330 for (Eigen::Index row = 0; row < archive_.R.rows(); ++row) {
331 const Eigen::VectorXd site = archive_.R.row(row).transpose();
332 bool present = false;
333 for (Eigen::Index fitted = 0; fitted < observations_.R.rows();
334 ++fitted)
335 if (samePhysical(site,
336 observations_.R.row(fitted).transpose())) {
337 present = true;
338 break;
339 }
340 if (present) continue;
341 double nearest = std::numeric_limits<double>::infinity();
342 std::size_t region = 0;
343 for (std::size_t j = 0; j < physical.size(); ++j) {
345 &box_, site, physical[j]);
346 const double distance =
347 (delta.array() * metric_.roots().array())
348 .matrix()
349 .squaredNorm();
350 if (!std::isfinite(distance))
351 throw std::overflow_error(
352 "Archive neighbourhood distance exceeds range");
353 if (distance < nearest) {
354 nearest = distance;
355 region = j;
356 }
357 }
358 regions[region].emplace_back(nearest, row);
359 }
360 for (auto& region: regions)
361 std::stable_sort(
362 region.begin(), region.end(),
363 [](const auto& a, const auto& b) { return a.first < b.first; });
364 std::vector<Eigen::Index> selected;
365 std::vector<std::size_t> next(regions.size(), 0);
366 bool added = true;
367 while (selected.size() < maximumAddedSites && added) {
368 added = false;
369 for (std::size_t j = 0;
370 j < regions.size() && selected.size() < maximumAddedSites; ++j)
371 if (next[j] < regions[j].size()) {
372 selected.push_back(regions[j][next[j]++].second);
373 added = true;
374 }
375 }
376 if (selected.empty()) return 0;
377 auto candidate = observations_;
378 for (const auto row: selected) {
379 Observation one;
380 one.R = archive_.R.middleRows(row, 1);
381 one.G = archive_.G.middleRows(row, 1);
382 one.E = archive_.E.middleRows(row, 1);
383 candidate.append(one);
384 }
385 fitted_ = false;
386 if (!gp_.conditionActivePosterior(candidate)) {
387 const Coord added = candidate.R.bottomRows(selected.size());
388 Eigen::MatrixXd covariance;
389 gp_.calculateObservationPosteriorCovariance(added, covariance,
390 false);
391 covariance.diagonal() +=
392 gp_.calculateObservationNoiseDiagonal(added);
393 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> spectrum(
394 covariance, Eigen::EigenvaluesOnly);
395 std::ostringstream error;
396 error.precision(17);
397 error << "Archived native Gaussian conditioning failed; channels="
398 << covariance.rows();
399 if (spectrum.info() == Eigen::Success)
400 error << "; minimum_eigenvalue="
401 << spectrum.eigenvalues().minCoeff()
402 << "; maximum_eigenvalue="
403 << spectrum.eigenvalues().maxCoeff();
404 error << "; minimum_diagonal=" << covariance.diagonal().minCoeff()
405 << "; maximum_entry=" << covariance.cwiseAbs().maxCoeff();
406 throw std::runtime_error(error.str());
407 }
408 observations_ = std::move(candidate);
409 consumedArchiveRows_ = archive_.R.rows();
410 fitted_ = true;
411 return selected.size();
412 }
413 // Only the requested owned measurements condition the fitted background.
414 // Kernel parameters and the physical output transform remain fixed.
415 bool conditionNativeBatch(const std::vector<Eigen::VectorXd>& q,
416 const std::vector<PotentialEvaluation>& values)
417 {
418 if (!fitted_)
419 throw std::logic_error(
420 "Fit native observations before conditioning");
421 auto candidate = observations_;
422 addObservations(q, values);
423 for (const auto& point: q) {
424 const Eigen::VectorXd x = metric_.physical(point);
425 bool present = false;
426 for (Eigen::Index row = 0; row < candidate.R.rows(); ++row)
427 if (samePhysical(candidate.R.row(row).transpose(), x)) {
428 present = true;
429 break;
430 }
431 if (present) continue;
432 const auto row = findPhysicalObservation(x);
433 if (row < 0)
434 throw std::logic_error(
435 "Native measurement is absent from its archive");
436 Observation one;
437 one.R = archive_.R.middleRows(row, 1);
438 one.G = archive_.G.middleRows(row, 1);
439 one.E = archive_.E.middleRows(row, 1);
440 candidate.append(one);
441 }
442 if (candidate.R.rows() == observations_.R.rows()) {
443 fitted_ = true;
444 return true;
445 }
446 fitted_ = false;
447 if (!gp_.conditionActivePosterior(candidate)) return false;
448 observations_ = std::move(candidate);
449 consumedArchiveRows_ = archive_.R.rows();
450 fitted_ = true;
451 return true;
452 }
453
454 bool hasConditionedResidual() const noexcept
455 {
456 return fitted_ && gp_.hasActivePosterior();
457 }
458
459private:
460 void fit()
461 {
462 if (observations_.R.rows() == 0)
463 throw std::invalid_argument(
464 "At least one native GP observation required");
465 fitted_ = false;
466 backgroundRows_ = 0;
467 const bool cold = !gp_.hasBeenOptimized();
468 gp_.setHyperparameters(observations_, configuration_, cold, cold, cold);
469 gp_.optimize(observations_);
470 if (!gp_.isDecomposedSuccessfully())
471 throw std::runtime_error(
472 "LI-NEB GP posterior factorization failed");
473 fitted_ = true;
474 backgroundRows_ = observations_.R.rows();
475 consumedArchiveRows_ = archive_.R.rows();
476 // A finite posterior supplies proposals. Hyperparameter stationarity is
477 // a separate diagnostic; path acceptance uses native energies and
478 // forces.
479 if (gp_.failedOptim()) {
480 std::vector<Eigen::VectorXd> training;
481 for (Eigen::Index row = 0; row < observations_.R.rows(); ++row)
482 training.push_back(
483 metric_.weighted(observations_.R.row(row).transpose()));
484 (void)evaluate(training);
485 }
486 }
487
488public:
489 std::vector<PotentialEvaluation> evaluate(
490 const std::vector<Eigen::VectorXd>& q)
491 {
492 if (!q.empty() && !fitted_)
493 throw std::logic_error(
494 "Native GP observations require fitting before prediction");
495 std::vector<PotentialEvaluation> values;
496 for (const auto& p: q) {
497 Observation prediction;
498 prediction.R.resize(1, p.size());
499 prediction.R.row(0) = metric_.physical(p).transpose();
500 gp_.calculatePotentialDispatched(prediction);
501 if (prediction.E.rows() != 1 || prediction.E.cols() != 1 ||
502 prediction.G.rows() != 1 || prediction.G.cols() != p.size())
503 throw std::runtime_error("LI-NEB GP prediction shape mismatch");
504 if (!std::isfinite(prediction.E(0, 0)))
505 throw std::runtime_error(
506 "Nonfinite LI-NEB GP energy prediction");
507 values.push_back(
508 {prediction.E(0, 0),
509 metric_.gradient(prediction.G.row(0).transpose())});
510 }
511 return values;
512 }
513 // Marginal physical-gradient uncertainties transformed to the mass metric.
514 std::vector<PointVariance> posteriorPointVariance(
515 const std::vector<Eigen::VectorXd>& q)
516 {
517 if (q.empty()) return {};
518 if (!fitted_)
519 throw std::logic_error(
520 "Native GP observations require fitting before uncertainty "
521 "prediction");
522 std::vector<Observation> storage(q.size());
523 std::vector<Observation*> queries;
524 queries.reserve(q.size());
525 for (std::size_t j = 0; j < q.size(); ++j) {
526 if (q[j].size() != metric_.dimension() || !q[j].allFinite())
527 throw std::invalid_argument(
528 "Finite mass-coordinate GP uncertainty sites required");
529 auto& point = storage[j];
530 point.R.resize(1, metric_.dimension());
531 point.R.row(0) = metric_.physical(q[j]).transpose();
532 point.E.resize(1, 1);
533 point.E.setZero();
534 point.G.resize(1, metric_.dimension());
535 point.G.setZero();
536 queries.push_back(&point);
537 }
538 gp_.calculateVarianceBatch(queries);
539 std::vector<PointVariance> result(q.size());
540 for (std::size_t j = 0; j < q.size(); ++j) {
541 if (storage[j].E.rows() != 1 || storage[j].E.cols() != 1 ||
542 storage[j].G.rows() != 1 ||
543 storage[j].G.cols() != metric_.dimension() ||
544 !storage[j].E.allFinite() || !storage[j].G.allFinite())
545 throw std::runtime_error(
546 "GP gradient-variance shape or values are invalid");
547 double massTrace = 0., cartesianTrace = 0.;
548 for (Eigen::Index k = 0; k < metric_.dimension(); ++k) {
549 const double variance = storage[j].G(0, k);
550 if (variance < -1e-12 * std::max(1., std::abs(variance)))
551 throw std::runtime_error(
552 "GP reports a negative marginal gradient variance");
553 const double nonnegative = std::max(0., variance);
554 cartesianTrace += nonnegative;
555 massTrace +=
556 nonnegative / (metric_.roots()[k] * metric_.roots()[k]);
557 }
558 result[j] = {std::max(0., storage[j].E(0, 0)), massTrace,
559 cartesianTrace};
560 }
561 return result;
562 }
563 // Joint latent energies precede one query block per mass-gradient
564 // coordinate. Measurement noise uses the same mass transformation as latent
565 // gradients.
567 const std::vector<Eigen::VectorXd>& q) const
568 {
569 if (q.empty()) return Eigen::VectorXd(0);
570 if (!fitted_)
571 throw std::logic_error(
572 "Fit native observations before noise prediction");
573 const Eigen::Index dimension = metric_.dimension();
574 const auto count = static_cast<Eigen::Index>(q.size());
575 if (std::cmp_greater(q.size(),
576 static_cast<std::size_t>(
577 std::numeric_limits<Eigen::Index>::max() /
578 (dimension + 1))))
579 throw std::invalid_argument("GP noise channel count is too large");
580 Coord positions(count, dimension);
581 for (Eigen::Index j = 0; j < count; ++j) {
582 if (q[j].size() != dimension || !q[j].allFinite())
583 throw std::invalid_argument(
584 "Finite matching measurement sites required");
585 positions.row(j) = metric_.physical(q[j]).transpose();
586 }
587 Eigen::VectorXd noise =
588 gp_.calculateObservationNoiseDiagonal(positions);
589 if (noise.size() != count * (dimension + 1))
590 throw std::runtime_error("GP noise channel count differs");
591 for (Eigen::Index k = 0; k < dimension; ++k)
592 noise.segment(count * (k + 1), count) /=
593 metric_.roots()[k] * metric_.roots()[k];
594 return noise;
595 }
596
598 const std::vector<Eigen::VectorXd>& q)
599 {
600 if (q.empty()) return Eigen::MatrixXd(0, 0);
601 if (!fitted_)
602 throw std::logic_error(
603 "Fit native observations before joint uncertainty prediction");
604 const Eigen::Index dimension = metric_.dimension();
605 const auto maximumCount = static_cast<std::size_t>(
606 std::numeric_limits<Eigen::Index>::max() / (dimension + 1));
607 if (std::cmp_greater(q.size(), maximumCount))
608 throw std::invalid_argument("GP joint channel count is too large");
609 const auto count = static_cast<Eigen::Index>(q.size());
610 Coord positions(count, dimension);
611 for (Eigen::Index j = 0; j < count; ++j) {
612 if (q[j].size() != dimension || !q[j].allFinite())
613 throw std::invalid_argument(
614 "Finite matching mass-coordinate uncertainty sites "
615 "required");
616 positions.row(j) = metric_.physical(q[j]).transpose();
617 }
618 Eigen::MatrixXd covariance;
619 gp_.calculateObservationPosteriorCovariance(positions, covariance,
620 false);
621 const Eigen::Index channels = count * (dimension + 1);
622 if (covariance.rows() != channels || covariance.cols() != channels ||
623 !covariance.allFinite())
624 throw std::runtime_error(
625 "Joint GP covariance dimensions or values differ");
626 Eigen::VectorXd scales = Eigen::VectorXd::Ones(channels);
627 for (Eigen::Index k = 0; k < dimension; ++k)
628 scales.segment(count * (k + 1), count)
629 .setConstant(1 / metric_.roots()[k]);
630 covariance =
631 (scales.asDiagonal() * covariance * scales.asDiagonal()).eval();
632 if (!covariance.allFinite())
633 throw std::runtime_error(
634 "Mass-coordinate GP covariance is nonfinite");
635 return covariance;
636 }
637
638 // Joint latent GP uncertainty of a weighted energy sum in physical units.
639 // Energy weights precede zero weights for every Cartesian gradient channel.
641 const std::vector<Eigen::VectorXd>& q,
642 const Eigen::VectorXd& energyWeights)
643 {
644 if (q.size() != static_cast<std::size_t>(energyWeights.size()) ||
645 !energyWeights.allFinite())
646 throw std::invalid_argument(
647 "Finite matching GP energy-functional weights required");
648 if (q.empty()) return 0.;
649 if (!fitted_)
650 throw std::logic_error(
651 "Native GP observations require fitting before uncertainty "
652 "prediction");
653 const Eigen::Index dimension = metric_.dimension();
654 if (q.size() >
655 static_cast<std::size_t>(std::numeric_limits<Eigen::Index>::max() /
656 (dimension + 1)))
657 throw std::invalid_argument(
658 "GP energy-functional channel count is too large");
659 const auto count = static_cast<Eigen::Index>(q.size());
660 Coord positions(count, dimension);
661 for (Eigen::Index j = 0; j < count; ++j) {
662 if (q[j].size() != dimension || !q[j].allFinite())
663 throw std::invalid_argument(
664 "Finite mass-coordinate GP uncertainty sites required");
665 positions.row(j) = metric_.physical(q[j]).transpose();
666 }
667 Eigen::VectorXd weights =
668 Eigen::VectorXd::Zero(count * (dimension + 1));
669 weights.head(count) = energyWeights;
670 const double variance =
671 gp_.calculateObservationFunctionalVariance(positions, weights);
672 if (!std::isfinite(variance))
673 throw std::runtime_error("Nonfinite GP energy-functional variance");
674 return variance;
675 }
676 // H_q v = M^(-1/2) H_x M^(-1/2) v. The prepared physical
677 // posterior includes its mean and residual; consume it before refitting.
679 const Eigen::VectorXd& q)
680 {
681 if (!fitted_) return {};
682 Coord position(1, q.size());
683 position.row(0) = metric_.physical(q).transpose();
684 auto physical = gp_.prepareMeanHessian(position);
685 if (!physical) return {};
686 const Eigen::VectorXd roots = metric_.roots();
687 return [physical = std::move(physical), roots](
688 const Eigen::VectorXd& direction, Eigen::VectorXd& result) {
689 if (direction.size() != roots.size() || !direction.allFinite())
690 return false;
691 const Eigen::VectorXd cartesian = direction.array() / roots.array();
692 Eigen::VectorXd response;
693 if (!physical(cartesian, response) ||
694 response.size() != roots.size() || !response.allFinite())
695 return false;
696 result = response.array() / roots.array();
697 return result.allFinite();
698 };
699 }
700 bool hyperparametersConverged() const noexcept
701 {
702 return fitted_ && !gp_.failedOptim();
703 }
704 Eigen::Index observations() const
705 {
706 return archive_.R.rows();
707 }
708 std::size_t observationIdentityComparisons() const noexcept
709 {
710 return observationIdentityComparisons_;
711 }
712 Eigen::Index fittedObservations() const
713 {
714 return fitted_ ? observations_.R.rows() : 0;
715 }
716 bool hasFittedObservation(const Eigen::VectorXd& q) const
717 {
718 if (!fitted_) return false;
719 const auto x = metric_.physical(q);
720 for (Eigen::Index row = 0; row < observations_.R.rows(); ++row)
721 if (samePhysical(observations_.R.row(row).transpose(), x))
722 return true;
723 return false;
724 }
725 std::size_t directionalPairTiles() const
726 {
727 return gp_.pair_local_directional_tiles_for_testing_;
728 }
729 // Validation points must be absent under the same periodic geometry rule
730 // that selects the model's native observations.
731 bool hasObservation(const Eigen::VectorXd& q) const
732 {
733 return hasPhysicalObservation(metric_.physical(q));
734 }
735 bool ownsNativeObservation(const Eigen::VectorXd& q) const
736 {
737 return hasObservation(q);
738 }
739 // Distance in the inverse-distance feature metric used by the fitted GP.
740 double nearestNativeDistance(const Eigen::VectorXd& q) const
741 {
742 if (archive_.R.rows() == 0 || q.size() != metric_.dimension() ||
743 !q.allFinite())
744 return std::numeric_limits<double>::infinity();
745 const Eigen::VectorXd point = metric_.physical(q);
746 const auto& lengths =
747 gp_.getSexpAtCovarianceFunction().getLengthScaleRef();
748 if (lengths.size() == 0)
749 throw std::runtime_error(
750 "The fitted GP has no inverse-distance length scales");
751 const Eigen::Index atoms = configuration_.atoms_mov.type.size();
752 auto squaredFeatureDistance = [&](const Eigen::VectorXd& site) {
753 double squared = 0.;
754 for (Eigen::Index i = 0; i < atoms; ++i)
755 for (Eigen::Index j = i + 1; j < atoms; ++j) {
756 const auto pair = configuration_.pairtype(
757 configuration_.atoms_mov.type(0, i),
758 configuration_.atoms_mov.type(0, j));
759 if (pair < 0 ||
760 (lengths.size() != 1 && pair >= lengths.size()))
761 continue;
762 const double length =
763 lengths.size() == 1 ? lengths.data()[0] : lengths(pair);
764 const double left =
765 box_.displacement(site.segment<3>(3 * i),
766 site.segment<3>(3 * j))
767 .norm();
768 const double right =
769 box_.displacement(point.segment<3>(3 * i),
770 point.segment<3>(3 * j))
771 .norm();
772 if (!(length > 0.) || !std::isfinite(length) ||
773 !(left > 0.) || !(right > 0.))
774 throw std::domain_error(
775 "The GP trust metric requires finite nonzero pair "
776 "distances");
777 const double delta = (1. / left - 1. / right) / length;
778 squared += delta * delta;
779 }
780 return squared;
781 };
782 double squared = std::numeric_limits<double>::infinity();
783 for (Eigen::Index row = 0; row < archive_.R.rows(); ++row)
784 squared = std::min(squared, squaredFeatureDistance(
785 archive_.R.row(row).transpose()));
786 return std::sqrt(squared);
787 }
788 bool nativeObservation(const Eigen::VectorXd& q,
789 PotentialEvaluation& value) const
790 {
791 if (q.size() != metric_.dimension() || !q.allFinite())
792 throw std::invalid_argument(
793 "Finite mass-coordinate native observation required");
794 const auto row = findPhysicalObservation(metric_.physical(q));
795 if (row < 0) return false;
796 value.energy = archive_.E(row, 0);
797 value.gradient =
798 (archive_.G.row(row).transpose().array() / metric_.roots().array())
799 .matrix();
800 return true;
801 }
802
803private:
804 bool hasPhysicalObservation(const Eigen::VectorXd& x) const
805 {
806 return findPhysicalObservation(x) >= 0;
807 }
808 bool inObservationChart(const Eigen::VectorXd& x) const
809 {
810 if (!box_.periodic()) return true;
811 if (!(observationChartRadius_ > 0.) ||
812 !std::isfinite(observationChartRadius_))
813 return false;
814 for (Eigen::Index atom = 0; atom < x.size(); atom += 3)
815 if (!((x.segment<3>(atom) - observationAnchor_.segment<3>(atom))
816 .stableNorm() < observationChartRadius_))
817 return false;
818 return true;
819 }
820 // Each chart point lies within one quarter of minimage's unique-image
821 // radius from the anchor, atom by atom. Two chart points therefore have
822 // raw displacements strictly within half that radius: their minimum image
823 // is Cartesian. One coordinate supplies a conservative search interval.
824 // Outside points use exhaustive matching, including translated images.
825 // samePhysical owns every identity decision and its original tolerance.
826 Eigen::Index findPhysicalObservation(
827 const Eigen::VectorXd& x,
828 const std::vector<Eigen::VectorXd>* pending = nullptr) const
829 {
830 const auto count =
831 archive_.R.rows() +
832 static_cast<Eigen::Index>(pending ? pending->size() : 0);
833 if (count == 0) return -1;
834 Eigen::Index first = -1;
835 auto consider = [&](Eigen::Index row) {
836 if (first >= 0 && row >= first) return;
837 const Eigen::VectorXd point =
838 row < archive_.R.rows()
839 ? Eigen::VectorXd(archive_.R.row(row).transpose())
840 : pending->at(row - archive_.R.rows());
841 ++observationIdentityComparisons_;
842 if (samePhysical(point, x)) first = row;
843 };
844 if (!inObservationChart(x)) {
845 for (Eigen::Index row = 0; row < count; ++row) {
846 consider(row);
847 if (first >= 0) break;
848 }
849 return first;
850 }
851 const double scale =
852 std::max({1., observationScale_, x.cwiseAbs().maxCoeff()});
853 const double eps = std::numeric_limits<double>::epsilon();
854 const double tolerance = std::max(1e-12, 128 * eps * scale);
855 const double width =
856 std::nextafter(tolerance, std::numeric_limits<double>::infinity());
857 const auto begin = observationCoordinates_.lower_bound(std::nextafter(
858 x[0] - width, -std::numeric_limits<double>::infinity()));
859 const auto end = observationCoordinates_.upper_bound(std::nextafter(
860 x[0] + width, std::numeric_limits<double>::infinity()));
861 for (auto entry = begin; entry != end; ++entry)
862 consider(entry->second);
863 for (const auto row: outsideObservationChart_)
864 consider(row);
865 return first;
866 }
867 bool samePhysical(const Eigen::VectorXd& previous,
868 const Eigen::VectorXd& x) const
869 {
870 const auto delta =
872 const double scale = std::max(
873 {1., previous.cwiseAbs().maxCoeff(), x.cwiseAbs().maxCoeff()});
874 const double tolerance = std::max(
875 1e-12, 128 * std::numeric_limits<double>::epsilon() * scale);
876 return delta.cwiseAbs().maxCoeff() <= tolerance;
877 }
878 GaussianProcessRegression gp_;
879 AtomsConfiguration configuration_;
880 MassMetric metric_;
881 geometry::PairBox box_;
882 Observation observations_;
883 Observation archive_;
884 std::multimap<double, Eigen::Index> observationCoordinates_;
885 std::vector<Eigen::Index> outsideObservationChart_;
886 Eigen::VectorXd observationAnchor_;
887 double observationChartRadius_{};
888 double observationScale_ = 1.;
889 mutable std::size_t observationIdentityComparisons_{};
890 Eigen::Index backgroundRows_{};
891 Eigen::Index consumedArchiveRows_{};
892 bool fitted_{};
893};
894
895// SIDPP acts on physical Cartesian coordinates, not on mass coordinates.
896// The shared NEBPath implementation supplies minimum-image pair geometry.
897inline std::vector<Eigen::VectorXd> lineIntegralSIDPPSeed(
898 neb::NEBPath& physicalBand, int atoms, const std::vector<char>& moving,
899 const MassMetric& metric, double alpha = .33)
900{
901 physicalBand.initializeSIDPP(atoms, moving, alpha);
902 std::vector<Eigen::VectorXd> result;
903 for (int j = 0; j < physicalBand.numImages(); ++j)
904 result.push_back(metric.weighted(physicalBand.image(j).positions));
905 return result;
906}
907
909
928
929// AIE outer loop: the surrogate moves the contour endpoints and the interior
930// together. Every convergence decision uses native values at every current
931// band coordinate, including independently corrected interior points.
932template <class Model>
934 const std::vector<Eigen::VectorXd>& initial,
935 const LineIntegralNEBBatch& potential, Model& model,
936 const GPLineIntegralNEBOptions& options = {},
937 const std::function<void(const GPLineIntegralNEBResult&)>& retain = {})
938{
939 if (!(options.maximumProposalDisplacement > 0) ||
940 !std::isfinite(options.maximumProposalDisplacement) || !potential)
941 throw std::invalid_argument(
942 "Positive finite GP proposal radius and native calculator "
943 "required");
944 if (options.path.jctcCompatible && options.stringMethod)
945 throw std::invalid_argument(
946 "JCTC-compatible constraints require the LI-NEB path method");
947 GPLineIntegralNEBResult result;
948 std::vector<Eigen::VectorXd> measuredPoints;
949 std::vector<PotentialEvaluation> measuredValues;
950 auto observe = [&](const auto& q) {
951 auto values = potential(q);
952 if (values.size() != q.size())
953 throw std::runtime_error("Native GP LI-NEB batch shape mismatch");
954 measuredPoints.insert(measuredPoints.end(), q.begin(), q.end());
955 measuredValues.insert(measuredValues.end(), values.begin(),
956 values.end());
957 return values;
958 };
959 auto native = [&](const auto& q) {
960 ++result.native.batchEvaluations;
961 result.native.evaluations += q.size();
962 return observe(q);
963 };
964 LineIntegralFIREState fireState;
965 auto measured = [&](const auto& q, const auto& v) {
966 const auto& o = options.path;
967 double spring = o.spring, contour = o.contour,
968 contourRight = o.contourRight;
969 if (o.jctcCompatible && fireState.initialized &&
970 fireState.constraintsInitialized) {
971 spring = fireState.spring;
972 contour = fireState.contourLeft;
973 contourRight = fireState.contourRight;
974 }
975 return evaluateLineIntegralNEB(q, v, o.energy, spring, contour, o.hbar,
976 o.action, o.jctcCompatible, contourRight,
977 o.actionForceCutoff);
978 };
979 auto forceCriteria = [&](const LineIntegralNEBState& state) {
980 return state.maximumForce < options.path.forceTolerance &&
981 (!options.path.jctcCompatible ||
982 state.transverseForceSum <
983 options.path.transverseForceSumTolerance);
984 };
985 auto contourCriteria = [&](const LineIntegralNEBState& state) {
986 return options.path.jctcCompatible ||
987 state.endpointEnergyError < options.path.energyTolerance;
988 };
989 auto nativeCriteria = [&](const LineIntegralNEBState& state) {
990 return forceCriteria(state) && contourCriteria(state) &&
991 state.turningOrientationsQualified;
992 };
993 result.native.path = initial;
994 result.native.native = native(initial);
995 result.native.state = measured(initial, result.native.native);
996 for (std::size_t outer = 0; outer <= options.maximumOuterIterations;
997 ++outer) {
998 result.outerIterations = outer;
999 auto& current = result.native;
1000 // Native Newton corrections close the contour independently of the GP
1001 // interpolation error. Only the two changed endpoints require new
1002 // forces.
1003 for (int correction = 0; correction < 12; ++correction) {
1004 std::vector<Eigen::VectorXd> endpoints;
1005 std::vector<std::size_t> indices;
1006 for (auto j: {std::size_t(0), current.path.size() - 1}) {
1007 const auto& value = current.native[j];
1008 const double residual = value.energy - options.path.energy;
1009 if (std::abs(residual) < .2 * options.path.energyTolerance)
1010 continue;
1011 const double norm2 = value.gradient.squaredNorm();
1012 if (!(norm2 > 0) || !std::isfinite(norm2))
1013 throw std::domain_error(
1014 "Native turning contour has no finite normal");
1015 Eigen::VectorXd step = -residual / norm2 * value.gradient;
1016 if (step.norm() > options.maximumProposalDisplacement)
1017 step *= options.maximumProposalDisplacement / step.norm();
1018 endpoints.push_back(current.path[j] + step);
1019 indices.push_back(j);
1020 }
1021 if (indices.empty()) break;
1022 const auto values = native(endpoints);
1023 if (values.size() != indices.size())
1024 throw std::runtime_error("Native contour batch shape mismatch");
1025 for (std::size_t k = 0; k < indices.size(); ++k) {
1026 current.path[indices[k]] = endpoints[k];
1027 current.native[indices[k]] = values[k];
1028 }
1029 }
1030 current.state = measured(current.path, current.native);
1031 current.converged = nativeCriteria(current.state);
1032 if (retain) retain(result);
1033 if (!current.state.turningOrientationsQualified &&
1034 forceCriteria(current.state) && contourCriteria(current.state)) {
1035 current.failure =
1036 "LI-NEB turning orientation does not enter the forbidden "
1037 "region";
1038 return result;
1039 }
1040 if (current.converged) {
1041 current.failure.clear();
1042 return result;
1043 }
1044 if (outer == options.maximumOuterIterations) break;
1045 model.refit(measuredPoints, measuredValues);
1046 ++result.refits;
1047 auto inner = options.path;
1048 inner.maximumIterations = options.innerIterations;
1049 inner.geometricPreconditioning = options.geometricSurrogateForces;
1050 auto surrogate = [&](const auto& q) {
1051 result.surrogateEvaluations += q.size();
1052 return model.evaluate(q);
1053 };
1054 auto propose = [&]() {
1055 auto path = current.path;
1056 try {
1057 path = (options.stringMethod
1058 ? optimizeLineIntegralString(current.path,
1059 surrogate, inner)
1061 current.path, surrogate, inner, {},
1062 options.path.jctcCompatible ? &fireState
1063 : nullptr))
1064 .path;
1065 } catch (const std::domain_error&) {
1066 }
1067 return path;
1068 };
1069 auto proposal = propose();
1070 bool accepted = false;
1071 double radius = options.maximumProposalDisplacement;
1072 for (int attempt = 0; attempt < 12; ++attempt) {
1073 double maximum = 0;
1074 for (std::size_t j = 0; j < proposal.size(); ++j)
1075 maximum =
1076 std::max(maximum, (proposal[j] - current.path[j]).norm());
1077 if (maximum <= 1e-12) break;
1078 const double fraction = maximum > radius ? radius / maximum : 1.;
1079 auto trial = current.path;
1080 for (std::size_t j = 0; j < trial.size(); ++j)
1081 trial[j] += fraction * (proposal[j] - current.path[j]);
1082 auto values = native(trial);
1083 auto restoration = options.path;
1084 restoration.maximumStep = radius;
1085 const auto repaired = restoreLineIntegralInterior(
1086 trial, values, current.native, restoration, native,
1087 options.nativeInteriorCorrections);
1088 result.interiorCorrectionBatches += repaired.batchEvaluations;
1089 result.interiorCorrectionPoints += repaired.pointEvaluations;
1090 double restoredDisplacement = 0;
1091 for (std::size_t j = 0; j < trial.size(); ++j)
1092 restoredDisplacement = std::max(
1093 restoredDisplacement, (trial[j] - current.path[j]).norm());
1094 try {
1095 auto state = measured(trial, values);
1096 // No GP-only stationarity or action is reported as native
1097 // evidence.
1098 if (state.turningOrientationsQualified &&
1099 restoredDisplacement > 1e-12 &&
1100 (options.proposalAcceptance ==
1102 state.maximumForce < current.state.maximumForce)) {
1103 current.path = std::move(trial);
1104 current.native = std::move(values);
1105 current.state = std::move(state);
1106 accepted = true;
1107 break;
1108 }
1109 } catch (const std::domain_error&) {
1110 }
1111 // Rejected native bands and contour corrections remain training
1112 // data. Each new proposal uses those forces inside a contracted
1113 // trust region.
1114 model.refit(measuredPoints, measuredValues);
1115 ++result.refits;
1116 proposal = propose();
1117 radius *= .5;
1118 }
1119 if (!accepted) {
1120 auto recovery = options.path;
1121 recovery.maximumIterations = options.nativeRecoveryIterations;
1122 const auto savedCalls = current.evaluations,
1123 savedBatches = current.batchEvaluations;
1124 auto recovered = optimizeLineIntegralNEB(
1125 current.path, observe, recovery, {},
1126 options.path.jctcCompatible ? &fireState : nullptr);
1127 recovered.evaluations += savedCalls;
1128 recovered.batchEvaluations += savedBatches;
1129 current = std::move(recovered);
1130 }
1131 ++current.iterations;
1132 }
1133 result.native.failure = "GP LI-NEB outer iteration limit";
1134 return result;
1135}
1136} // namespace gpr::quantum
@ x
Definition Enums.h:28
NEB path management: image chain, spring forces, climbing image.
void optimize(const Observation &observation)
Optimize paramaters of a Gaussian process.
Definition Optimize.cpp:550
std::function< bool(const Eigen::VectorXd &, Eigen::VectorXd &)> MeanHessianAction
void setHyperparameters(const Observation &all_obs, const AtomsConfiguration &conf_info, const bool update_sexpat_cf_param=true, const bool update_const_cf_param=true, const bool update_sqrt_prior_param=true)
Set up hyperparameters for GPR.
bool periodic() const noexcept
Some axis is periodic.
Definition MinImage.h:198
NEB path: chain of images between two endpoints.
Definition NEBPath.h:57
int numImages() const
Definition NEBPath.h:338
void initializeSIDPP(int n_atoms, double alpha=0.33)
Initialize via Sequential IDPP (SIDPP). rgsaddle_sidpp_alternating_path. The spring on that call is t...
Definition NEBPath.cpp:712
Image & image(int i)
Access image i.
Definition NEBPath.h:329
std::size_t observationIdentityComparisons() const noexcept
bool hasObservation(const Eigen::VectorXd &q) const
bool hasConditionedResidual() const noexcept
bool hyperparametersConverged() const noexcept
LineIntegralGPModel(const InputParameters &parameters, AtomsConfiguration configuration, MassMetric metric, bool pairLocalDirectional=true, bool useHssvd=true)
double posteriorEnergyFunctionalVariance(const std::vector< Eigen::VectorXd > &q, const Eigen::VectorXd &energyWeights)
Eigen::VectorXd observationNoiseDiagonal(const std::vector< Eigen::VectorXd > &q) const
Eigen::MatrixXd posteriorObservationCovariance(const std::vector< Eigen::VectorXd > &q)
std::size_t conditionArchivedAround(const std::vector< Eigen::VectorXd > &targets, std::size_t maximumAddedSites)
std::vector< PotentialEvaluation > observeNativeBatch(const std::vector< Eigen::VectorXd > &q, const LineIntegralNEBBatch &native)
void refitArchivedLocal(const std::vector< Eigen::VectorXd > &targets, const std::vector< Eigen::VectorXd > &required, std::size_t maximumSites)
bool hasFittedObservation(const Eigen::VectorXd &q) const
bool ownsNativeObservation(const Eigen::VectorXd &q) const
void refit(const std::vector< Eigen::VectorXd > &q, const std::vector< PotentialEvaluation > &values)
double nearestNativeDistance(const Eigen::VectorXd &q) const
std::vector< PointVariance > posteriorPointVariance(const std::vector< Eigen::VectorXd > &q)
void refitLocal(const std::vector< Eigen::VectorXd > &q, const std::vector< PotentialEvaluation > &values, std::size_t maximumSites)
GaussianProcessRegression::MeanHessianAction prepareHessian(const Eigen::VectorXd &q)
bool nativeObservation(const Eigen::VectorXd &q, PotentialEvaluation &value) const
std::vector< PotentialEvaluation > evaluate(const std::vector< Eigen::VectorXd > &q)
bool refitWithActiveResidual(const std::vector< Eigen::VectorXd > &q, const std::vector< PotentialEvaluation > &values, std::size_t maximumBackgroundSites, std::size_t maximumAddedSites)
std::size_t addObservations(const std::vector< Eigen::VectorXd > &q, const std::vector< PotentialEvaluation > &values)
bool conditionNativeBatch(const std::vector< Eigen::VectorXd > &q, const std::vector< PotentialEvaluation > &values)
Eigen::VectorXd weighted(const Eigen::VectorXd &x) const
double uniqueImageRadius(const double cell[9]) noexcept
Definition MinImage.h:112
Eigen::VectorXd flatMinimumImageDisplacement(const PairBox *box, const Eigen::VectorXd &from, const Eigen::VectorXd &to)
Definition MinImage.h:259
Half surrogate(GaussianProcessRegression &gp, const Eigen::VectorXd &x, Kind kind, const Options &options)
Half measured(const GradientOracle &oracle, const Eigen::VectorXd &x, Kind kind, const Options &options)
Full central difference of the oracle gradient: 2 d calls.
Models for quantum-path (instanton) searches: arc and tail actions, amplitude continuation.
std::function< std::vector< PotentialEvaluation >( const std::vector< Eigen::VectorXd > &)> LineIntegralNEBBatch
LineIntegralFeasibilityResult restoreLineIntegralInterior(std::vector< Eigen::VectorXd > &trial, std::vector< PotentialEvaluation > &values, const std::vector< PotentialEvaluation > &source, const LineIntegralNEBOptions &options, const LineIntegralNEBBatch &native, std::size_t maximumCorrections=4)
LineIntegralNEBResult optimizeLineIntegralNEB(const std::vector< Eigen::VectorXd > &initial, const LineIntegralNEBBatch &potential, const LineIntegralNEBOptions &options={}, const std::function< void(const LineIntegralNEBResult &)> &retain={}, LineIntegralFIREState *fireState=nullptr, const std::function< bool(const std::vector< Eigen::VectorXd > &)> &earlyStop={})
std::vector< Eigen::VectorXd > lineIntegralSIDPPSeed(neb::NEBPath &physicalBand, int atoms, const std::vector< char > &moving, const MassMetric &metric, double alpha=.33)
LineIntegralNEBResult optimizeLineIntegralString(const std::vector< Eigen::VectorXd > &initial, const LineIntegralNEBBatch &potential, const LineIntegralNEBOptions &options={}, const std::function< void(const LineIntegralNEBResult &)> &retain={}, LineIntegralFIREState *fireState=nullptr)
GPLineIntegralNEBResult optimizeGPLineIntegralNEB(const std::vector< Eigen::VectorXd > &initial, const LineIntegralNEBBatch &potential, Model &model, const GPLineIntegralNEBOptions &options={}, const std::function< void(const GPLineIntegralNEBResult &)> &retain={})
LineIntegralNEBState evaluateLineIntegralNEB(const std::vector< Eigen::VectorXd > &q, const std::vector< PotentialEvaluation > &values, double energy, double spring=1., double contour=10., double hbar=1., LineIntegralAction action=LineIntegralAction::MomentumTrapezoid, bool jctcCompatible=false, double contourRight=0., double actionForceCutoff=1e-4)
FieldMatrixd Coord
Definition Macros.h:35
STL namespace.
Stores configurations of all atoms in the system.
Definition Structures.h:832
Structure of the input parameters. All input parameters are pairs of string names and values.
Definition Structures.h:370
Observation data: energy, gradient and positions.
FieldMatrixd E
Eigen::VectorXd positions
Definition NEBPath.h:40
LineIntegralProposalAcceptance proposalAcceptance