Loading...
Searching...
No Matches
GPNEB.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
22
23#ifndef GPR_NEB_GPNEB_H_
24#define GPR_NEB_GPNEB_H_
25
26#include <Eigen/Dense>
27#include <algorithm>
28#include <array>
29#include <atomic>
30#include <cmath>
31#include <cstdint>
32#include <deque>
33#include <functional>
34#include <iostream>
35#include <limits>
36#include <memory>
37#include <optional>
38#include <random>
39#include <stdexcept>
40#include <string>
41#include <vector>
42
43#include "AcquisitionStrategy.h"
44#include "BandTrace.h"
45#include "NEBPath.h"
47#include "Session.h" // gpr::neb::ActiveLearningSession
48#include "gpr/Enums.h" // gpr::HyperparameterOptimizationMode
49#include "gpr/PublicLayout.h"
53#include "gpr/ml/PhaseTimers.h"
58#include "structures/Structures.h" // gpr::UncertaintyMode
59
60namespace gpr {
61class TrustRadius;
62
63namespace neb {
64
68enum class NEBMode {
69 Standard, // All images evaluated every iteration (no GP)
70 AIE, // All images evaluated on the true potential.
71 OIE, // One Image Evaluated per iteration (GP-accelerated)
72 GP_AIE, // GP inner relaxation, then oracle every interior image.
73 GP_OIE, // GP inner relaxation, then one oracle eval at the selected image.
74 GP_LOCAL, // Band relaxed on a pair-additive spline baseline of the
75 // whole system plus a Cartesian GP residual over the atoms
76 // that carry the path motion; one image measured per round.
77};
78
82using NEBOracle = std::function<std::pair<double, Eigen::VectorXd>(
83 const Eigen::VectorXd& positions)>;
84
90 std::function<std::vector<std::pair<double, Eigen::VectorXd>>(
91 const std::vector<Eigen::VectorXd>& positions)>;
92
101 std::function<ObservationVariance(const Eigen::VectorXd& positions)>;
102
112
114 int image_index = -1;
115 double force_before = std::numeric_limits<double>::quiet_NaN();
116 double force_after = std::numeric_limits<double>::quiet_NaN();
119 bool converged = false;
120};
121
123public:
124 explicit OracleForceProgressTracker(int n_images);
125
126 [[nodiscard]] std::optional<NEBOracleOptimizationOutcome> observe(
127 int image_index, double force_norm);
128
129private:
130 std::vector<double> previous_force_norm_;
131};
132
137
138[[nodiscard]] bool oracleContextRequestsAdaptiveSo3(
139 const NEBOracleEvaluationContext& context);
140
142public:
143 explicit AdaptiveSo3Policy(bool path_geometry_so3_sensitive);
144
145 [[nodiscard]] bool shouldUse(
146 const NEBOracleEvaluationContext& context) const;
147 [[nodiscard]] bool shouldUse(const NEBOracleEvaluationContext& context,
148 double force_noise_rms,
149 double force_tolerance) const;
150
151 [[nodiscard]] static bool endpointPathHasNearLinearBondedTriplet(
152 const Eigen::VectorXd& reactant_positions,
153 const Eigen::VectorXd& product_positions,
154 const std::vector<int>& atomic_numbers,
155 double min_angle_degrees = 165.0);
156
157private:
158 bool path_geometry_so3_sensitive_ = false;
159};
160
166
168[[nodiscard]] double forceComponentRmsForNorm(
169 double component_rms, Eigen::Index degrees_of_freedom,
170 ConvergenceNormType norm) noexcept;
171
182public:
183 AdaptiveSo3SessionPolicy(bool path_geometry_so3_sensitive,
184 double component_force_tolerance,
185 Eigen::Index degrees_of_freedom,
186 ConvergenceNormType convergence_norm);
187
189 const NEBOracleEvaluationContext& context) noexcept;
190 [[nodiscard]] AdaptiveSo3EvaluationMode evaluationMode() const noexcept;
191 void observeForceComponentRms(double component_rms) noexcept;
193 const NEBOracleOptimizationOutcome& outcome) noexcept;
194 [[nodiscard]] bool restartRequested() const noexcept;
195 [[nodiscard]] double triggerForceNoise() const noexcept;
196 void beginAveragedSession() noexcept;
197 [[nodiscard]] bool averagedSession() const noexcept;
198
199private:
200 enum class ProgressState {
201 Probeable,
202 AwaitingOutcome,
203 RawLease,
204 };
205
206 AdaptiveSo3Policy probe_policy_;
207 double component_force_tolerance_ = 0.0;
208 Eigen::Index degrees_of_freedom_ = 0;
210 std::atomic<AdaptiveSo3EvaluationMode> evaluation_mode_{
212 std::atomic<bool> averaged_session_{false};
213 std::atomic<ProgressState> progress_state_{ProgressState::Probeable};
214 std::atomic<bool> restart_requested_{false};
215 std::atomic<double> trigger_force_noise_{0.0};
216 std::atomic<int> current_context_image_{-1};
217 std::atomic<int> trigger_image_{-1};
218};
219
221
226inline constexpr int kMaxConsecutiveOracleFailures = 8;
227
233
242
259 Eigen::Index oracle_batch_chunk = 0;
260 double conv_tol = 0.05; // max force convergence
263 std::optional<ConvergenceNormType> convergence_force_norm;
264 // Live RMS uncertainty streams reported by the oracle. Energy noise floors
265 // the GP likelihood after conversion to variance. Force noise smears the
266 // requested force tolerance in quadrature. The legacy pointer is treated
267 // as energy noise for existing callers.
268 const double* oracle_energy_noise_rms = nullptr;
269 const double* oracle_force_noise_rms = nullptr;
270 const double* oracle_noise_rms = nullptr;
272 std::function<void(const NEBOracleEvaluationContext&)>
274 std::function<void(const NEBOracleOptimizationOutcome&)>
276 // Oracle adapters request a clean training session when their physical
277 // surface changes. GPNEB checks this collectively after oracle batches
278 // and before retaining the returned observations.
279 std::function<bool()> oracle_session_restart_requested;
280 // Path checkpoint for a clean oracle-surface transition. The focal image
281 // identifies the saddle neighborhood whose force stencil conditions the
282 // replacement GP without mixing observations from two oracle surfaces.
283 std::function<void(const NEBOracleSessionCheckpoint&)>
285 int max_outer_iter = 200;
286 // Interpret max_outer_iter as a budget PER IMAGE rather than per run.
287 //
288 // The acquisition oracles roughly one image per outer iteration, so
289 // covering the band once costs nimages outers. An absolute budget
290 // therefore hands a long band less of a chance per image than a short
291 // one: at the same number, 18 images get 2.25x less coverage per image
292 // than 8, and a configuration tuned at one image count is silently
293 // wrong at another. Both Baker boards run so far differ in image count
294 // as well as in the thing they meant to vary, so neither is a
295 // controlled comparison.
296 //
297 // Off by default, because it changes what an existing --max-iterations
298 // means and every recorded board was run under the absolute reading.
299 // --gp-outer-budget-per-image.
301
302 // Spread factor for the density-free half of the band-resolved test.
303 // The band counts as resolved only when its worst image is within this
304 // multiple of its typical image, which is a question whose answer does
305 // not change with image count -- unlike the absolute variance bar,
306 // whose fixed threshold a denser design clears without having learned
307 // more. Non-positive disables the companion test and restores the
308 // absolute bar alone. --gp-variance-spread-factor.
310 int max_inner_iter = 100; // GP inner relaxation iterations
311 // (legacy AIE branch only)
312 double inner_step_size = 0.01; // steepest descent step on GP surface
313 double spring_constant = 5.0; // = k_max for the energy-
314 // weighted variable spring
315 double spring_constant_min = -1.0; // k_min for the variable
316 // spring. Negative => derive
317 // as 0.1 * spring_constant
318 // at NEBPath construction.
319 bool climbing_image = true;
320 // Once climbing-image activates, restrict the convergence
321 // criterion to the climbing-image NEB force only. Matches eOn's
322 // `climbing_image_converged_only = true` semantics in neb_loose.
323 // With this true, AIE/Standard converges in ~half the outer
324 // iterations on the Baker reference set (per-cell parity with
325 // eOn's NEB-CI). When false, the max NEB force across the entire
326 // band must meet conv_tol, which is the academic textbook
327 // convergence but ~2x more outer iters than eOn reports.
329 // An image outside the prediction kernel's support has no posterior
330 // there, so it must not move on a GP mean that has reverted to its
331 // prior. That is a statement about THAT image. With this true the
332 // whole band stops instead, which is only the same thing when no
333 // image is left that could move: a fitted ARD length scale sits well
334 // below the band's own segment spacing (measured 8.6x below it on
335 // baker_15_hocl), so a single blocking image routinely freezes
336 // seventeen that are inside support. When false, blocking images are
337 // deactivated for the pass and the rest relax; the band still stops
338 // outright when EVERY interior image is blocked, since then no
339 // relaxation is available and only an oracle at the blocker helps.
340 // Length scales are not the knob here: raising them above chain
341 // spacing over-smooths and moves the saddle (see the deliberate
342 // exclusion documented on lengthscaleProjectionFloor).
344 // CI activation requires the live band to pass max(ci_activation_tol,
345 // ci_activation_factor * F0) -- the eOn force gate, with the absolute
346 // tolerance arm standing alone when F0 (the initial force baseline) is
347 // unset -- and an interior energy maximum on the current band (a
348 // mountain-pass point). Peak-confidence, triplet-at-current-geometry,
349 // and band-variance checks do not gate activation; that rigor lives on
350 // the accept path instead (force tolerance, mountain-pass, band-maximum,
351 // path ceiling, adjacent-perpendicular MEP certificate).
352 // Defaults match eOn nebmmf's [Nudged Elastic Band] reference settings:
353 // ci_after = 0.5 and ci_after_rel = 0.8.
354 double ci_activation_tol = 0.5;
356
357 // Uncertainty-convergence threshold as a fraction of the GP signal
358 // variance. The effective variance cap is unc_convergence * magnSigma2
359 // when the fitted signal variance is available, and this raw value for
360 // model-free helper calls. GP-OIE uses the corresponding force-posterior
361 // ceiling to select which image the climbing-image marker tracks, not to
362 // gate activation itself; CI-candidate variance can still request an
363 // oracle before activation.
364 double unc_convergence = 0.05;
365
366 // Restricted-variance acquisition (qog0). When true, a proposed
367 // interior whose energy posterior variance exceeds the fitted
368 // likelihood noise (or is NaN/+inf) becomes an oracle target. It
369 // is not AND-ed into proposalTrustCertified: that wiring deadlocks
370 // Baker03 at inner=0 / exit=trust_cert. Default off is
371 // byte-identical to the unflagged path.
373
374 int n_atoms = 0; // for IDPP
380 // Atomic numbers of the band's atoms (frame order). They key the
381 // per-element-pair contact floor of the band domain (the ZBL prior's
382 // repulsion onset); empty falls back to the endpoint scalar bound.
383 std::vector<int> atomic_numbers;
384 // Atoms of the frame the band does not move (fixed in the .con), as flat
385 // positions and atomic numbers. The contact floor holds the moving atoms
386 // off them as well as off each other; empty for a band of every atom.
387 Eigen::VectorXd frozen_positions;
388 std::vector<int> frozen_atomic_numbers;
389 bool use_idpp = false;
390 bool use_sidpp = true; // sequential IDPP for initial path
391 double sidpp_alpha = 0.33;
392 // When use_sidpp is true, swaps the per-image distance-target
393 // interpolation from linear (Smidstrup et al., classic IDPP) to
394 // inverse-distance (Zhu, Thompson, Martinez 2019 geodesic).
395 // Inverse-distance keeps close bonded pairs close for a larger
396 // fraction of the chain index; better suited to bond breaking /
397 // forming reactions where the linear-distance interpolation
398 // overshoots to non-bonded geometries mid-chain.
399 bool sidpp_geodesic = false;
400 // The band engine's step retraction when the path is geodesic: the
401 // per-image internal-coordinate retraction with its Jacobians every
402 // inner iteration (true), or the Cartesian step (false). The path
403 // construction and its per-outer geodesic reparametrization follow
404 // sidpp_geodesic either way. The geodesic path selects the channel:
405 // it keeps a breaking and a forming bond partial together, where the
406 // linear-distance path breaks one before the other forms and the band
407 // relaxes onto separated fragments (Baker 17_claisen: 0.92 eV above
408 // the concerted saddle). The inner steps stay Cartesian by default;
409 // the retraction is what each inner iteration pays for (17_claisen:
410 // 42 s of a 45 s band; 16_oxirane: 12 s per outer at 18 images).
412 // Path-union topology. Gabriel is the default open
413 // diametric-ball graph. Relative neighborhood (Toussaint 1980) is
414 // a strict Gabriel subgraph for A/B; no distance cutoff.
416 // Fit each image-local joint energy-force GP with a soft heat-kernel
417 // covariance derived from the live whole-band path. This is independent
418 // of SIDPP path construction and geodesic NEB step retraction. Mutually
419 // exclusive with the default molecular manifold tensor
420 // (ManifoldEnergyForceKernel on InternalCoordinateChart).
422 std::vector<char> moving_atoms;
423 // ASE-style 3x3 cell, row-major a, b, c. Zeros keep isolated-molecule
424 // Cartesian pair vectors. A nonzero cell wraps InternalCoordinateSet
425 // bonds through the LODE minimage mi_* ABI.
426 std::array<double, 9> cell{};
427 double pair_cutoff = 0.0;
428 double pair_cutoff_width = 0.0;
429 // Geometric (cubic-potential) NEB spring: F_par = k*(d_n^2 -
430 // d_p^2)*tau. Perpendicular spring contribution cancels exactly
431 // under transverse perturbations of dense meshes; K_eff = 4 k s
432 // auto-softens dense chains. Lets the GP-NEB use significantly
433 // more images without the small-spacing + stiff-k explosion.
442 // Default TPE: scores accuracy deficit (force residual + force UQ) with
443 // saddle energy, not IMSPE energy-variance reduction alone (see
444 // oie::oieUtility). IMSPE remains available via --acquisition imspe.
446 // Three-phase dispatch (Phase 1: IMSPE pick; Phase 2: CI image;
447 // Phase 3: dimer via outer_iter_hook). When false, falls through
448 // to the legacy cascade (variance / force-targeted / rejected-
449 // proposal). Kept as an escape hatch until the new path is
450 // benchmarked across the full Baker24 sweep.
452 // Exact IMSPE fixed-theta refresh gate. When > 0 and IMSPE picks
453 // an ordinary chain image, the GP appends the oracle row and
454 // refreshes the posterior at the current hyperparameters when
455 // selected IMSPE gain / trace(K_post_chain) is below this
456 // dimensionless tolerance. Zero disables the gate.
458 // Seed the GP with oracle evaluations at every intermediate image
459 // of the initial path before the outer loop starts. Disabled by
460 // default: the canonical OIE references (Koistinen 2017/2019,
461 // Garrido-Torres 2019) seed only the two endpoints and let the
462 // max-variance acquisition sample the interior one image per round,
463 // which is the source of the oracle-call saving over AIE. Oracling
464 // all n_im-2 intermediates upfront costs an AIE-sized batch before
465 // the loop even starts and builds a large gradient-enhanced
466 // covariance whose per-outer SCG fit dominates wall time at high
467 // image counts (1054-row fit at 36 images). Enable only to
468 // reproduce ChemGP's gp_neb_oie path-seeded start.
469 bool seed_full_chain = false;
470 double ucb_kappa = 1.0;
485 std::shared_ptr<const gpr::WallClockLimit> wall_clock_limit;
503 int evals_per_iter = 1; // OIE: images per outer iteration
504 bool use_triplet = false; // evaluate i-1, i, i+1
505 unsigned int seed = 42;
506 bool verbose = true;
507 // Record a per-outer-iteration band trace (energies, posterior energy
508 // variance, hyperparameters) into GPNEBResult::band_trace. Off by default;
509 // the driver enables it from the unified config Trace.bandHistory field.
510 bool record_band_trace = false;
511 // With record_band_trace, also query the fitted global GP at every image
512 // after each outer iteration (mean, gradient and joint variance): the one
513 // part of the trace the loop does not already hold. On by default so a
514 // config that asks for the band trace keeps the full record; gprn turns
515 // it on only with --trace-band-history.
517 // Additionally retain per-(outer,image) geometries in each trace record so
518 // the driver can emit con-v2 trace frames. Off by default to bound the
519 // result size; enabled together with the con-v2 trace request.
521 // Record a composition-level per-outer snapshot (oracle target, theta,
522 // barrier estimate, which convergence certificates fired, CI index, max
523 // oracle force) into GPNEBResult::composition_trace. Off by default; the
524 // golden-trace regression harness enables it. Deterministic content only.
526 // Prefer the global band GP over an ordinary per-image Cartesian GP. An
527 // eligible CI image carrying a fixed molecular tangent chart owns MMF so
528 // the dimer and its action certificates use the constrained scalar-energy
529 // posterior. Set false to prefer an eligible per-image model generally.
533 std::optional<bool> dimer_analytic_curvature;
537 bool has_initial_path = false;
542 std::vector<double> initial_rest_lengths;
543 // A fidelity transition can carry a measured saddle neighborhood into a
544 // clean session. Outer zero refines this image while its current oracle
545 // stencil remains certified, then normal CI reassignment resumes.
547
548 // ---- GP-OIE-specific knobs (mirror gprd CLI surface) ----------------
549 //
550 // Mirror of the dimer's --uncertainty-mode / --use-psis-laplace /
551 // --use-delta-method / --rff-features chain so the gprn driver can
552 // exercise the same layered MAP / LAPLACE_SLICE / RFF arms as gprd.
553 // Each knob is forwarded one-to-one onto the freshly built
554 // GaussianProcessRegression in the GP-OIE branch (see GPNEB.cpp).
555 //
556 // Each outer iteration trains from the accumulated observations.
557 // Long-lived state belongs to the active-learning session, while
558 // GP model ownership is scoped by explicit model leases.
560 // Posterior variance the acquisition and certificates consume; Latent is
561 // the nugget-free variance every backend agrees on.
564 bool use_psis_laplace = false;
566 bool use_delta_method = false;
567 // Disable output target standardization (raw E/G targets). Paired with the
568 // HS-SVD backend (cond=1) to run normalization-free. --gp-no-output-norm.
570 // Floor the output standardization scale at the energy the gradient
571 // data imply (GaussianProcessRegression::setOutputScaleFloor).
572 bool output_scale_floor = false;
573 // Residual-GP prior mean: train on E/G minus the ZBL repulsive pair prior
574 // and add it back at prediction. The kernel and HS-SVD basis are unchanged.
575 bool use_zbl_prior_mean = false;
576 // Teng/Bao Morse force-field prior mean. Default off.
577 bool use_ff_prior_mean = false;
578 // Learn the likelihood noise sigma2 as an SCG hyperparameter
579 // (Empirical Bayes on the joint [E,F] misfit scale). Honored under
580 // the NLML objective; the noise floor still applies after each
581 // refit, so learning can only raise the noise above the floor.
585 double robust_nu = 0.0;
588 bool fit_step_stop = true;
589 // Virtual derivative observations (Riihimaki-Vehtari conjugate
590 // constraints) at internal-trust clip points: when the inner loop
591 // breaks on drift, pin the posterior toward the prior mean at the
592 // drifted geometry with a conditioning-only observation. Rows never
593 // enter hyperparameter fitting and retire when real data arrives
594 // nearby. --gp-virtual-obs.
596 // Extra noise sigma^2 on virtual rows (raw target units). Soft
597 // against the learned data noise so pins bias without forcing
598 // interpolation. --gp-virtual-obs-noise.
599 double virtual_obs_noise = 0.04;
600 // Anchored cumulative drift budget for the inner loop (EMD from
601 // the outer-start snapshot plus the cumulative travel cap). Off
602 // leaves the kernel-support bound and the per-step certifier as
603 // the only inner trust gates. --gp-drift-budget.
604 bool use_drift_budget = true;
605 // Post-convergence competing-channel survey: surrogate-only NEB
606 // relaxations of perturbed initial bands on the final GP, reported
607 // as [channel-survey] lines. Zero oracle cost, answer unchanged.
608 // --gp-channel-survey.
609 bool channel_survey = false;
610 // Soft geodesic heat prior over the live band under the classic
611 // stack: the session receives the current band as the reference
612 // path each outer, and refits evidence-fit the additive amplitude
613 // (zero optimum = exact atomistic fallback). Derivations:
614 // docs/orgmode/explanation/theory/soft_geodesic_heat_kernel.org.
615 // --gp-geodesic-prior.
616 bool use_geodesic_prior = false;
617 // Adaptive pruning: drop training observations whose exact block
618 // downdate moves no band energy by one likelihood sigma. Shrinks
619 // every later O(n^3) refit. On by default: an unpruned NEB training
620 // set grows without bound and the refit wall grows cubically with it
621 // (05_cyclopropyl: 326 observations, 787 s per outer). The dimer
622 // path bounds itself through EMD dedup; the band path needs this.
623 // --gp-adaptive-prune false restores the unbounded set.
625 // Training-set growth between prune passes, matching the classic
626 // refit cadence. --gp-adaptive-prune-growth.
628 // Hard ceiling on training observations, enforced at prune points by
629 // dropping least-influential rows until the count is under it. Zero
630 // leaves the set unbounded, which is what it is today: the threshold
631 // prune fires only when a row moves the band by less than one
632 // likelihood sigma, and across every Baker cell measured that never
633 // happens, so no [prune] line is ever emitted while the set climbs
634 // past 150. The kernel order is this count times (1 + 3 natoms) and
635 // the append is two O(m^3) steps, so an unbounded count makes the run
636 // quartic in outer iterations and a bounded one makes it linear.
637 // --gp-adaptive-prune-max. Zero leaves the set unbounded, which is the
638 // published run: that command passes 128 itself. A positive value is
639 // opt-in. Rows within one kernel length of the live band are kept.
641 // Admit an acquisition as a training row only when it is farther from
642 // every existing row than the model can resolve,
643 // d = l sqrt(noise/magn) / 2. This is what the dimer path already does,
644 // and the comment above says in as many words that the band path needs
645 // the same.
646 //
647 // On by default, because it costs no information. Every acquisition
648 // reaches the observation archive before any admission decision is
649 // taken, pruning never touches the archive, and per-image models
650 // re-select archived rows into their neighbourhoods. What this bounds
651 // is the ACTIVE set the O(m^3) factorisation runs on, not the record
652 // of what was sampled.
653 //
654 // The rows it declines are the ones closer together than the model can
655 // tell apart at the live noise level, so they carry no curvature
656 // information and only enlarge the factorisation.
657 // --gp-resolution-dedup false restores the unbounded active set.
659
670 std::vector<int> symmetry_permutation;
671
672 // Training-set appends between full hyperparameter refits. The refit
673 // is 91% of an outer iteration and its cost is cubic in the kernel
674 // order, so the cadence is the one speed lever that drops no data:
675 // every row stays, theta is simply re-fitted less often.
676 //
677 // Session defaults this to 5 and nothing ever set it, so it has never
678 // been varied. --gp-refit-cadence.
680 // Chemistry-constrained factorized hyperparameter refits: pairtype
681 // lengthscale ratios fixed from descriptor spreads, global scale +
682 // noise + prefactor solved on a handful of eigendecompositions per
683 // refit instead of an SCG trajectory. --gp-chem-hyper.
685 // Coherent GP model family. Classic profiles (CHEMGP, GPRD_ZBL) override
686 // independent objective/normalization knobs in applyConfigToGP.
687 // The hyperparameter solver remains an independent choice.
688 // EXTENDED leaves those knobs under their own controls.
692 // One compact atomic posterior serves every image and retains all rows.
694 // Additive two-body correction candidate of the active refit.
696 // Statistic of the residual energies the GP reverts to off its data.
698 // GP conditioning knobs forwarded onto the GP-OIE GaussianProcessRegression
699 // via applyConfigToGP. Each replaces a former getenv toggle (no env vars).
700 // use_ls_prior: two-sided chemistry-centred log-Gaussian length-scale prior
701 // (was GPR_LS_PRIOR). principled_nugget: Marchildon-Zingg diagonal nugget
702 // bounding cond(K) <= kappa_max (was GPR_PRINCIPLED_NUGGET). kappa_max:
703 // that cap; 0 (or <=1) selects detail::principledKappaMaxDefault() (was
704 // GPR_KAPPA_MAX).
705 // Default ON: Karvonen–Oates (NLML ill-posed on noiseless stationary
706 // kernels) + Baker trajectory audit (kappa thrash without prior).
707 // Selects the post-convergence index test on the linked librgsaddle.
708 // CLI --rgsaddle-library and RGSADDLE_LIBRARY store this selection.
709 // An empty string keeps the index test idle. RgsaddleClient::load
710 // checks the ABI stamp of the linked library.
711 std::string rgsaddle_library;
714 bool rgsaddle_refine = false;
715 bool use_ls_prior = true;
723 // Floor the per-pair length-scale seed, MAP anchor, and INLA box at
724 // the covalent descriptor scale (see
725 // GaussianProcessRegression::setLengthScaleSeedChemicalFloor).
727 // Default ON: Marchildon–Zingg GE-GP conditioning (Baker kappa audit).
728 bool principled_nugget = true;
729 // Opt-in rigid-motion nullspace deflation for free systems (default off).
731 // Refit on every retained row after a failed subset fit; false keeps the
732 // subset estimator (GaussianProcessRegression::setSubsetFailureEscalation).
734 // Largest first-step distance of a cold rgmin MAP fit in log-hyperparameter
735 // units; 0 leaves the first step to the solver.
737 // True lowers the opening step of the whole cold session so its first
738 // trial moves at most the bound; false caps the first step only.
740 // Transplant the previous MAP fit's curvature record into the next fit
741 // (GaussianProcessRegression::setRgminWarmStart); off opens every fit
742 // afresh at the previous optimum.
743 bool rgmin_warm_start = false;
744 // Hold theta when an append leaves the fit subset as the last converged
745 // fit left it (GaussianProcessRegression::setSkipUnchangedSubsetFit).
747 // Refit on accumulated contradiction evidence of acquired rows rather
748 // than on every row whose posterior spread exceeds the tolerance.
750 double kappa_max = 0.0;
752 // 0 derives the automatic force tolerance from the gradient noise.
753 // Ignored unless rff_features == -1 (automatic selection).
755 // Hutchinson stochastic-trace probes for the hyperparameter gradient
756 // (0 = exact dense-inverse trace). Routed to the GP via applyConfigToGP.
758 // HS-SVD eigen-form solver backend (#87).
759 bool use_hssvd_solver = true;
761 // The struct defaults are the gprn CLI defaults: chop at 1e-6 and
762 // take the dual route (nobs x nobs instead of N x N). The host
763 // eigensolver is Eigen's self-adjoint solver.
764 double hssvd_dual_chop_tol = 1e-6;
775 bool local_tier_classic = false;
780 // Distributed factorization; applied process-wide before the first
781 // factorization (see gpr::linalg::configureDistributedFactorization).
784 // Cancellation-free posterior variance reductions; applied process-wide
785 // (see gpr::linalg::configureStablePosteriorVariance).
787 // Scale-free MAP stationarity gate for fixed-theta posterior refresh:
788 // skip hyperparameter optimization when ||H^{-1} g_new|| is below this
789 // tolerance at the current MAP parameters. Zero disables the gate.
791 // Use the GP optimizer's displacement tolerance as the fixed-theta
792 // stationarity threshold.
794 // Solver axis for hyperparameter_mode == RGMIN_OPT. Ignored
795 // otherwise. Set from --hyperparameter-mode rgmin:<method>.
796 // RGMIN_LBFGS is 3. An int keeps this header free of rgmin.h and
797 // keeps the member in builds that do not link rgmin.
799 bool rgmin_method_set = false;
809 // Rows the hyperparameter optimizer fits on (farthest-point subset);
810 // 0 = every row. Canonical gprd: 10.
812 // The anneal stage before the local hyperparameter fit: box-ensemble
813 // work units (0 = off), chains, and the fit period.
814 bool gp_anneal_stage = false;
818 // Posterior variances conditioned on the nearest N training
819 // configurations only (0 = the full solve).
821 // 0 disables the capped step.
822 int max_inner_iter_gp = 0; // GP-OIE inner relaxation budget. Nonpositive
823 // selects condition-driven stopping; positive
824 // values impose an explicit iteration cap.
826 true; // Query a trust-projected step along the current true NEB
827 // force before considering band reparameterization.
829 true; // Reparametrize the band once when the OIE outer map reaches a
830 // fixed point without a CI certificate and measured-force
831 // recovery cannot add information.
833 true; // Reparametrize after retained local OIE path motions when the
834 // redistributed band already has exact oracle support.
877 bool band_leak_bound = false;
882 bool band_stall = true;
883 // -- GP_LOCAL: local Cartesian polish between true-force band steps --
884 // Atoms whose endpoint displacement reaches this fraction of the largest
885 // endpoint displacement form the polished set.
886 double gp_local_fraction = 0.1;
887 // Moving atoms within this distance of a selected atom join the set
888 // (0 keeps the displacement selection alone).
889 double gp_local_radius = 0.0;
890 // Retained observations in the local model; older ones leave first.
892 // Largest displacement of a polished image from the band step that
893 // preceded the polish, per image, in the local subspace (Angstrom).
894 double gp_local_trust = 0.3;
895 // Inner quasi-Newton iterations of one polish.
897 // Marginal-likelihood iterations per outer refit (0 keeps the seed).
899 // Polish exit: local band force below this multiple of conv_tol.
901 // Once the substrate force of a round is under the round tolerance,
902 // hold the far atoms still and finish the local atoms on the pairs
903 // that touch them alone.
904 bool gp_local_phase = true;
905 // Rebuild of the residual model on the refitted baseline, with the
906 // substrate Hessian, every this many outers (0 never rebuilds).
908 // Standard deviation of the energy and gradient channels.
909 double gp_local_noise = 1e-3;
910 // Pair-additive baseline: cutoff of the spline radial function in
911 // Angstrom (0 disables the baseline) and its knot spacing.
913 // 0 derives the spacing from the force tolerance.
915 // Trust radius of one substrate step in the far subspace (Angstrom).
916 double gp_local_far_trust = 0.5;
917 // Image displacement that refreshes its substrate Hessian (Angstrom).
918 double gp_local_far_refresh = 0.05;
919 // Measure every interior image of the seeded band before the first
920 // relaxation; false starts from the endpoints alone.
922 // Images measured per relaxation round: the worst unmeasured ones.
924 // Rounds per extra image in the batch (0 keeps the batch fixed), and
925 // the largest batch.
928 // Bands with at most this many interior images measure all of them
929 // each round.
931 // Scale the local block of the band step by the inverse diagonal of
932 // the baseline Hessian.
933 bool gp_local_jacobi = false;
934 // Neighbour radius that grows the local set after three stalled rounds
935 // (0 never grows it).
937 // Halve a band step that raises the largest surrogate force by more
938 // than half.
940 // Keep the band quasi-Newton memory across outer iterations until the
941 // models are refitted.
943 // Add the local GP residual on top of the baseline.
944 bool gp_local_residual = true;
945 // Baseline pairs beyond this distance are summed once per round and
946 // held as a linear model (0 evaluates every pair on every step); a
947 // positive refresh distance also resums them inside a round once an
948 // atom moved that far.
951 // Substrate-step and local-polish cycles per outer iteration.
953 // Measure every image after each polish instead of one image per
954 // outer iteration.
955 bool gp_local_sweep = false;
956 // Internal. A local band that stopped above the tolerance is searched
957 // once more with substrate atoms sprung by the pair-model load. Not a
958 // user setting: the first search leaves it false.
960 double lbfgs_max_move = 0.1; // GP-OIE band L-BFGS max per-atom
961 // Cartesian displacement, Angstrom.
962 // Unweighted: not eOn's mass-weighted
963 // Matter cap. The numeric default
964 // matches the eOn nebmmf reference
965 // config [Optimizer] max_move = 0.1.
966 // eOn's general optimizer default is
967 // 0.2, but the NEB chain L-BFGS is
968 // run with a 2x tighter cap because
969 // single-step Cartesian jumps past
970 // ~0.1 flip sub-saddle tangents on
971 // small molecules and trigger
972 // angle-reset cascades.
973 // Values >0.2 trigger a one-shot
974 // warning on the first band step
975 // (RgLbfgs or InternalLbfgs)
976 // because the L-BFGS quadratic-model
977 // trust region rarely holds past that.
978 int lbfgs_memory = 20; // GP-OIE band L-BFGS memory.
979
1000
1002 static constexpr bool isRgsaddleEngine(BandEngineKind kind) noexcept
1003 {
1004 return kind == BandEngineKind::Rgsaddle ||
1008 }
1010 double lbfgs_inverse_curvature = 0.01; // Initial inverse Hessian scale.
1011 double lbfgs_finite_difference = 1e-6; // Auto-scale curvature probe.
1012 bool lbfgs_auto_scale = true;
1019 static constexpr double kDefaultLbfgsNewtonAgreement = 2.0;
1021
1025 static void requireLbfgsNewtonAgreement(double value)
1026 {
1027 if (std::isfinite(value) && value >= 0.0) return;
1028 throw std::invalid_argument(
1029 "band.lbfgs.newton_agreement must be finite and non-negative");
1030 }
1031
1034 static bool parseBandEngineKind(const std::string& name,
1035 BandEngineKind& out) noexcept
1036 {
1037 if (name.empty()) {
1039 return true;
1040 }
1041 if (name == "internal-lbfgs") {
1043 return true;
1044 }
1045 if (name == "rg-lbfgs") {
1047 return true;
1048 }
1049 if (name == "rg-fire") {
1051 return true;
1052 }
1053 if (name == "rg-saddle") {
1055 return true;
1056 }
1057 if (name == "rg-saddle-rtr") {
1059 return true;
1060 }
1061 if (name == "rg-saddle-ode12r") {
1063 return true;
1064 }
1065 if (name == "rg-saddle-ode12r-exp") {
1067 return true;
1068 }
1069 return false;
1070 }
1071
1072 // Sketched L-BFGS history sub-sampling. Gower-Richtarik (2015)
1073 // sketch-and-project view: at each two-loop call, sub-sample
1074 // m_sketch < memory pairs from the curvature history uniformly at
1075 // random, build the inverse-Hessian apply from the sketched subset
1076 // only. Equivalent to a {0,1}-sketch matrix S_k with m_sketch
1077 // unit-rows selecting which (s_i, y_i) participate.
1078 //
1079 // 0 (default) disables sketching and uses the full history (=
1080 // standard L-BFGS). Values in [1, memory) activate sketching. The
1081 // RNG is seeded once via lbfgs_sketch_seed.
1082 //
1083 // Use case: post-CI-activation runs where the L-BFGS history
1084 // contains stale pairs from before the gradient field
1085 // discontinuously changed. Random refresh decontaminates the H
1086 // approximation probabilistically; cheaper than a full reset.
1088 uint64_t lbfgs_sketch_seed = 1;
1089 // Nystrom-sketched chain Hessian for the L-BFGS H0 slot
1090 // (Frangella-Tropp-Udell SIMAX 2023, doi:10.1137/21M1466244).
1091 // 0 = scalar gamma * I (legacy). 1 <= k <= chain_dof activates the
1092 // rank-k Nystrom approximation, rebuilt once per outer iter from
1093 // k Hessian-vector products computed via FD on the band-force
1094 // functor; column-distributed across MPI ranks for true strong
1095 // scaling on the HvP phase. See SketchedHessianH0.h.
1097 double lbfgs_sketch_h0_eps = 1e-3;
1098
1099 // ---- Path reparametrization ----------------------------------
1100 // Compatibility fields for callers that still populate the legacy
1101 // periodic / spacing-triggered controls. GP-NEB reparametrizes only
1102 // after a retained hook motion changes the band geometry; the
1103 // operation is evaluated in the same active inverse-distance metric
1104 // as geodesic SIDPP and resets L-BFGS state because curvature pairs
1105 // are indexed against the replaced parameterization.
1107 double reparam_tol = -1.0;
1108
1109 // ---- eOn GP-NEB inner-mode ------------------------------------
1110 // Match the eOn GPSurrogateJob reference (client/GPSurrogateJob.cpp
1111 // + client/NudgedElasticBand.cpp:200-423): the inner LBFGS loop
1112 // runs to NEB-convergence on the current GP with NO per-step
1113 // variance/trust rejection, and the worst-image picker is plain
1114 // argmax over per_image_var (no IMSPE/UCB/triplet/CI cascade).
1115 // Default off so existing callers see no behaviour change; turn
1116 // on to disable the per-step rejection inside the inner loop and
1117 // collapse the acquisition picker to max-variance.
1118 bool eon_inner_mode = false;
1119
1120 double inner_conv_tol = 0.05; // GP-OIE inner-loop GP-force tol:
1121 // matches the outer fmax so the
1122 // inner relaxation does not run
1123 // tighter than the outer
1124 // convergence requires.
1125 double gp_tol_divisor = 10.0; // GP-OIE adaptive inner tolerance
1126 // divisor near convergence. Far
1127 // from convergence the effective
1128 // divisor relaxes toward 2; the
1129 // fixed inner_conv_tol remains the
1130 // lower bound.
1131
1132 // Relative CI-residual ratio for the MMF hook trigger
1133 // (shouldRunOciMmfHookOnCurrentTrueCi): the hook may open when
1134 // ci_force <= inner_unc_relative * max_band_force while both sit
1135 // above conv_tol. The inner relaxation itself carries no
1136 // variance-based halt -- posterior variance says nothing about
1137 // force-direction error; excursion control is the geometric EMD
1138 // trust/drift certifier plus the internal step trust.
1139 // 0 disables the relative trigger term.
1141
1142 // Best-path-restart guard (CatLearn ML-NEB; analog of
1143 // CatLearn best-path rewind (activelearning.py check_fmax): track the
1144 // chain at the lowest whole-band max force seen. If a later outer's
1145 // force is strictly worse than that held best (same observable, no
1146 // multiplicative threshold), rewind before the next inner relaxation.
1147
1148 // ---- Warm-start + pruning (mirror AtomicDimer.cpp:1218-1233) ----
1149 // num_bigiter_initparam: number of outer iters where the GP
1150 // hyperparameter seeds are re-derived from target and descriptor
1151 // statistics. After this, setHyperparameters is
1152 // called with update_*_param=false so SCG warm-starts from the
1153 // previous fit instead of re-seeding. Without warm-start, every
1154 // outer iter blows away the previous fit and SCG lands in a
1155 // different local minimum, producing wildly different GP forces
1156 // across iters (max_gp_F observed swinging 0.05 -> 173 -> 0.28).
1157 // Default 1: re-init only at outer=0; warm-start from then on.
1159
1161 // The adaptive trust machinery can throttle inner relaxation before the
1162 // surrogate reaches a useful band optimum. Off by default; the calibrated
1163 // fixed radius below is the certificate.
1165 // Empirical gradient-fidelity radius: strong disagreement at a measured
1166 // row contracts by 1/4; strong agreement permits expansion by two. The
1167 // shared trust-region component supplies its numerical floor, and the
1168 // physical cap is max(trust_adaptive_floor,
1169 // trust_adaptive_A/sqrt(n_atoms)). The exploration schedule's trust_t_min
1170 // does not constrain contraction.
1171 bool rho_trust = false;
1172 double trust_radius = 0.5;
1173 double trust_adaptive_A = 1.3;
1175 double trust_t_min = 0.15;
1176 double trust_delta_explore = 0.35;
1179 // Scale-free trust region (TuRBO/LABCAT fraction-of-spread). When enabled
1180 // the EMD trust radius is anchored to scalefree_tau * median pairwise EMD
1181 // spread of the training set, so tau stays a dimensionless O(1) knob that
1182 // auto-rescales per system. Replaces the former GPR_SCALEFREE_TRUST /
1183 // GPR_SCALEFREE_TAU env toggles (no env vars).
1184 //
1185 // Default OFF: enabling it makes the converged barrier depend on the image
1186 // count. At high resolution the closely spaced images drive the
1187 // acquisition/CI into high-variance extrapolation; the surrogate forces
1188 // blow up (max_gp_F ~ 80, max_var ~ 20) and the climbing image hops between
1189 // spurious maxima, so 03_h2co converges to 3.112 at 8 images but ~0 at 18.
1190 // The saddle is a property of the PES, not the discretisation. The
1191 // validated tracked baseline never enabled this; keep it off until the
1192 // trust radius is made resolution-invariant.
1193 bool scalefree_trust = false;
1194 double scalefree_tau = 0.5;
1195
1196 // GP-OIE handoff bridge: caller supplies a callback that builds the
1197 // (parameters, atoms_config) pair the GP needs to .initialize().
1198 // Kept as a callback rather than holding a copy of those structures
1199 // so the lightweight GPNEBConfig stays POD-ish; the callback is
1200 // populated by main_neb.cpp from the loaded .con frame. The GP modes
1201 // (GP_OIE, GP_AIE) require it and gpNEB throws std::invalid_argument
1202 // when it is empty; the modes without a GP ignore it.
1203 std::function<void(gpr::InputParameters&, gpr::AtomsConfiguration&)>
1205
1210
1222 using OuterIterHook = std::function<void(
1223 NEBPath& path, int ci_image_idx, int outer_iter,
1224 ActiveLearningSession& session, bool& converged, bool trap_detected)>;
1226
1231 std::function<void(const NEBPath& path, int ci_image_idx,
1232 int outer_iter, ActiveLearningSession& session)>;
1234
1240 std::function<bool(const NEBPath& path, int ci_image_idx,
1241 int outer_iter, double ci_force)>;
1243
1247 using OieInnerHandoffPriority = std::function<bool(
1248 const NEBPath& path, int ci_image_idx, int outer_iter, double ci_force,
1249 double max_chain_energy_variance, double posterior_variance_threshold,
1250 bool current_chain_certificate, bool planned_current_chain_or_ci,
1251 const ActiveLearningSession* session)>;
1253
1257 using OieFixedImage = std::function<int(const NEBPath& path,
1258 int ci_image_idx, int outer_iter)>;
1260
1264 const NEBPath& path, int ci_image_idx, int outer_iter)>;
1266
1272};
1273
1274namespace detail {
1275
1280std::vector<Eigen::Index> selectLocalPolishDofs(
1281 const Eigen::VectorXd& initial, const Eigen::VectorXd& final_state,
1282 double fraction, double radius);
1283
1284class BandRelaxationEngine;
1285
1288[[nodiscard]] std::pair<double, Eigen::VectorXd> evaluateOieOraclePosition(
1289 const Eigen::VectorXd& positions, const NEBOracle& oracle);
1290
1291[[nodiscard]] OieFixedImageLease resolveOieFixedImageLease(
1292 const GPNEBConfig& config, const NEBPath& path, int ci_image_idx,
1293 int outer_iter);
1294
1297[[nodiscard]] OieFixedImageLease arbitrateOieRecoveryBandOwnership(
1298 OieFixedImageLease local_recovery_lease, int ci_idx,
1299 int adjacent_recovery_ci_idx, int adjacent_recovery_target_idx);
1300
1303class OieRecoveryStencilAnchor {
1304public:
1306 bool update(const NEBPath& path, const OieFixedImageLease& lease);
1307
1309 bool reanchor(const NEBPath& path, const OieFixedImageLease& lease);
1310
1311 [[nodiscard]] bool active() const noexcept
1312 {
1313 return owner_image_ >= 0;
1314 }
1315 [[nodiscard]] int ownerImage() const noexcept
1316 {
1317 return owner_image_;
1318 }
1319
1321 bool restore(NEBPath& path);
1322
1324 void applyActiveImageMask(std::vector<char>& active_images,
1325 int n_images) const;
1326
1330 void clear();
1331
1332private:
1333 int owner_image_ = -1;
1334 std::vector<Eigen::VectorXd> positions_;
1335 bool committed_handoff_pending_ = false;
1336 bool release_after_restore_ = false;
1337};
1338
1339struct OieRecoveryGrowthTrial {
1340 int image_index = -1;
1341 std::vector<Eigen::VectorXd> source_stencil_positions;
1342 Eigen::VectorXd positions;
1343 double energy = std::numeric_limits<double>::quiet_NaN();
1344 Eigen::VectorXd gradient;
1345 Eigen::VectorXd source_force_vector;
1346 Eigen::VectorXd trial_force_vector;
1347 double source_force = std::numeric_limits<double>::infinity();
1348 double trial_force = std::numeric_limits<double>::infinity();
1349
1350 [[nodiscard]] bool improvesForce() const noexcept;
1351};
1352
1353[[nodiscard]] std::optional<OieRecoveryGrowthTrial> makeOieRecoveryGrowthTrial(
1354 const NEBPath& path, int image_index, const Eigen::VectorXd& positions,
1355 double energy, const Eigen::VectorXd& gradient);
1356
1357bool commitOieRecoveryGrowthTrial(NEBPath& path,
1358 const OieRecoveryGrowthTrial& trial);
1359
1371bool admitRecoveryGrowthObservation(
1372 ActiveLearningSession& session, const policy::TrainingPolicy* policy,
1373 int image_index, const Eigen::VectorXd& positions, double energy,
1374 const Eigen::VectorXd& gradient, bool admitted_this_outer_step);
1375
1376[[nodiscard]] int resolveOieFixedImage(const GPNEBConfig& config,
1377 const NEBPath& path, int ci_image_idx,
1378 int outer_iter);
1379
1380[[nodiscard]] int resolveOieLocalRecoveryImage(
1381 int fixed_image, int ci_candidate_idx,
1382 bool ci_candidate_posterior_confident);
1383
1384[[nodiscard]] bool oieLocalRecoveryOwnsReplaceableWork(
1385 int n_images, int local_recovery_image,
1386 const std::vector<char>& image_evaluated,
1387 const std::vector<char>& image_observed_current);
1388
1389[[nodiscard]] bool oieLocalRecoverySuppressesReplaceableWork(
1390 bool local_recovery_owns_replaceable_work,
1391 bool allow_replaceable_acquisition = false);
1392
1393[[nodiscard]] bool shouldAcquireOieOwnerModelGrowth(bool model_growth_required);
1394
1395[[nodiscard]] int selectOieRecoveryCandidateCertificateImage(
1396 int n_images, int recovery_owner, bool model_growth_required,
1397 int candidate_image, bool candidate_handover_certified);
1398
1399[[nodiscard]] bool shouldDeferOieFixedPointRecovery(
1400 bool local_recovery_owns_replaceable_work, bool oracle_target_selected);
1401
1404struct OieFixedPointHistory {
1405 std::vector<Eigen::VectorXd> resolutions;
1406 std::vector<Eigen::VectorXd> mmf_grants;
1407
1408 void observeTraining(Eigen::Index row_count, std::uint64_t revision);
1409
1410private:
1411 Eigen::Index row_count_ = -1;
1412 std::uint64_t revision_ = 0;
1413};
1414
1415[[nodiscard]] bool shouldActivateClimbingImage(const GPNEBConfig& config,
1416 bool ci_active, int outer,
1417 double band_force, double f0,
1418 double ci_candidate_variance);
1419
1420[[nodiscard]] bool shouldEvaluateClimbingImageCandidate(
1421 const GPNEBConfig& config, bool ci_active, int outer, double band_force,
1422 double f0, double ci_candidate_variance,
1423 std::optional<double> signal_variance);
1424
1425[[nodiscard]] bool shouldSampleCurrentChainForCiActivation(
1426 const GPNEBConfig& config, bool ci_active, int outer, double band_force,
1427 double f0);
1428
1429struct OieChainCertificateTarget {
1430 double deficit = 0.0;
1431 int image_index = -1;
1432};
1433
1434[[nodiscard]] OieChainCertificateTarget selectCurrentOieChainCertificateTarget(
1435 bool saddle_handoff_needs_ci_oracle, int ci_idx,
1436 bool climbing_image_converged_only, const NEBPath& path,
1437 const std::vector<double>& posterior_energy_variance,
1438 double force_tolerance, double variance_threshold,
1439 int adjacent_recovery_target_idx = -1,
1440 double adjacent_recovery_deficit = 0.0);
1441
1446[[nodiscard]] std::vector<int> pathAwareTopologyImageIndices(
1447 const NEBPath& path);
1448
1449[[nodiscard]] std::shared_ptr<const gpr::geometry::InternalCoordinateSet>
1450makeMolecularInternalCoordinatesForPath(const NEBPath& path,
1451 const GPNEBConfig& config);
1452
1453[[nodiscard]] std::shared_ptr<const gpr::geometry::InternalCoordinateSet>
1454makeGeodesicInternalCoordinatesForPath(const NEBPath& path,
1455 const GPNEBConfig& config);
1456
1460[[nodiscard]] std::shared_ptr<const gpr::geometry::InternalCoordinateChart>
1461makeImageInternalCoordinateChart(
1462 std::shared_ptr<const gpr::geometry::InternalCoordinateSet> internals,
1463 const Eigen::VectorXd& positions);
1464
1468bool attachImageManifoldChart(
1469 ActiveLearningSession& session, int i,
1470 const std::shared_ptr<const gpr::geometry::InternalCoordinateSet>&
1471 internals,
1472 const Eigen::VectorXd& positions);
1473
1477bool attachGlobalManifoldChart(
1478 ActiveLearningSession& session,
1479 const std::shared_ptr<const gpr::geometry::InternalCoordinateSet>&
1480 internals,
1481 const Eigen::VectorXd& positions);
1482
1485bool attachGlobalManifoldChart(
1486 gpr::GaussianProcessRegression& gp, const gpr::Observation* training_obs,
1487 const std::shared_ptr<const gpr::geometry::InternalCoordinateSet>&
1488 internals,
1489 const Eigen::VectorXd& positions);
1490
1494void attachClassicGlobalManifoldChart(const GPNEBConfig& config,
1495 const NEBPath& path,
1496 ActiveLearningSession* session,
1497 gpr::GaussianProcessRegression& gp,
1498 const gpr::Observation& training_obs);
1499
1500[[nodiscard]] int selectCurrentChainPriorityForOieOracle(
1501 bool ci_active, int ci_idx, bool ci_activation_needs_oracle,
1502 int ci_candidate_idx, double ci_certificate_deficit,
1503 double chain_certificate_deficit,
1504 bool saddle_handoff_needs_ci_oracle = false,
1505 bool ci_candidate_handover_needs_oracle = false,
1506 bool ci_convergence_needs_oracle = false, int chain_certificate_idx = -1,
1507 bool accepted_drift_pending = false);
1508
1509[[nodiscard]] double oieSaddleCertificateDeficit(
1510 int saddle_candidate_idx, const NEBPath& path,
1511 const std::vector<double>& posterior_energy_variance, double conv_tol,
1512 double variance_threshold);
1513
1514[[nodiscard]] double oieSaddleForceConfirmationDeficit(int saddle_candidate_idx,
1515 const NEBPath& path,
1516 double conv_tol);
1517
1518[[nodiscard]] bool shouldRequestOieSaddleForceConfirmation(
1519 double predicted_force, double convergence_force_tolerance);
1520
1525[[nodiscard]] double oieSaddleForceLowerConfidenceBound(
1526 double predicted_force, double gradient_variance_trace, double kappa);
1527
1528[[nodiscard]] double oieSaddleNeighborhoodCertificateDeficit(
1529 int saddle_center_idx, const NEBPath& path,
1530 const std::vector<double>& posterior_energy_variance, double conv_tol,
1531 double variance_threshold);
1532
1533[[nodiscard]] bool shouldExpandOciHandoffStencil(
1534 bool ci_active, bool saddle_handoff_needs_ci_oracle,
1535 double local_certificate_deficit);
1536
1537[[nodiscard]] std::vector<int> selectOciHandoffStencilOracleTargets(
1538 int ci_idx, int n_images, const std::vector<char>& image_evaluated,
1539 const std::vector<char>& image_observed_current);
1540
1541[[nodiscard]] std::vector<int> selectOciHandoffCertificateOracleTargets(
1542 int ci_idx, const NEBPath& path, const ActiveLearningSession& session);
1543
1544[[nodiscard]] std::vector<int> selectOieActivationTripletOracleTargets(
1545 int ci_candidate_idx, int n_images,
1546 const std::vector<char>& image_evaluated,
1547 const std::vector<char>& image_observed_current,
1548 const std::vector<double>& posterior_energy_variance);
1549
1550[[nodiscard]] double oieCurrentTrueForceCertificate(
1551 const NEBPath& path, const std::vector<char>& image_evaluated,
1552 const std::vector<char>& image_observed_current);
1553
1554struct OieBandForceSummary {
1555 double max_neb_force = 0.0;
1556 double max_measured_neb_force = std::numeric_limits<double>::quiet_NaN();
1557 int measured_images = 0;
1558 int interior_images = 0;
1559};
1560
1562[[nodiscard]] OieBandForceSummary summarizeOieBandForces(const NEBPath& path);
1563
1564[[nodiscard]] bool shouldRetainOieRestartSnapshot(
1565 bool ci_active, const char* inner_exit, int accepted_inner_steps,
1566 double relaxed_gp_force, bool measured_reparam_restart_protected = false);
1567
1568[[nodiscard]] bool shouldProtectMeasuredProposalRestart(
1569 bool candidate_applied, bool improved_before_refit,
1570 bool improved_after_refit) noexcept;
1571
1572[[nodiscard]] bool shouldScheduleOiePathMotionReparam(const GPNEBConfig& config,
1573 bool path_moved);
1574[[nodiscard]] bool shouldScheduleOieHookReparam(const GPNEBConfig& config,
1575 bool hook_moved_chain);
1576[[nodiscard]] bool shouldQueueOieHookReparamCandidate(
1577 bool proposal_moves_band, bool all_candidate_images_observed) noexcept;
1578
1579[[nodiscard]] bool gpInnerIterationAllowed(int inner_iteration,
1580 int configured_limit);
1581
1582[[nodiscard]] bool oieAttemptWallBudgetExhausted(
1583 double elapsed_seconds, double longest_outer_seconds,
1584 double budget_seconds) noexcept;
1585
1586[[nodiscard]] bool shouldStopOieInnerAtCoordinateResolution(
1587 const Eigen::VectorXd& accepted_positions,
1588 const Eigen::VectorXd& proposed_positions) noexcept;
1589
1590struct OieInnerHandoffPrecheck {
1591 bool handoff_data_ready = false;
1592 bool current_chain_certificate = false;
1593 bool current_saddle_stencil_certificate = false;
1594 bool soft_quiet_blocked_after_reject = false;
1595 bool trusted_recovery_active = false;
1596 bool trusted_retry_progress_pending = false;
1597 bool oie_quiet_handoff_stalled = false;
1598 bool rejected_seed_replay = false;
1599 bool planned_current_chain_or_ci = false;
1600 double ci_force = std::numeric_limits<double>::quiet_NaN();
1601 double handoff_force_threshold = std::numeric_limits<double>::quiet_NaN();
1602};
1603
1604[[nodiscard]] bool shouldBypassOieInnerForHandoff(
1605 const OieInnerHandoffPrecheck& state, int accepted_inner_steps);
1606
1607struct OieLowerBarrierEvidence {
1608 bool true_pes_local_max = false;
1609 bool adjacent_mep_checked = false;
1610 bool adjacent_mep = false;
1611 bool second_order = false;
1612
1613 [[nodiscard]] bool independentlyCertified() const noexcept
1614 {
1615 return second_order ||
1616 (true_pes_local_max && adjacent_mep_checked && adjacent_mep);
1617 }
1618};
1619
1620enum class OieLowerBarrierAction {
1621 KeepCurrent,
1622 CompleteCurrentCertificate,
1623 RestoreCertifiedBest,
1624};
1625
1626[[nodiscard]] const char* oieLowerBarrierActionName(
1627 OieLowerBarrierAction action) noexcept;
1628
1631[[nodiscard]] double oieContinuationMerit(bool ci_active,
1632 bool climbing_image_converged_only,
1633 const NEBPath& path);
1634
1641[[nodiscard]] double oieContinuationReward(double best_merit_at_pull,
1642 double merit_now) noexcept;
1643
1644struct OieContinuationArm {
1645 int pulls = 0;
1646 double reward_sum = 0.0;
1647 double reward_sum_sq = 0.0;
1648};
1649
1652[[nodiscard]] double sampleOieContinuationReward(const OieContinuationArm& arm,
1653 std::mt19937_64& rng);
1654
1656class OieContinuationRewards {
1657public:
1658 [[nodiscard]] bool pending() const noexcept
1659 {
1660 return selected_ >= 0;
1661 }
1662 [[nodiscard]] const OieContinuationArm& arm(bool restore) const noexcept
1663 {
1664 return restore ? restore_ : continue_;
1665 }
1666 [[nodiscard]] bool begin(bool restore, double measured_merit) noexcept;
1667 void observe(double measured_merit) noexcept;
1668
1669private:
1670 OieContinuationArm continue_, restore_;
1671 int selected_ = -1;
1672 double best_ = std::numeric_limits<double>::infinity();
1673 double reference_ = std::numeric_limits<double>::quiet_NaN();
1674};
1675
1685[[nodiscard]] OieLowerBarrierAction selectOieLowerBarrierAction(
1686 bool have_best_climb_positions, int best_climb_ci_idx,
1687 double best_climb_barrier, double best_climb_force, double current_barrier,
1688 const OieLowerBarrierEvidence& current_evidence,
1689 double posterior_spread = std::numeric_limits<double>::quiet_NaN());
1690
1693[[nodiscard]] bool shouldAcceptOieCiOnlyConvergence(
1694 bool pending_band_action_active, bool ci_active,
1695 bool climbing_image_converged_only, bool ci_force_is_measured,
1696 bool saddle_energy_ok, bool below_path_ceiling, double ci_force,
1697 double model_noise_tol);
1698
1704[[nodiscard]] bool shouldUseOieBestClimbRestart(
1705 bool ci_active, bool have_best_climb_positions, double best_climb_force,
1706 double latest_restart_force = std::numeric_limits<double>::infinity(),
1707 int best_climb_ci_idx = -1,
1708 double best_climb_barrier = std::numeric_limits<double>::infinity(),
1709 int latest_climb_ci_idx = -1,
1710 double latest_climb_barrier = std::numeric_limits<double>::infinity());
1711
1712[[nodiscard]] bool shouldPreferLatestOieClimbRestart(
1713 bool ci_active, bool have_latest_climb_positions,
1714 bool latest_climb_from_drift);
1715
1716enum class OieRelaxationRestartSource {
1717 CurrentPath,
1718 BestPath,
1719 LatestEqual,
1720 LatestClimb,
1721 BestClimb,
1722};
1723
1728[[nodiscard]] OieRelaxationRestartSource selectOieRelaxationRestartSource(
1729 bool frozen_sweep, bool use_best_climb, bool use_best_path,
1730 bool use_latest_climb, bool use_latest_equal);
1731
1732[[nodiscard]] double oieRestartReferenceForce(bool ci_active,
1733 bool have_best_climb_positions,
1734 double best_path_force,
1735 double best_climb_force);
1736
1737[[nodiscard]] bool shouldRetainOieHookRestartSnapshot(bool ci_active,
1738 bool hook_ran,
1739 bool hook_converged);
1740
1741[[nodiscard]] bool shouldPromoteOieHookRestartSnapshot(
1742 bool hook_ran, bool hook_converged, bool hook_left_chain_moved);
1743
1746[[nodiscard]] bool shouldRestoreRejectedOieHookConvergence(bool hook_converged,
1747 bool hook_certified);
1748
1749[[nodiscard]] bool shouldRetainRejectedOieHookSaddleForRethread(
1750 bool hook_converged, bool hook_certified, bool saddle_energy_ok,
1751 bool adjacent_mep_ok);
1752
1753[[nodiscard]] bool shouldSkipOieInnerAfterRejectedHookConvergence(
1754 bool hook_converged, bool hook_certified);
1755
1756[[nodiscard]] bool shouldSkipOieInnerAfterRejectedHookAttempt(
1757 bool hook_ran, bool hook_added_training, bool hook_converged,
1758 bool hook_certified, bool hook_moved_chain);
1759
1760[[nodiscard]] bool shouldRetainOieBestClimbSnapshot(
1761 bool ci_active, double candidate_force, double best_climb_force,
1762 bool true_saddle_energy_certificate,
1763 double candidate_barrier = std::numeric_limits<double>::infinity(),
1764 double best_climb_barrier = std::numeric_limits<double>::infinity());
1765
1766[[nodiscard]] bool isOieCurrentCiForceAnchor(bool ci_active,
1767 bool oracle_updates_current_path,
1768 int oracle_idx, int ci_idx,
1769 int max_force_idx);
1770
1771[[nodiscard]] double oieClimbMeritForce(
1772 bool ci_active, bool oracle_updates_current_path, int oracle_idx,
1773 int ci_idx, double ci_force, double whole_band_force,
1774 int whole_band_force_idx, bool convergence_uses_ci_only);
1775
1776[[nodiscard]] bool shouldUseCiOnlyClimbMerit(bool mmf_handoff_snapshot,
1777 bool convergence_uses_ci_only);
1778
1779[[nodiscard]] bool isTruePesSaddleEnergyCandidate(double saddle_energy,
1780 double reactant_energy,
1781 double product_energy);
1782
1788[[nodiscard]] bool hasTruePesSaddleEnergyCertificate(
1789 const NEBPath& path, int saddle_index, double force_quiet_tol,
1790 bool force_quiet_adjacent = false);
1791
1795[[nodiscard]] double ciPerpendicularForceResidual(const NEBPath& path,
1796 int image_idx);
1797
1798[[nodiscard]] Eigen::VectorXd ciPerpendicularForceVector(const NEBPath& path,
1799 int image_idx);
1800
1813[[nodiscard]] double chordTangentPerpendicularLeak(const NEBPath& path,
1814 int image_idx,
1815 double tangential_force);
1816
1828[[nodiscard]] bool bandDiscretizationCertificateHolds(const NEBPath& path,
1829 double force_tol,
1830 bool bound_leak = false);
1831
1838struct BandDiscretizationCertificate {
1839 bool evaluated = false;
1840 bool holds = false;
1841 double leak_max = 0.0;
1842 double residual_max = 0.0;
1843 int worst_image = -1;
1844};
1845[[nodiscard]] BandDiscretizationCertificate bandDiscretizationCertificateReport(
1846 const NEBPath& path, double force_tol, bool bound_leak = false);
1847
1848[[nodiscard]] bool bandPathCertificateHolds(const NEBPath& path,
1849 double band_force_scale);
1850
1860[[nodiscard]] std::vector<double> chordLeakSpringRestLengths(
1861 const NEBPath& path, double force_tol);
1862
1869[[nodiscard]] EigenMatrix resamplePathByRestLengths(
1870 const NEBPath& path, int n_images_total,
1871 const std::vector<double>& rest_lengths);
1872
1880[[nodiscard]] EigenMatrix insertMidpointsAroundClimbingImage(
1881 const NEBPath& path, std::vector<double>* rest_lengths,
1882 int subdivisions = 1);
1883
1889[[nodiscard]] int ridgeSubdivisionsForLeak(double leak, double force_tol);
1890
1891[[nodiscard]] int selectLargestFailingCiAdjacentPerpendicularForce(
1892 const NEBPath& path, int ci_idx, double force_tol);
1893
1896[[nodiscard]] int selectLargestFailingBandPerpendicularForce(
1897 const NEBPath& path, int ci_idx, double force_tol);
1898
1902[[nodiscard]] int selectOieAdjacentMepRecoveryTarget(
1903 bool ci_active, bool local_recovery_owner, const NEBPath& path, int ci_idx,
1904 double energy_force_tol, double mep_force_tol);
1905
1906[[nodiscard]] bool ciAdjacentPerpendicularForceConverged(const NEBPath& path,
1907 int ci_idx,
1908 double conv_tol);
1909
1913[[nodiscard]] bool bandPerpendicularForceConverged(const NEBPath& path,
1914 double force_tol);
1915
1916[[nodiscard]] bool hasOieHookConvergenceCertificate(const NEBPath& path,
1917 int saddle_index,
1918 double energy_force_tol,
1919 double mep_force_tol,
1920 bool climbing_only = false);
1921
1922[[nodiscard]] std::string oieHookConvergenceRejectionDiagnostic(
1923 const NEBPath& path, int saddle_index, double energy_force_tol,
1924 double mep_force_tol, bool climbing_only = false);
1925
1926[[nodiscard]] bool shouldAcceptOieHookConvergence(
1927 bool hook_converged, const NEBPath& path, int saddle_index,
1928 double energy_force_tol, double mep_force_tol, bool climbing_only = false);
1929
1930[[nodiscard]] bool oieHookChemistryQuietAtTolerance(bool hook_converged,
1931 bool saddle_energy_ok,
1932 double ci_force,
1933 double effective_force_tol);
1934
1935class GlobalLBFGSOptimizer;
1936
1937struct OieClimbingImageMarkerRefreshState {
1938 int previous_ci_idx = -1;
1939 int current_ci_idx = -1;
1940 bool changed = false;
1941};
1942
1945void setClimbingImageReassignConfidence(double confidence,
1946 double energy_noise_sigma) noexcept;
1947
1948void refreshOieClimbingImageMarker(bool ci_active, NEBPath& path);
1949
1950void refreshOieClimbingImageMarker(
1951 bool ci_active, NEBPath& path,
1952 const std::vector<double>& posterior_energy_variance,
1953 double confidence_width);
1954
1955void refreshOieClimbingImageMarker(
1956 bool ci_active, NEBPath& path,
1957 const std::vector<double>& posterior_energy_variance,
1958 double confidence_width, double variance_ceiling);
1959
1960void refreshOieClimbingImageMarkerFromPosteriorCandidate(
1961 bool ci_active, NEBPath& path, int posterior_candidate_idx,
1962 const std::vector<double>& posterior_energy_variance,
1963 double confidence_width, double variance_ceiling, int previous_ci_idx = -1);
1964
1965[[nodiscard]] OieClimbingImageMarkerRefreshState
1966refreshOieClimbingImageMarkerAndResetHistory(bool ci_active, NEBPath& path,
1967 BandRelaxationEngine& optimizer);
1968
1969[[nodiscard]] OieClimbingImageMarkerRefreshState
1970refreshOieClimbingImageMarkerAndResetHistory(bool ci_active, NEBPath& path,
1971 BandRelaxationEngine& optimizer,
1972 int protected_ci_idx);
1973
1978[[nodiscard]] bool bandBracketsSaddle(const NEBPath& path);
1979
1980[[nodiscard]] int activeClimbingMarkerIndex(const NEBPath& path);
1981
1988[[nodiscard]] inline int climbingStopImage(const NEBPath& path)
1989{
1990 const int climbing = activeClimbingMarkerIndex(path);
1991 if (climbing > 0 && climbing < path.numImages() - 1) return climbing;
1992 return path.highestEnergyImageIndex();
1993}
1994
1995[[nodiscard]] int selectOieClimbingImageIndex(bool ci_active,
1996 const NEBPath& path);
1997
1998[[nodiscard]] int selectOieClimbingImageIndex(
1999 bool ci_active, const NEBPath& path,
2000 const std::vector<double>& posterior_energy_variance,
2001 double confidence_width);
2002
2003[[nodiscard]] int selectOieClimbingImageIndex(
2004 bool ci_active, const NEBPath& path,
2005 const std::vector<double>& posterior_energy_variance,
2006 double confidence_width, double variance_ceiling);
2007
2008[[nodiscard]] bool restoreOiePathPositions(
2009 NEBPath& path, const std::vector<Eigen::VectorXd>& positions,
2010 bool preserve_climbing_marker);
2011
2014[[nodiscard]] bool restoreOieMeasuredClimb(
2015 NEBPath& path, const std::vector<Eigen::VectorXd>& positions,
2016 int climbing_index, double energy, const Eigen::VectorXd& gradient);
2017
2018[[nodiscard]] double effectivePosteriorVarianceThreshold(
2019 const GPNEBConfig& config, std::optional<double> signal_variance);
2020
2021[[nodiscard]] double updateInitialForceBaseline(double current_baseline,
2022 double oracle_force,
2023 bool ci_active);
2024
2025[[nodiscard]] double oieActivationOracleForce(
2026 bool oracle_updates_current_path, double oracle_target_force,
2027 bool current_ci_oracle_updates_path, double current_ci_oracle_force);
2028
2029[[nodiscard]] bool posteriorVarianceExceedsTolerance(double max_variance,
2030 double threshold);
2031
2032[[nodiscard]] bool posteriorVarianceConverged(double max_variance,
2033 double threshold);
2034
2035struct OieBandPosteriorReadiness {
2036 bool energy_resolved = true;
2037 bool force_resolved = true;
2038 int acquisition_image = -1;
2039 double max_energy_ratio = 0.0;
2040 double max_force_ratio = 0.0;
2041 std::vector<double> per_image_deficit;
2042
2043 [[nodiscard]] bool resolved() const noexcept
2044 {
2045 return energy_resolved && force_resolved;
2046 }
2047};
2048
2052[[nodiscard]] int selectOieInnerProposalAcquisitionImage(
2053 const OieBandPosteriorReadiness& readiness) noexcept;
2054
2065[[nodiscard]] OieBandPosteriorReadiness assessOieBandPosteriorReadiness(
2066 const std::vector<ObservationVariance>& per_image_variance,
2067 double energy_variance_threshold, double force_tolerance,
2068 double likelihood_noise_variance,
2069 const std::vector<char>& image_observed_current = {});
2070
2073[[nodiscard]] double sanitizePosteriorVariance(double variance);
2074
2079[[nodiscard]] bool posteriorVarianceWithinNoiseFloor(double variance,
2080 double noise_variance);
2081
2084[[nodiscard]] bool chainPosteriorVarianceWithinNoiseFloor(
2085 const std::vector<double>& posterior_energy_variance, int n_images,
2086 double noise_variance);
2087
2088[[nodiscard]] double oieTerminalSweepReferenceForce(
2089 double pre_oracle_relaxed_force, double post_oracle_force,
2090 bool has_true_force_eval);
2091
2092[[nodiscard]] bool oieCiPosteriorForceCertificate(bool ci_active,
2093 double current_ci_force,
2094 double ci_variance,
2095 double conv_tol,
2096 double variance_threshold);
2097
2098[[nodiscard]] double effectiveModelNoiseTolerance(const GPNEBConfig& config);
2099
2101[[nodiscard]] double forwardBarrierEnergy(const NEBPath& path,
2102 int saddle_image);
2103
2104void throwIfOracleSessionRestartRequested(
2105 const std::function<bool()>& restart_requested);
2106
2107[[nodiscard]] bool publishOracleSessionPathCheckpoint(
2108 const GPNEBConfig& config, const NEBPath& path, int focal_image_index = -1);
2109
2110enum class OracleSessionBootstrapScope {
2111 FocalStencil,
2112 FullPath,
2113};
2114
2115[[nodiscard]] int bootstrapOracleSessionFromCheckpoint(
2116 const NEBOracleSessionCheckpoint& checkpoint, NEBOracle& oracle,
2117 const std::function<void(const NEBOracleEvaluationContext&)>&
2118 evaluation_context,
2119 ActiveLearningSession& session,
2120 OracleSessionBootstrapScope scope =
2121 OracleSessionBootstrapScope::FocalStencil);
2122
2123[[nodiscard]] bool activateOracleTransitionFocalClimbingImage(
2124 const GPNEBConfig& config, NEBPath& path,
2125 const ActiveLearningSession& session, int outer_iteration);
2126
2127[[nodiscard]] bool modelNoiseRaisesConvergenceTolerance(
2128 const GPNEBConfig& config);
2129
2130[[nodiscard]] const double* oracleEnergyNoiseRmsPtr(
2131 const GPNEBConfig& config) noexcept;
2132
2133[[nodiscard]] bool outerConvergenceCertifiedByTolerance(
2134 const GPNEBConfig& config, const NEBPath& path, bool ci_active,
2135 double convergence_force);
2136
2137[[nodiscard]] double imspeRelativeGain(double selected_score,
2138 double chain_trace);
2139
2142[[nodiscard]] double oracleBatchForceResolution(
2143 const gpr::Observation& acquired, ConvergenceNormType force_norm,
2144 double force_tolerance);
2145
2146[[nodiscard]] bool shouldUseFixedThetaRefreshFromImspe(
2147 const GPNEBConfig& config, AcquisitionType acquisition,
2148 double selected_score, double chain_trace, bool reinit_hyperparams,
2149 bool frozen_sweep, bool rejected_proposal,
2150 bool oracle_updates_current_path);
2151
2152[[nodiscard]] bool shouldUseFixedThetaRefreshAfterAcquisition(
2153 const GPNEBConfig& config, AcquisitionType acquisition,
2154 double selected_imspe_score, double imspe_chain_trace,
2155 bool reinit_hyperparams, bool frozen_sweep, bool rejected_proposal,
2156 bool oracle_updates_current_path);
2157
2158[[nodiscard]] bool shouldUseFixedThetaRefreshForOracleBatch(
2159 const GPNEBConfig& config, AcquisitionType acquisition,
2160 std::size_t oracle_batch_size, double selected_imspe_score,
2161 double imspe_chain_trace, bool reinit_hyperparams, bool frozen_sweep,
2162 bool rejected_proposal, bool oracle_updates_current_path,
2163 bool model_boundary_evidence, bool recovery_model_growth = false);
2164
2172[[nodiscard]] bool shouldRunOciMmfHookOnCurrentTrueCi(
2173 bool ci_active, int hook_ci_idx, int oracle_idx,
2174 bool oracle_updates_current_path, int n_images, bool hook_ci_evaluated,
2175 int max_force_idx,
2176 double ci_force = std::numeric_limits<double>::infinity(),
2177 double max_band_force = 0.0, double conv_tol = 0.0,
2178 double max_chain_energy_variance = std::numeric_limits<double>::infinity(),
2179 double posterior_variance_threshold = 0.0, double inner_unc_relative = 0.0,
2180 bool controller_requests_handoff = false,
2181 bool adjacent_mep_certificate_failed = false);
2182
2183[[nodiscard]] bool shouldPrioritizeCurrentCiOracleForOciMmfHandoff(
2184 bool controller_requests_handoff, bool ci_active, int ci_idx, int n_images,
2185 double ci_force, double conv_tol, double max_chain_energy_variance,
2186 double posterior_variance_threshold);
2187
2190[[nodiscard]] ObservationVariance jointObservationVariance(
2191 const gpr::Observation& variance, Eigen::Index row = 0);
2192
2195[[nodiscard]] std::vector<ObservationVariance> evaluateOieGlobalVariances(
2196 const std::vector<char>& prediction_required,
2197 const std::vector<char>& force_certification_required,
2198 const std::function<void(const std::vector<char>&,
2199 std::vector<ObservationVariance>&)>& evaluate);
2200
2203[[nodiscard]] ObservationVariance jointForceCertificationVariance(
2204 const ObservationVariance& reported_variance,
2205 double reported_variance_calibration);
2206
2207[[nodiscard]] double observationGradientVarianceTrace(
2208 const ObservationVariance& variance);
2209
2210[[nodiscard]] bool shouldFlagGpMinTrap(double max_gp_force, double oracle_force,
2211 double conv_tol, double inner_conv_tol,
2212 const char* inner_exit = nullptr);
2213
2214[[nodiscard]] bool shouldFlagMmfHandoffTrap(double gp_force,
2215 double oracle_force,
2216 double handoff_threshold);
2217
2218[[nodiscard]] bool shouldInvalidateOieClimbRestartSnapshot(
2219 bool ci_active, bool oracle_updates_current_path, int oracle_idx,
2220 int ci_idx, double gp_force, double oracle_force, double conv_tol,
2221 double inner_conv_tol, const char* inner_exit = nullptr);
2222
2223[[nodiscard]] std::optional<double> oieBbForceStepLength(
2224 const Eigen::VectorXd& previous_position,
2225 const Eigen::VectorXd& previous_force,
2226 const Eigen::VectorXd& current_position,
2227 const Eigen::VectorXd& current_force);
2228
2229class MeasuredBandRecoveryState {
2230public:
2231 explicit MeasuredBandRecoveryState(int n_images);
2232
2233 [[nodiscard]] bool observeAcceptedStep(
2234 int image_index, const Eigen::VectorXd& previous_position,
2235 const Eigen::VectorXd& previous_force,
2236 const Eigen::VectorXd& current_position,
2237 const Eigen::VectorXd& current_force);
2238
2239 [[nodiscard]] double inverseCurvature(int image_index,
2240 double fallback) const noexcept;
2241
2242 void reset() noexcept;
2243
2244private:
2245 std::vector<double> inverse_curvature_;
2246};
2247
2248[[nodiscard]] std::optional<double> measuredSecantBacktrackFraction(
2249 const Eigen::VectorXd& source_position, const Eigen::VectorXd& source_force,
2250 const Eigen::VectorXd& trial_position, const Eigen::VectorXd& trial_force);
2251
2252enum class MeasuredResidualStepAction {
2253 Accept,
2254 Backtrack,
2255 Reject,
2256};
2257
2258struct MeasuredResidualStepAssessment {
2259 MeasuredResidualStepAction action = MeasuredResidualStepAction::Reject;
2260 std::optional<double> backtrack_fraction;
2261};
2262
2263[[nodiscard]] MeasuredResidualStepAssessment assessMeasuredResidualStep(
2264 const Eigen::VectorXd& source_position, const Eigen::VectorXd& source_force,
2265 double source_residual, const Eigen::VectorXd& trial_position,
2266 const Eigen::VectorXd& trial_force, double trial_residual,
2267 bool trial_certificate);
2268
2269struct AdjacentMepTrialAssessment {
2270 MeasuredResidualStepAssessment step;
2271 Eigen::VectorXd perpendicular_force;
2272 double residual = std::numeric_limits<double>::quiet_NaN();
2273 bool saddle_energy_certificate = false;
2274};
2275
2276class AdjacentMepRecoveryState {
2277public:
2278 [[nodiscard]] bool arm(const NEBPath& path, int ci_idx, int target_idx,
2279 double force_tol);
2280 void clear() noexcept;
2281
2282 [[nodiscard]] bool activeFor(const NEBPath& path, int ci_idx) const;
2283 [[nodiscard]] int ciIndex() const noexcept
2284 {
2285 return ci_idx_;
2286 }
2287 [[nodiscard]] int targetImage() const noexcept
2288 {
2289 return target_idx_;
2290 }
2291 [[nodiscard]] double sourceResidual() const noexcept
2292 {
2293 return source_residual_;
2294 }
2295 [[nodiscard]] double deficit() const noexcept;
2296
2297 [[nodiscard]] bool stageTrial(const NEBPath& path);
2298 [[nodiscard]] bool setPendingTrialPosition(Eigen::VectorXd positions);
2299 [[nodiscard]] bool backtrackPendingTrial(double fraction);
2300 void clearPendingTrial() noexcept
2301 {
2302 pending_trial_position_.resize(0);
2303 }
2304 [[nodiscard]] bool hasPendingTrial() const noexcept
2305 {
2306 return pending_trial_position_.size() > 0;
2307 }
2308 [[nodiscard]] const Eigen::VectorXd& pendingTrialPosition() const noexcept
2309 {
2310 return pending_trial_position_;
2311 }
2312
2313 [[nodiscard]] bool restoreSource(NEBPath& path) const;
2315 [[nodiscard]] bool restoreTargetSource(NEBPath& path) const;
2316 [[nodiscard]] AdjacentMepTrialAssessment assessPendingTrial(
2317 const NEBPath& source_path, double trial_energy,
2318 const Eigen::VectorXd& trial_gradient, double energy_force_tol) const;
2319 [[nodiscard]] AdjacentMepTrialAssessment observePendingTrial(
2320 const NEBPath& source_path, double trial_energy,
2321 const Eigen::VectorXd& trial_gradient, double energy_force_tol);
2322 [[nodiscard]] bool commitPendingTrial(
2323 NEBPath& path, double trial_energy,
2324 const Eigen::VectorXd& trial_gradient);
2325 [[nodiscard]] std::optional<double> takeMeasuredInverseCurvature() noexcept
2326 {
2327 auto curvature = measured_inverse_curvature_;
2328 measured_inverse_curvature_.reset();
2329 return curvature;
2330 }
2331
2332private:
2333 int ci_idx_ = -1;
2334 int target_idx_ = -1;
2335 double force_tol_ = 0.0;
2336 double source_residual_ = std::numeric_limits<double>::quiet_NaN();
2337 Eigen::VectorXd ci_position_;
2338 std::vector<Image> source_path_images_;
2339 Image source_image_;
2340 Eigen::VectorXd source_tangent_;
2341 Eigen::VectorXd source_perpendicular_force_;
2342 Eigen::VectorXd pending_trial_position_;
2343 std::optional<double> measured_inverse_curvature_;
2344
2345 void retainMeasuredInverseCurvature(const Eigen::VectorXd& trial_gradient);
2346};
2347
2348bool applyOieMeasuredClimbingImageStep(
2349 NEBPath& path, int image_idx, ActiveLearningSession& session,
2350 NEBOracle& oracle, int& oracle_calls, bool project_rotations,
2351 double conv_tol, double max_radius, double& radius,
2352 bool surrogate_measured_non_descent, int outer, bool verbose,
2353 const std::array<double, 9>& cell,
2354 const gpr::geometry::ElementPairContactFloor& contact_floor,
2355 bool* marginal_progress = nullptr);
2356
2357bool applyOieBbForceCorrection(NEBPath& path, int image_idx,
2358 const Eigen::VectorXd& previous_position,
2359 const Eigen::VectorXd& previous_force,
2360 const Eigen::VectorXd& current_force,
2361 double conv_tol, double max_step);
2362
2363[[nodiscard]] bool shouldApplyOieTrueForceBbCorrection(
2364 bool ci_active, bool current_ci_oracle_updates_path, int current_ci_idx,
2365 int previous_ci_idx, double current_ci_force, double previous_ci_force,
2366 bool true_saddle_energy_certificate);
2367
2368[[nodiscard]] double oieGpInnerTolerance(const GPNEBConfig& config,
2369 double smallest_oracle_force,
2370 bool ci_active);
2371
2372[[nodiscard]] double oieGpForceErrorTolerance(const GPNEBConfig& config,
2373 double inner_tolerance,
2374 double oracle_force,
2375 double predicted_force,
2376 double force_error);
2377
2378// A measured force discrepancy sets a local stopping margin throughout
2379// one surrogate relaxation, including trial geometries without oracle rows.
2380// A different climbing image cannot inherit another image's discrepancy.
2381class OieMeasuredForceMargin {
2382public:
2383 void observe(int image_index, double oracle_force, double force_error);
2384 double tolerance(const GPNEBConfig& config, int image_index,
2385 double inner_tolerance, double predicted_force) const;
2386
2387private:
2388 int image_index_ = -1;
2389 double oracle_force_ = 0.0;
2390 double force_error_ = 0.0;
2391};
2392
2393[[nodiscard]] double oieGpRelaxationForce(const GPNEBConfig& config,
2394 bool ci_active, double chain_force,
2395 double ci_force,
2396 bool ci_saddle_energy_certified);
2397
2398[[nodiscard]] bool oieGpInnerForceConverged(bool climbing_only_phase,
2399 double relaxation_force,
2400 double chain_force,
2401 double relaxation_tolerance,
2402 double chain_tolerance);
2403
2404struct OieRelaxableForceMeasure {
2405 double max_force = 0.0;
2406 double climbing_force = std::numeric_limits<double>::infinity();
2407};
2408
2409[[nodiscard]] OieRelaxableForceMeasure measureOieRelaxableForces(
2410 const NEBPath& path, int ci_image_idx, int fixed_image_idx);
2411
2412[[nodiscard]] bool isImageWithinTrainingTrust(
2413 const Eigen::VectorXd& positions, const gpr::Observation& training_obs,
2414 const gpr::TrustRadius& trust, double trust_threshold);
2415
2416[[nodiscard]] bool clipImageToOuterTrust(Eigen::VectorXd& positions,
2417 const gpr::Observation& training_obs,
2418 const gpr::TrustRadius& trust,
2419 double trust_threshold);
2420
2421[[nodiscard]] bool imageWithinPredictionKernelSupport(
2422 const Eigen::VectorXd& positions,
2423 const gpr::AtomsConfiguration& atoms_config,
2424 const gpr::Observation& global_observations,
2425 const gpr::FieldMatrixd& global_length_scale,
2426 const gpr::Observation* local_observations = nullptr,
2427 const gpr::FieldMatrixd* local_length_scale = nullptr);
2428
2429[[nodiscard]] bool imageWithinPredictionKernelSupport(
2430 const Eigen::VectorXd& positions,
2431 const gpr::AtomsConfiguration& atoms_config,
2432 const gpr::Observation& global_observations,
2433 const gpr::SexpatCF& global_kernel,
2434 const gpr::Observation* local_observations = nullptr,
2435 const gpr::SexpatCF* local_kernel = nullptr);
2436
2437[[nodiscard]] bool precisionPoolEnergyGradient(
2438 double global_energy, const Eigen::VectorXd& global_gradient,
2439 double global_variance, double local_energy,
2440 const Eigen::VectorXd& local_gradient, double local_variance,
2441 double& pooled_energy, Eigen::VectorXd& pooled_gradient);
2442
2444[[nodiscard]] bool imageWithinSurrogateTrust(
2445 const Eigen::VectorXd& positions,
2446 const gpr::AtomsConfiguration& atoms_config,
2447 const gpr::Observation& global_observations,
2448 const gpr::SexpatCF& global_kernel,
2449 const gpr::Observation& trust_observations, const gpr::TrustRadius& trust,
2450 std::optional<double> measured_radius);
2451
2452// Each outer may move an atom by at most one configured band step. One
2453// probe inside the force tolerance does not open the geometric trust
2454// radius: that single pass is what let a later outer take a full
2455// trust-radius walk.
2456[[nodiscard]] inline bool surrogateOuterStepExceeded(double max_atom_motion,
2457 double max_step)
2458{
2459 if (!(max_step > 0.0) || !std::isfinite(max_step) ||
2460 !std::isfinite(max_atom_motion)) {
2461 return false;
2462 }
2463 return max_atom_motion >= max_step;
2464}
2465
2466[[nodiscard]] bool precisionPoolVariance(double global_variance,
2467 double local_variance,
2468 double& pooled_variance);
2469
2472[[nodiscard]] bool allInteriorImagesObserved(const NEBPath& path,
2473 const gpr::Observation& obs,
2474 int climbing_image = -1);
2475
2476class GlobalLBFGSObjective;
2477
2478[[nodiscard]] bool acceptTrustCertifiedProposal(
2479 GlobalLBFGSObjective& objective, const Eigen::VectorXd& accepted_positions,
2480 const std::function<bool()>& trust_at_current, int max_bisections = 12,
2481 Eigen::VectorXd* rejected_positions = nullptr,
2482 const std::function<bool(Eigen::VectorXd&)>& project_to_trust = {},
2483 const std::function<double()>& certified_step = {});
2484
2488[[nodiscard]] bool acceptPosteriorCertifiedProposal(
2489 GlobalLBFGSObjective& objective, const Eigen::VectorXd& accepted_positions,
2490 const std::function<bool()>& posterior_resolved_at_current,
2491 Eigen::VectorXd* rejected_positions = nullptr);
2492
2493[[nodiscard]] bool shouldProbeRejectedProposalVariance(bool step_certified,
2494 bool drift_break);
2495
2496[[nodiscard]] bool shouldLatchRejectedProposalAcquisition(bool step_certified,
2497 bool drift_break);
2498
2499[[nodiscard]] int selectAcceptedDriftCurrentChainPriority(
2500 bool step_certified, bool drift_break, int drift_image,
2501 int n_images) noexcept;
2502
2503[[nodiscard]] bool isAcceptedDriftCurrentChainPriorityPending(
2504 int drift_image, int n_images, const std::vector<char>& image_evaluated,
2505 const std::vector<char>& image_observed_current) noexcept;
2506
2507[[nodiscard]] bool cumulativeTrustTravelExceeded(
2508 const std::vector<double>& accumulated_travel,
2509 const std::vector<double>& proposed_step_travel, double trust_threshold);
2510
2511[[nodiscard]] int selectUnobservedAcquisitionIndex(
2512 const std::vector<double>& scores, const std::vector<char>& eligible,
2513 const std::vector<Eigen::VectorXd>& positions,
2514 const gpr::Observation& training_obs, int current_idx);
2515
2519[[nodiscard]] double expectedImprovementScore(double mu, double mu_best,
2520 double sigma);
2521
2524[[nodiscard]] int selectExpectedImprovementImage(
2525 const std::vector<double>& energies,
2526 const std::vector<double>& energy_variances,
2527 const std::vector<char>& eligible);
2528
2533[[nodiscard]] bool shouldStopOieInnerForExpectedImprovement(
2534 int accepted_inner_steps, int ei_image, double ei_score,
2535 double energy_variance_threshold = 0.0);
2536
2537struct ProposalAcquisitionTarget {
2538 int image_index = -1;
2539 Eigen::VectorXd positions;
2540
2541 [[nodiscard]] explicit operator bool() const
2542 {
2543 return image_index > 0 && positions.size() > 0;
2544 }
2545
2546 void clear()
2547 {
2548 image_index = -1;
2549 positions.resize(0);
2550 }
2551};
2552
2553[[nodiscard]] ProposalAcquisitionTarget prepareOieBoundaryAcquisition(
2554 ProposalAcquisitionTarget target, const gpr::Observation& training_obs,
2555 const gpr::TrustRadius& trust, double trust_threshold);
2556
2561[[nodiscard]] ProposalAcquisitionTarget
2562selectRestrictedVarianceAcquisitionTarget(
2563 const Eigen::VectorXd& proposal_positions, Eigen::Index image_dof,
2564 const std::vector<double>& posterior_energy_variance, double noise_variance,
2565 const gpr::Observation& training_obs);
2566
2567struct OieInnerProposalDecision {
2568 bool accept = true;
2569 ProposalAcquisitionTarget acquisition;
2570};
2571
2575[[nodiscard]] bool usesClassicOieRelaxation(
2576 AcquisitionType acquisition) noexcept;
2577
2581class OiePendingBandAction {
2582public:
2583 [[nodiscard]] bool stage(AcquisitionType acquisition,
2584 const Eigen::VectorXd& source_positions,
2585 const Eigen::VectorXd& trial_positions,
2586 Eigen::Index image_dof);
2587 void clear();
2588
2589 [[nodiscard]] bool active() const noexcept;
2590 [[nodiscard]] bool sourceMatches(const Eigen::VectorXd& positions) const;
2591 [[nodiscard]] const Eigen::VectorXd& sourcePositions() const noexcept;
2592 [[nodiscard]] const Eigen::VectorXd& trialPositions() const noexcept;
2593 [[nodiscard]] Eigen::Index imageDof() const noexcept;
2594
2595private:
2596 Eigen::VectorXd source_positions_;
2597 Eigen::VectorXd trial_positions_;
2598 Eigen::Index image_dof_ = 0;
2599};
2600
2601struct OieBandActionAcquisition {
2602 ProposalAcquisitionTarget target;
2603 double force_variance_reduction = std::numeric_limits<double>::quiet_NaN();
2604 double target_force_variance = std::numeric_limits<double>::quiet_NaN();
2605};
2606
2609[[nodiscard]] OieBandActionAcquisition selectOieBandActionAcquisition(
2610 const Eigen::VectorXd& action_positions, Eigen::Index image_dof,
2611 const EigenMatrix& posterior_covariance,
2612 const gpr::Observation& training_obs, double noise_variance);
2613
2617[[nodiscard]] OieInnerProposalDecision decideOieInnerProposal(
2618 const OieBandPosteriorReadiness& readiness,
2619 const Eigen::VectorXd& proposal_positions, Eigen::Index image_dof,
2620 const gpr::Observation& training_obs);
2621
2622[[nodiscard]] bool shouldSkipOieInnerForPendingAcquisition(
2623 const ProposalAcquisitionTarget& pending_acquisition,
2624 bool candidate_applied = false, int current_band_acquisition_image = -1,
2625 bool force_posterior_unresolved = false,
2626 bool activation_stencil_pending = false);
2627
2631[[nodiscard]] bool shouldPreemptOieInnerForPosteriorAction(
2632 AcquisitionType acquisition, bool ci_active, bool force_posterior_resolved,
2633 const ProposalAcquisitionTarget& posterior_action) noexcept;
2634
2639[[nodiscard]] bool shouldSkipOieInnerForUnresolvedForcePosterior(
2640 bool force_resolved, int current_band_acquisition_image) noexcept;
2641
2642using ReparametrizationTrustDistance =
2643 std::function<double(int, const Eigen::VectorXd&)>;
2644
2645struct ReparametrizationSupportMetric {
2646 double limit = 0.0;
2647 ReparametrizationTrustDistance evaluate;
2648};
2649
2650using ReparametrizationObservationPredicate =
2651 std::function<bool(int, const Eigen::VectorXd&)>;
2652
2655[[nodiscard]] bool hasMeasuredReparametrizationNeed(const NEBPath& path,
2656 int protected_image = -1);
2657
2660[[nodiscard]] bool shouldLaunchFixedPointReparametrization(
2661 const NEBPath& path, const std::vector<Eigen::VectorXd>& proposed_positions,
2662 const std::vector<ReparametrizationSupportMetric>& support_metrics,
2663 int protected_image = -1);
2664
2667[[nodiscard]] std::vector<Eigen::VectorXd> proposeReparametrizedBand(
2668 const NEBPath& accepted_path, const GPNEBConfig& config,
2669 int anchor_index = -1);
2670
2671[[nodiscard]] ProposalAcquisitionTarget selectUnobservedReparametrizationTarget(
2672 const std::vector<Eigen::VectorXd>& proposed_positions,
2673 const std::vector<ReparametrizationSupportMetric>& support_metrics,
2674 const ReparametrizationObservationPredicate& is_observed);
2675
2676[[nodiscard]] ProposalAcquisitionTarget selectUnobservedBandProposalTarget(
2677 const std::vector<Eigen::VectorXd>& proposed_positions, int preferred_image,
2678 const std::vector<ReparametrizationSupportMetric>& support_metrics,
2679 const ReparametrizationObservationPredicate& is_observed);
2680
2681[[nodiscard]] ProposalAcquisitionTarget
2682selectUnsupportedReparametrizationTarget(
2683 const std::vector<Eigen::VectorXd>& proposed_positions,
2684 const std::vector<ReparametrizationSupportMetric>& support_metrics);
2685
2686[[nodiscard]] ProposalAcquisitionTarget
2687selectUnsupportedReparametrizationTarget(
2688 const std::vector<Eigen::VectorXd>& proposed_positions,
2689 double trust_threshold,
2690 const ReparametrizationTrustDistance& distance_to_training);
2691
2692[[nodiscard]] ProposalAcquisitionTarget
2693selectUnsupportedReparametrizationTarget(
2694 const std::vector<Eigen::VectorXd>& proposed_positions,
2695 const gpr::Observation& training_obs, const gpr::TrustRadius& trust,
2696 double trust_threshold);
2697
2698enum class OieOracleSelectionArm {
2699 None = 0,
2700 ActivationPriority,
2701 RejectedProposal,
2702 CurrentChainPriority,
2703 CertificateDeficit,
2704 AcceptedDrift,
2705 PredictionKernelDrift,
2706 FrozenSweep,
2707 CurrentClimbingImage,
2708 Variance,
2709 FirstUnobserved,
2710 RecoveryModelGrowth,
2711 TPE,
2712 PSBAX,
2714};
2715
2716enum class OieAcceptedDriftKind {
2717 GeometricTrustBoundary = 0,
2718 PredictionKernelBoundary,
2719};
2720
2721struct OieAcceptedDriftTarget {
2722 int image_index = -1;
2723 OieAcceptedDriftKind kind = OieAcceptedDriftKind::GeometricTrustBoundary;
2724
2725 OieAcceptedDriftTarget(int image_index_ = -1,
2726 OieAcceptedDriftKind kind_ =
2727 OieAcceptedDriftKind::GeometricTrustBoundary)
2728 : image_index(image_index_), kind(kind_)
2729 {
2730 }
2731};
2732
2733[[nodiscard]] const char* oieOracleSelectionArmName(
2734 OieOracleSelectionArm arm) noexcept;
2735
2736[[nodiscard]] bool oieSelectionArmUsesPosteriorAcquisition(
2737 OieOracleSelectionArm arm) noexcept;
2738
2739struct OieOracleTargetDecision {
2740 int image_index = -1;
2741 OieOracleSelectionArm arm = OieOracleSelectionArm::None;
2742 bool requires_force_quality = false;
2743
2744 [[nodiscard]] bool selectedByRejectedProposal() const;
2745 [[nodiscard]] bool selectedByPosteriorAcquisition() const;
2746 [[nodiscard]] bool replaceableByPosteriorAcquisition() const;
2747 [[nodiscard]] bool replaceableByPosteriorActionAcquisition() const;
2748};
2749
2750class OieOracleTargetPlanner {
2751public:
2764 OieOracleTargetPlanner(
2765 int n_images, bool frozen_sweep, bool ci_active, int ci_idx,
2766 const std::vector<char>& image_evaluated,
2767 const std::vector<char>& image_observed_current,
2768 const std::vector<char>& image_posterior_certified_current,
2769 const std::vector<double>& per_image_var,
2770 double acquisition_noise_floor = 0.0, int local_recovery_image = -1,
2771 bool allow_replaceable_acquisition = false,
2772 bool climbing_image_converged_only = false,
2773 std::vector<char> image_acquisition_unavailable = {});
2774
2775 [[nodiscard]] OieOracleTargetDecision selectPriorityTarget(
2776 const ProposalAcquisitionTarget& rejected_proposal_acquisition,
2777 bool variance_exceeded, int max_var_idx,
2778 int current_chain_priority_idx = -1,
2779 OieAcceptedDriftTarget accepted_drift = {},
2780 bool current_chain_required = true,
2781 const ProposalAcquisitionTarget& pending_band_action = {}) const;
2782
2783 [[nodiscard]] OieOracleTargetDecision selectPosteriorAcquisitionTarget(
2784 const OieOracleTargetDecision& fallback, int image_index,
2785 OieOracleSelectionArm arm) const;
2786
2789 [[nodiscard]] OieOracleTargetDecision selectPosteriorActionTarget(
2790 const OieOracleTargetDecision& fallback,
2791 const ProposalAcquisitionTarget& target,
2792 bool target_within_training_trust, double posterior_force_variance,
2793 double force_noise_floor, OieOracleSelectionArm arm) const;
2794
2799 [[nodiscard]] OieOracleTargetDecision
2800 selectRequiredCurrentChainMeasurementTarget(
2801 const OieOracleTargetDecision& fallback, int image_index,
2802 OieAcceptedDriftTarget blocking_drift = {}) const;
2803
2807 [[nodiscard]] OieOracleTargetDecision selectSurrogateRepairTarget(
2808 const OieOracleTargetDecision& fallback, const char* inner_exit,
2809 const OieBandPosteriorReadiness& readiness,
2810 bool measurement_owned) const;
2811
2812 [[nodiscard]] OieOracleTargetDecision selectRecoveryModelGrowthTarget(
2813 const OieOracleTargetDecision& fallback, int image_index) const;
2814
2818 [[nodiscard]] OieOracleTargetDecision selectExpectedImprovementTarget(
2819 const OieOracleTargetDecision& fallback, int image_index) const;
2820
2825 [[nodiscard]] OieOracleTargetDecision selectForceResidualRemeasureTarget(
2826 const OieOracleTargetDecision& fallback, int max_force_image,
2827 double max_band_force, double force_tolerance) const;
2828
2829private:
2830 [[nodiscard]] bool isInterior(int idx) const;
2831 [[nodiscard]] bool isCurrentAcquisitionAvailable(int idx) const;
2832 [[nodiscard]] bool isEvaluated(int idx) const;
2833 [[nodiscard]] bool isObservedCurrent(int idx) const;
2834 [[nodiscard]] bool isPosteriorCertified(int idx) const;
2835 [[nodiscard]] bool hasTrueCurrentOracleData(int idx) const;
2836 [[nodiscard]] bool hasCurrentOracleData(int idx) const;
2837 [[nodiscard]] int firstUnobservedInterior() const;
2838 [[nodiscard]] int bestVarianceTarget(int max_var_idx) const;
2839 [[nodiscard]] OieOracleTargetDecision decision(
2840 int image_index, OieOracleSelectionArm arm) const;
2841
2842 int n_images_;
2843 bool frozen_sweep_;
2844 bool ci_active_;
2845 int ci_idx_;
2846 const std::vector<char>& image_evaluated_;
2847 const std::vector<char>& image_observed_current_;
2848 const std::vector<char>& image_posterior_certified_current_;
2849 const std::vector<double>& per_image_var_;
2850 double acquisition_noise_floor_ = 0.0;
2851 int local_recovery_image_ = -1;
2852 bool allow_replaceable_acquisition_ = false;
2853 bool climbing_image_converged_only_ = false;
2854 // Refusal excludes a purchase without supplying an observation or
2855 // constraining a distinct off-path proposal for the same image.
2856 std::vector<char> image_acquisition_unavailable_;
2857 [[nodiscard]] bool clearsNoiseFloor(int idx) const;
2858};
2859
2862[[nodiscard]] bool shouldPreferForceResidualRemeasure(
2863 const OieOracleTargetDecision& decision, double max_band_force,
2864 double force_tolerance) noexcept;
2865
2871struct OffBandResidualGuard {
2872 bool armed = false;
2873 Eigen::VectorXd positions;
2874};
2875
2876[[nodiscard]] bool protectUnmeasuredOffBandProposal(
2877 OffBandResidualGuard& guard, bool selected_by_rejected,
2878 bool proposal_has_positions, bool coincides_with_band,
2879 bool proposal_in_training, const Eigen::VectorXd& proposal,
2880 double residual_force, double force_tolerance);
2881
2887[[nodiscard]] bool keepProposalWithoutRemeasure(bool proposal_has_positions,
2888 bool proposal_in_training,
2889 int remeasure_image) noexcept;
2890
2894[[nodiscard]] bool releaseTrainedPendingAcquisition(
2895 ProposalAcquisitionTarget& acquisition, const gpr::Observation& training,
2896 bool residual_force_open);
2897
2898[[nodiscard]] int selectOieOracleTarget(
2899 int n_images, bool frozen_sweep, bool ci_active, int ci_idx,
2900 const std::vector<char>& image_evaluated,
2901 const std::vector<char>& image_observed_current,
2902 const std::vector<double>& per_image_var,
2903 const ProposalAcquisitionTarget& rejected_proposal_acquisition,
2904 bool variance_exceeded, int max_var_idx,
2905 int current_chain_priority_idx = -1,
2906 bool* selected_by_rejected_proposal = nullptr);
2907
2908[[nodiscard]] int selectOieOracleTarget(
2909 int n_images, bool frozen_sweep, bool ci_active, int ci_idx,
2910 const std::vector<char>& image_evaluated,
2911 const std::vector<char>& image_observed_current,
2912 const std::vector<char>& image_posterior_certified_current,
2913 const std::vector<double>& per_image_var,
2914 const ProposalAcquisitionTarget& rejected_proposal_acquisition,
2915 bool variance_exceeded, int max_var_idx,
2916 int current_chain_priority_idx = -1,
2917 bool* selected_by_rejected_proposal = nullptr);
2918
2919[[nodiscard]] ProposalAcquisitionTarget selectRejectedProposalAcquisitionTarget(
2920 const Eigen::VectorXd& proposal_positions, Eigen::Index image_dof,
2921 const std::vector<double>& scores, const std::vector<char>& eligible,
2922 const gpr::Observation& training_obs, int current_idx);
2923
2924[[nodiscard]] int findRestorableObservationRow(const gpr::Observation& obs,
2925 const Image& image);
2926
2927bool restoreObservedImageIfPresent(const gpr::Observation& obs, Image& image);
2928
2931bool adoptMeasuredOracleRow(NEBPath& path, int index,
2932 const gpr::Observation& measured, double* force);
2933
2937bool measuredForceBelowFinalTolerance(NEBPath& path, int index,
2938 double tolerance,
2939 bool require_energy_bracket,
2940 const gpr::Observation& measured,
2941 double* force);
2942
2944bool refreshOieImage(Image& image, const gpr::Observation& observations,
2945 bool preserve_evaluated,
2946 const std::function<void(Image&)>& predict);
2947
2948bool restoreObservedImagesAndRefreshForces(
2949 const gpr::Observation& obs, NEBPath& path,
2950 std::vector<char>& image_observed_current,
2951 std::vector<char>& image_evaluated);
2952
2953struct OieCurrentObservationState {
2954 bool restored_current_observations = false;
2955 int ci_idx = -1;
2956};
2957
2958struct OieClimbingImageActivationState {
2959 bool ci_active = false;
2960 int ci_idx = -1;
2961};
2962
2963[[nodiscard]] bool oieClimbingImageActivationCertificate(
2964 bool band_force_gate_ready, bool saddle_exists) noexcept;
2965
2968using OieClimbingEnergyChange = std::function<double(const NEBPath&, int)>;
2969
2974[[nodiscard]] double oieClimbingStepEnergyChange(const NEBPath& path,
2975 int image_idx,
2976 ActiveLearningSession& session,
2977 bool project_rotations,
2978 double radius);
2979
2982[[nodiscard]] bool measuredClimbRefutesHandover(
2983 const NEBPath& path, int candidate_idx, int incumbent_idx,
2984 const OieClimbingEnergyChange& climb_change);
2985
2986[[nodiscard]] OieCurrentObservationState restoreOieCurrentObservationsAndMarker(
2987 const gpr::Observation& obs, NEBPath& path, bool ci_active,
2988 int posterior_candidate_idx, int certified_ci_idx,
2989 const std::vector<double>& posterior_energy_variance,
2990 double confidence_width, double variance_ceiling,
2991 std::vector<char>& image_observed_current,
2992 std::vector<char>& image_evaluated,
2993 bool require_true_handover_certificate = false, int protected_ci_idx = -1,
2994 const OieClimbingEnergyChange& climb_change = {});
2995
2996[[nodiscard]] OieClimbingImageActivationState updateOieClimbingImageActivation(
2997 const GPNEBConfig& config, NEBPath& path, bool ci_active,
2998 const std::vector<double>& posterior_energy_variance,
2999 double confidence_width, double variance_ceiling, int certified_ci_idx = -1,
3000 bool band_force_gate_ready = true);
3001
3003void refreshOieClimbingImageAfterRefit(
3004 const GPNEBConfig& config, NEBPath& path, bool ci_active,
3005 int posterior_candidate_idx, int previous_ci_idx, int protected_ci_idx,
3006 const std::vector<double>& posterior_energy_variance,
3007 double variance_ceiling, const OieClimbingEnergyChange& climb_change = {});
3008
3009[[nodiscard]] bool shouldStartTerminalSweep(
3010 double relaxed_gp_force, double max_chain_var, double uncertainty_threshold,
3011 bool has_true_force_eval, double max_true_force_eval, double conv_tol,
3012 bool ci_force_confident, bool ci_only_convergence_active = false);
3013
3014struct GlobalLBFGSOptions {
3015 int memory = 20;
3016 double inverse_curvature = 0.01;
3017 double finite_difference = 1e-6;
3018 bool auto_scale = true;
3019 bool angle_reset = true;
3020 bool distance_reset = true;
3021 // Sketched L-BFGS history sub-sampling (Gower-Richtarik 2015
3022 // sketch-and-project view). 0 = use full history (standard
3023 // L-BFGS). 1 <= k < memory selects k pairs uniformly at random
3024 // per two-loop call.
3025 int sketch_history = 0;
3026 uint64_t sketch_seed = 1;
3027 // Nystrom-sketched chain Hessian for the L-BFGS H0 slot
3028 // (Frangella-Tropp-Udell SIMAX 2023, doi:10.1137/21M1466244).
3029 // When > 0, every outer iter builds a rank-k Nystrom approximation
3030 // of the chain Hessian via k Hessian-vector products (one per
3031 // sketch column, distributed across MPI ranks; see
3032 // gpr/optimization/SketchedHessianH0.h for the math layout). The
3033 // chain L-BFGS two-loop applies this in place of scalar gamma * I
3034 // as the initial inverse-Hessian estimate. Replicated apply with
3035 // O(n * k) cost; sub-second for n up to a few thousand and k <= 30.
3036 // 0 keeps the legacy scalar H0.
3037 int sketch_h0_rank = 0;
3038 // FD step for the Nystrom Hessian-vector probes (Angstrom for
3039 // Cartesian band coordinates). Small enough to stay inside the
3040 // L-BFGS quadratic-model trust region; large enough that two
3041 // gradient calls do not cancel to round-off.
3042 double sketch_h0_eps = 1e-3;
3044 double newton_agreement = GPNEBConfig::kDefaultLbfgsNewtonAgreement;
3045};
3046
3050void emitMaxMoveTrustRegionWarning(double max_move, bool& warned);
3051
3052[[nodiscard]] double maxBandMotion(const Eigen::VectorXd& step,
3053 Eigen::Index image_dof);
3054
3063[[nodiscard]] Eigen::VectorXd limitBandMotion(const Eigen::VectorXd& step,
3064 Eigen::Index image_dof,
3065 double max_move);
3066
3067struct NEBBandObjectiveGeodesicOptions {
3068 bool enabled = false;
3069 int n_atoms = 0;
3070 std::vector<char> moving_atoms;
3071 // Atomic numbers (frame order) for the per-element-pair contact floor;
3072 // empty keeps the scalar endpoint bound alone.
3073 std::vector<int> atomic_numbers;
3074 // Fixed atoms the moving atoms must also stay off (GPNEBConfig).
3075 Eigen::VectorXd frozen_positions;
3076 std::vector<int> frozen_atomic_numbers;
3077 std::shared_ptr<const gpr::geometry::InternalCoordinateSet>
3078 internal_coordinates;
3079 // Minimum-interatomic-distance step limit (Goswami 2026 Eq. 5.3, r_limit
3080 // in [0, 1)): each atom's displacement is capped at
3081 // 0.5 * (1 - r_limit) * d_min, so a single step cannot close any contact
3082 // below r_limit * d_min. The trust radius catches feature-space
3083 // extrapolation; this catches the physically unacceptable geometry the
3084 // feature-space metric can miss. The endpoint minimum also fixes a
3085 // contact floor at r_limit * d_endpoint across all steps. <= 0 disables.
3086 double min_distance_ratio_limit = 0.0;
3087 std::array<double, 9> cell{};
3088 // Per-primitive internal trust radii derived from the band's own
3089 // discretization (internalTrustFromPathSpacing): a relaxation step may
3090 // change each internal by about one inter-image spacing before it jumps
3091 // past the resolution of the band itself. Empty disables the constraint;
3092 // entries <= 0 leave that primitive unconstrained. Units follow the
3093 // primitive (Angstrom for bonds, radians for angles/dihedrals), so no
3094 // cross-unit mixing enters the scale test.
3095 Eigen::VectorXd internal_trust_per_primitive;
3096};
3097
3098// Median adjacent-image |dq_k| per primitive over the path: the band's own
3099// internal-coordinate discretization scale. Primitives the path does not
3100// traverse (zero median spacing) get 0 and stay unconstrained.
3101[[nodiscard]] Eigen::VectorXd internalTrustFromPathSpacing(
3102 const NEBPath& path,
3103 const gpr::geometry::InternalCoordinateSet& internal_coordinates);
3104
3105class GlobalLBFGSObjective {
3106public:
3107 virtual ~GlobalLBFGSObjective() = default;
3108
3109 [[nodiscard]] virtual Eigen::VectorXd positions() const = 0;
3110 [[nodiscard]] virtual Eigen::VectorXd force() const = 0;
3111 virtual void setPositions(const Eigen::VectorXd& positions) = 0;
3116 [[nodiscard]] virtual bool stepAdmissible(const Eigen::VectorXd& from,
3117 const Eigen::VectorXd& to) const
3118 {
3119 return from.size() == to.size() && from.allFinite() && to.allFinite();
3120 }
3121 virtual bool refresh(bool finite_difference_step) = 0;
3122 [[nodiscard]] virtual Eigen::Index imageDof() const = 0;
3123 [[nodiscard]] virtual Eigen::VectorXd difference(
3124 const Eigen::VectorXd& a, const Eigen::VectorXd& b) const;
3125 [[nodiscard]] virtual Eigen::VectorXd stepPositions(
3126 const Eigen::VectorXd& positions, const Eigen::VectorXd& step) const;
3127 [[nodiscard]] virtual double maxMotion(const Eigen::VectorXd& step) const;
3130 [[nodiscard]] virtual Eigen::VectorXd limitMotion(
3131 const Eigen::VectorXd& step, double max_move) const;
3136 [[nodiscard]] virtual double merit() const
3137 {
3138 return std::numeric_limits<double>::quiet_NaN();
3139 }
3143 [[nodiscard]] virtual Eigen::VectorXd projectPerpendicular(
3144 const Eigen::VectorXd& v) const
3145 {
3146 return v;
3147 }
3151 virtual void respace() { }
3152};
3153
3154class NEBBandObjective final : public GlobalLBFGSObjective {
3155public:
3156 explicit NEBBandObjective(NEBPath& path, std::function<bool()> refresh = {},
3157 NEBBandObjectiveGeodesicOptions geodesic = {},
3158 int fixed_image_index = -1,
3159 std::vector<char> active_images = {});
3160
3161 [[nodiscard]] Eigen::VectorXd positions() const override;
3162 [[nodiscard]] Eigen::VectorXd force() const override;
3163 void setPositions(const Eigen::VectorXd& positions) override;
3164 [[nodiscard]] bool stepAdmissible(const Eigen::VectorXd& from,
3165 const Eigen::VectorXd& to) const override;
3166 bool refresh(bool finite_difference_step) override;
3167 [[nodiscard]] Eigen::Index imageDof() const override;
3168 [[nodiscard]] Eigen::VectorXd stepPositions(
3169 const Eigen::VectorXd& positions,
3170 const Eigen::VectorXd& step) const override;
3171 [[nodiscard]] double merit() const override;
3172 [[nodiscard]] Eigen::VectorXd projectPerpendicular(
3173 const Eigen::VectorXd& v) const override;
3174 void respace() override;
3175
3181 void setActiveImages(std::vector<char> active_images);
3182 [[nodiscard]] const std::vector<char>& activeImages() const noexcept
3183 {
3184 return active_images_;
3185 }
3188 [[nodiscard]] std::size_t geodesicRetractionFallbacks() const noexcept
3189 {
3190 return geodesic_retraction_fallbacks_;
3191 }
3192
3193private:
3194 NEBPath& path_;
3195 std::function<bool()> refresh_;
3196 NEBBandObjectiveGeodesicOptions geodesic_;
3197 gpr::geometry::ElementPairContactFloor contact_floor_;
3198 int fixed_image_index_ = -1;
3199 std::vector<char> active_images_;
3200 bool clean_ = false;
3201 mutable std::size_t geodesic_retraction_fallbacks_ = 0;
3202
3203 [[nodiscard]] bool imageIsActive(int image_idx) const;
3204 [[nodiscard]] bool hasFrozenContacts() const noexcept;
3205};
3206
3207ProposalAcquisitionTarget holdOieUnsupportedImages(
3208 NEBBandObjective& objective, const Eigen::VectorXd& accepted_positions,
3209 const std::vector<char>& blocked_images);
3210
3213std::ostream& bandLog();
3214
3228struct CurvatureStepCap {
3229 bool saturated = false;
3230 double force_before = 0.0;
3231 double limit = 0.0;
3232
3233 void reset() noexcept
3234 {
3235 saturated = false;
3236 force_before = 0.0;
3237 limit = 0.0;
3238 }
3239
3240 [[nodiscard]] double resolve(
3241 double max_move, double kappa, double force_motion,
3242 double newton_agreement = GPNEBConfig::kDefaultLbfgsNewtonAgreement)
3243 {
3244 double used = max_move;
3245 if (limit > 0.0 && std::isfinite(limit) && limit < used) used = limit;
3246 // 0.2 A is the band trust (warnIfMaxMoveExceedsTrustRegion).
3247 // A larger cap is an unclipped step, not the limit cycle.
3248 constexpr double kBandTrust = 0.2;
3249 const bool stopped = saturated && std::isfinite(force_before) &&
3250 std::isfinite(force_motion) &&
3251 force_motion >= force_before * (1.0 - 1.0e-8);
3252 if (!(stopped && std::isfinite(max_move) && max_move > 0.0 &&
3253 max_move <= kBandTrust && kappa > 0.0 && std::isfinite(kappa) &&
3254 force_motion > 0.0 && force_motion < kappa * max_move)) {
3255 return used;
3256 }
3257 // F/kappa is the Newton step and 1/kappa changes the force by
3258 // 1 eV/A, so the ratio of the two lengths is F. Above
3259 // newton_agreement the stored 1/kappa cap is shorter than that
3260 // Newton step by more than the agreement factor. The extended LJ
3261 // pentamer hits this at F = 11 eV/A (kappa 164 eV/A^2): the 0.1 A
3262 // trust reaches the reference barrier and 0.006 A does not. The
3263 // narrow climb (F about 1.8) and the Muller-Brown handoff
3264 // (F about 1.2) stay under the default 2 eV/A.
3265 if (force_motion > newton_agreement) return used;
3266 constexpr double kFloor = 1.0e-4;
3267 const double shrunk = std::max(1.0 / kappa, kFloor);
3268 if (shrunk < used) {
3269 bandLog() << "[band] curvature-cap " << used << " -> " << shrunk
3270 << " kappa=" << kappa << " force=" << force_motion
3271 << std::endl;
3272 limit = shrunk;
3273 used = shrunk;
3274 }
3275 return used;
3276 }
3277
3278 void observe(double step_motion, double configured_max_move,
3279 double force_motion) noexcept
3280 {
3281 saturated = std::isfinite(step_motion) &&
3282 std::isfinite(configured_max_move) &&
3283 configured_max_move > 0.0 &&
3284 step_motion >= configured_max_move * (1.0 - 1.0e-8);
3285 if (saturated && std::isfinite(force_motion))
3286 force_before = force_motion;
3287 }
3288};
3289
3290class GlobalLBFGSOptimizer {
3291public:
3292 explicit GlobalLBFGSOptimizer(GlobalLBFGSOptions options = {});
3293
3294 void reset();
3295 bool update(const GlobalLBFGSObjective& objective,
3296 const Eigen::VectorXd& r1, const Eigen::VectorXd& r0,
3297 const Eigen::VectorXd& f1, const Eigen::VectorXd& f0);
3298 bool step(GlobalLBFGSObjective& objective, double max_move,
3299 std::optional<double> initial_inverse_curvature = std::nullopt);
3300
3301 // Rebuild the Nystrom-sketched H0 from a fresh batch of
3302 // Hessian-vector products at the current band position. No-op
3303 // when options_.sketch_h0_rank <= 0. Intended to be called once
3304 // per outer iter (the same cadence that adds a new (s, y) pair to
3305 // the L-BFGS history); the sketch then services every two-loop
3306 // call until the next rebuild.
3307 //
3308 // The HvP functor must compute H * v at the current band geometry
3309 // (e.g. via FD on the band-force functor) and may be MPI-aware
3310 // (the sketch's internal column distribution participates in
3311 // MPI_COMM_WORLD when GPR_HAVE_MPI is on).
3312 void rebuildSketchedH0(
3313 const std::function<Eigen::VectorXd(const Eigen::VectorXd&)>& hvp,
3314 int n_dof);
3315
3320 void setCurvatureExclusion(Eigen::Index offset, Eigen::Index len) noexcept
3321 {
3322 curvature_exclude_offset_ = offset;
3323 curvature_exclude_len_ = len;
3324 }
3325
3326 [[nodiscard]] int iteration() const
3327 {
3328 return iteration_;
3329 }
3330 [[nodiscard]] int historySize() const
3331 {
3332 return static_cast<int>(s_history_.size());
3333 }
3334 [[nodiscard]] double lastCurvatureDot() const
3335 {
3336 return last_curvature_dot_;
3337 }
3338 // Curvature scale kappa = (s . y) / (s . s) along the most recent
3339 // accepted L-BFGS step -- the Rayleigh quotient of the (band) Hessian
3340 // in the step direction. CurvatureStepCap turns this into the trust
3341 // cap after a saturated step inside the 0.2 A band trust that did
3342 // not reduce the residual, once that residual is inside kappa * cap.
3343 // The next cap is 1/kappa when the residual is at most
3344 // lbfgs_newton_agreement. A static cap of 0.1 A against
3345 // kappa ~ 1.8e3 eV/A^2 plateaus the band force near kappa * cap
3346 // (about 180 eV/A). That residual is above the default agreement
3347 // bound, so 1/kappa would undershoot the Newton step and the
3348 // configured cap is kept. A residual that is still falling keeps
3349 // the configured cap.
3350 // Returns 0 when no positive curvature pair has been recorded yet.
3351 [[nodiscard]] double lastCurvatureScale() const
3352 {
3353 if (s_history_.empty()) return 0.0;
3354 const double ss = s_history_.back().squaredNorm();
3355 if (!(ss > 0.0) || !std::isfinite(last_curvature_dot_)) return 0.0;
3356 const double kappa = last_curvature_dot_ / ss;
3357 return (std::isfinite(kappa) && kappa > 0.0) ? kappa : 0.0;
3358 }
3359
3360private:
3361 void clearHistory();
3362 void warnIfMaxMoveExceedsTrustRegion(double max_move);
3363 [[nodiscard]] Eigen::VectorXd getStep(
3364 GlobalLBFGSObjective& objective, double max_move,
3365 const Eigen::VectorXd& force, const Eigen::VectorXd& positions,
3366 std::optional<double> initial_inverse_curvature);
3367
3368 GlobalLBFGSOptions options_;
3369 int iteration_ = 0;
3370 std::deque<Eigen::VectorXd> s_history_;
3371 std::deque<Eigen::VectorXd> y_history_;
3372 std::deque<double> rho_history_;
3373 Eigen::VectorXd r_prev_;
3374 Eigen::VectorXd f_prev_;
3375 double last_curvature_dot_ = 0.0;
3376 Eigen::Index curvature_exclude_offset_ = -1;
3377 Eigen::Index curvature_exclude_len_ = 0;
3378 bool max_move_warned_ = false;
3379 CurvatureStepCap curvature_cap_;
3380 uint64_t sketch_rng_state_ = 0; // splitmix64 state; 0 = uninitialized
3381 // Nystrom-sketched chain Hessian H0. nullptr when sketch_h0_rank
3382 // is 0 (default = scalar H0). Lazily constructed on first step()
3383 // once n_dof is known from the objective; rebuilt every outer iter
3384 // from k Hessian-vector products (column-distributed across MPI
3385 // ranks). See gpr/optimization/SketchedHessianH0.h.
3386 std::unique_ptr<gpr::optim::SketchedHessianH0> sketched_h0_;
3387};
3388
3393class BandRelaxationEngine {
3394public:
3395 virtual ~BandRelaxationEngine() = default;
3396 virtual void reset() = 0;
3397 virtual bool step(
3398 GlobalLBFGSObjective& objective, double max_move,
3399 std::optional<double> initial_inverse_curvature = std::nullopt) = 0;
3400 virtual void rebuildSketchedH0(
3401 const std::function<Eigen::VectorXd(const Eigen::VectorXd&)>& hvp,
3402 int n_dof) = 0;
3403 virtual void setCurvatureExclusion(Eigen::Index offset,
3404 Eigen::Index len) noexcept = 0;
3405 [[nodiscard]] virtual int iteration() const = 0;
3406 [[nodiscard]] virtual int historySize() const = 0;
3407 [[nodiscard]] virtual double lastCurvatureDot() const = 0;
3408 [[nodiscard]] virtual double lastCurvatureScale() const = 0;
3409};
3410
3411class InternalLbfgsEngine final : public BandRelaxationEngine {
3412public:
3413 explicit InternalLbfgsEngine(GlobalLBFGSOptions options = {})
3414 : impl_(options)
3415 {
3416 }
3417
3418 void reset() override
3419 {
3420 impl_.reset();
3421 }
3422 bool step(
3423 GlobalLBFGSObjective& objective, double max_move,
3424 std::optional<double> initial_inverse_curvature = std::nullopt) override
3425 {
3426 return impl_.step(objective, max_move, initial_inverse_curvature);
3427 }
3428 void rebuildSketchedH0(
3429 const std::function<Eigen::VectorXd(const Eigen::VectorXd&)>& hvp,
3430 int n_dof) override
3431 {
3432 impl_.rebuildSketchedH0(hvp, n_dof);
3433 }
3434 void setCurvatureExclusion(Eigen::Index offset,
3435 Eigen::Index len) noexcept override
3436 {
3437 impl_.setCurvatureExclusion(offset, len);
3438 }
3439 [[nodiscard]] int iteration() const override
3440 {
3441 return impl_.iteration();
3442 }
3443 [[nodiscard]] int historySize() const override
3444 {
3445 return impl_.historySize();
3446 }
3447 [[nodiscard]] double lastCurvatureDot() const override
3448 {
3449 return impl_.lastCurvatureDot();
3450 }
3451 [[nodiscard]] double lastCurvatureScale() const override
3452 {
3453 return impl_.lastCurvatureScale();
3454 }
3455
3456 bool update(const GlobalLBFGSObjective& objective,
3457 const Eigen::VectorXd& r1, const Eigen::VectorXd& r0,
3458 const Eigen::VectorXd& f1, const Eigen::VectorXd& f0)
3459 {
3460 return impl_.update(objective, r1, r0, f1, f0);
3461 }
3462
3463private:
3464 GlobalLBFGSOptimizer impl_;
3465};
3466
3473enum class MeasuredNebStepStatus {
3474 NotRequested,
3475 Proposed,
3476 InvalidPath,
3477 InvalidSelection,
3478 InvalidImageState,
3479 InvalidPosteriorSample,
3480 MissingMeasurement,
3481 NonFiniteForce,
3482 Stationary,
3483 OptimizerRejected,
3484};
3485
3486[[nodiscard]] const char* measuredNebStepStatusName(
3487 MeasuredNebStepStatus status) noexcept;
3488
3489[[nodiscard]] std::vector<Eigen::VectorXd> proposeMeasuredNebStep(
3490 const NEBPath& path, const GPNEBConfig& config, int selected_image = -1,
3491 MeasuredNebStepStatus* status = nullptr);
3492
3495[[nodiscard]] std::vector<Eigen::VectorXd> proposePsBaxSampledNebStep(
3496 const NEBPath& path, const Eigen::VectorXd& interior_observation_sample,
3497 const GPNEBConfig& config, MeasuredNebStepStatus* status = nullptr);
3498
3499struct PsBaxActionProposal {
3500 ProposalAcquisitionTarget target;
3501 MeasuredNebStepStatus status = MeasuredNebStepStatus::NotRequested;
3502 double force_variance = std::numeric_limits<double>::quiet_NaN();
3503 bool trust_projected = false;
3504 bool trust_certified = false;
3505};
3506
3507using PsBaxTrustProjector = std::function<bool(Eigen::VectorXd&)>;
3508using PsBaxTrustCertificate = std::function<bool(const Eigen::VectorXd&)>;
3509
3513[[nodiscard]] PsBaxActionProposal proposePsBaxActionAcquisition(
3514 const NEBPath& path, gpr::GaussianProcessRegression& gp,
3515 const gpr::Observation& training_obs, const GPNEBConfig& config,
3516 std::uint64_t posterior_seed, const PsBaxTrustProjector& project_to_trust,
3517 const PsBaxTrustCertificate& trust_certified);
3518
3521[[nodiscard]] std::vector<Eigen::VectorXd> proposeCertifiedMeasuredNebStep(
3522 const NEBPath& path, const gpr::Observation& observations,
3523 const GPNEBConfig& config, int selected_image,
3524 MeasuredNebStepStatus* status = nullptr);
3525
3528[[nodiscard]] std::vector<Eigen::VectorXd> proposeCertifiedMeasuredNebStep(
3529 const NEBPath& path, const ActiveLearningSession& session,
3530 const GPNEBConfig& config, int selected_image,
3531 MeasuredNebStepStatus* status = nullptr);
3532
3536[[nodiscard]] std::vector<Eigen::VectorXd> oieRecoveryGrowthCandidates(
3537 const Eigen::VectorXd& source, const Eigen::VectorXd& measured_proposal,
3538 const gpr::Observation& local_observations);
3539
3540[[nodiscard]] int selectOieRecoveryGrowthCandidate(
3541 const std::vector<char>& admissible, const std::vector<double>& variances,
3542 const std::vector<double>& trust_distances, int measured_step_index,
3543 int secant_backtrack_index);
3544
3548[[nodiscard]] std::vector<Eigen::VectorXd> isolateBandProposalImage(
3549 const NEBPath& source,
3550 const std::vector<Eigen::VectorXd>& proposed_positions, int selected_image);
3551
3552struct MeasuredBandProposalAssessment {
3553 bool fully_measured = false;
3554 bool accept = false;
3555 std::optional<double> inverse_curvature;
3556};
3557
3561[[nodiscard]] MeasuredBandProposalAssessment assessMeasuredBandProposal(
3562 const NEBPath& source, const NEBPath& candidate);
3563
3567[[nodiscard]] std::vector<double> measuredBandForceProfile(
3568 const NEBPath& path, int climbing_image = -1);
3569
3572[[nodiscard]] MeasuredResidualStepAssessment assessMeasuredClimbingStep(
3573 const NEBPath& source, const NEBPath& candidate, int climbing_image);
3574
3577[[nodiscard]] int selectMeasuredBandForceTarget(const NEBPath& path);
3578
3582[[nodiscard]] bool commitMeasuredBandCandidate(
3583 NEBPath& accepted_path, const NEBPath& measured_candidate,
3584 int climbing_image = -1);
3585
3586[[nodiscard]] bool shouldAcceptMeasuredBandCandidate(
3587 double candidate_max_force, double anchor_max_force) noexcept;
3588
3589[[nodiscard]] bool shouldAcceptMeasuredBandCandidate(
3590 const std::vector<double>& candidate_force_profile,
3591 const std::vector<double>& anchor_force_profile) noexcept;
3592
3596[[nodiscard]] double measuredVarianceCalibration(double force_error,
3597 double reported_force_variance,
3598 Eigen::Index dof,
3599 double noise_variance);
3600
3605[[nodiscard]] double posteriorSquaredErrorBound(Eigen::Index dof);
3606
3613[[nodiscard]] bool driftAdvanceOutsidePosterior(double force_error,
3614 double reported_force_variance,
3615 Eigen::Index dof,
3616 double noise_variance);
3617
3622[[nodiscard]] bool keptDriftOutsidePosterior(
3623 bool kept_advance, bool measured_on_band, double force_error,
3624 double reported_force_variance, Eigen::Index dof, double noise_variance);
3625
3627[[nodiscard]] double gradientFidelityTrustRadius(const GPNEBConfig& config,
3628 double radius,
3629 double fidelity);
3630
3634void installSecantClimbingDirection(NEBPath& path,
3635 ActiveLearningSession* session,
3636 const GPNEBConfig& config);
3637} // namespace detail
3638
3644 std::size_t hssvd = 0;
3645 std::size_t cholesky = 0;
3646};
3647
3661
3664void applyConfigToGP(const GPNEBConfig& config,
3666
3672 Unspecified,
3676 IterationBudget,
3679};
3680
3682 std::unique_ptr<NEBPath> path;
3683 bool converged = false;
3688 bool index_checked = false;
3690 bool index_refused = false;
3692 bool index_continue = false;
3695 double index_resolution = 0.0;
3699 // Aggregate count (kept for back-compat). Equal to
3700 // oracle_calls_endpoints
3701 // + oracle_calls_initial
3702 // + oracle_calls_outer
3703 // + oracle_calls_validation.
3704 // Use oracle_calls_to_convergence for the algorithmic-cost number
3705 // (excludes the post-convergence PES validation pass).
3710 // Endpoint evaluations (always 2 in standard runs, evaluated once
3711 // before the outer loop).
3713 // Initial-design intermediate evaluations (zero for OIE/GP-OIE
3714 // modes; n_im-2 for Standard/AIE).
3716 // Worst-image acquisitions made inside the outer loop. Exactly one
3717 // per outer iter in OIE/GP-OIE.
3719 // Post-convergence full-chain re-evaluation. Cosmetic cost: makes
3720 // barrier_energy / max_energy_image PES-true rather than
3721 // GP-predicted. NOT part of the algorithmic cost-to-convergence.
3730 double returned_true_force = std::numeric_limits<double>::infinity();
3731 // Forward barrier: E_saddle - E_reactant (image[0]).
3732 double barrier_energy = 0.0;
3733 // Reverse barrier: E_saddle - E_product (image[N-1]). For
3734 // exothermic reactions this is the larger number (the barrier the
3735 // product must climb to reach the saddle); for endothermic, it's
3736 // the smaller. Reported together with barrier_energy so the kinetic
3737 // picture (rate in either direction) is fully visible without
3738 // recomputing from the path.
3740 // The band's own saddle, retained when dimer refinement later
3741 // overwrites barrier_energy / reverse_barrier_energy with the
3742 // refined saddle's. Both directions are kept so each stage reports a
3743 // consistent pair: forward minus reverse is E_product - E_reactant
3744 // for either stage, since the endpoints do not move. NaN until the
3745 // band produces a barrier.
3746 double ci_barrier_energy = std::numeric_limits<double>::quiet_NaN();
3747 double ci_reverse_barrier_energy = std::numeric_limits<double>::quiet_NaN();
3748 std::vector<double> max_force_history;
3749 // Per-outer-iteration band trace (energies, posterior variance,
3750 // hyperparameters). Populated only when GPNEBConfig::record_band_trace is
3751 // set; empty otherwise. Used by the driver's h5 / con-v2 trace writers and
3752 // by the variance-collapse diagnosis.
3753 std::vector<OieBandTraceRecord> band_trace;
3754 // Composition-level outer-iter snapshots for golden-trace regression.
3755 // Populated only when GPNEBConfig::record_composition_trace is set.
3756 std::vector<OuterIterCompositionTraceRecord> composition_trace;
3768 Eigen::MatrixXd force_stop_positions;
3770 Eigen::MatrixXd force_stop_directions;
3771 Eigen::MatrixXd force_stop_gradients;
3772 Eigen::VectorXd force_stop_energies;
3774 Eigen::MatrixXd force_stop_modes;
3777 double force_stop_wall_s = 0.0;
3793 // Algorithmic cost: endpoints + initial design + outer-iter
3794 // acquisitions. Excludes validation pass.
3800
3803 std::array<std::optional<gpr::htst::Half>, 3> harmonic_halves{};
3804};
3805
3818GPNEBResult gpNEB(NEBOracle oracle, const Eigen::VectorXd& initial,
3819 const Eigen::VectorXd& final_state, int n_images,
3820 const GPNEBConfig& config = {},
3821 ActiveLearningSession* session = nullptr);
3822
3823} // namespace neb
3824} // namespace gpr
3825
3826#endif // GPR_NEB_GPNEB_H_
Acquisition strategies for GP-NEB OIE image selection.
ConvergenceNormType
Definition Enums.h:48
DistanceMetricType
Definition Enums.h:46
NEB path management: image chain, spring forces, climbing image.
Composition-level per-outer-iteration snapshot for gpNEB regression.
ActiveLearningSession: shared GP + training data across GP-NEB and GP-Dimer phases.
Trust radius enforcement for GP surrogate models.
Definition TrustRadius.h:36
static bool endpointPathHasNearLinearBondedTriplet(const Eigen::VectorXd &reactant_positions, const Eigen::VectorXd &product_positions, const std::vector< int > &atomic_numbers, double min_angle_degrees=165.0)
Definition GPNEB.cpp:136
AdaptiveSo3Policy(bool path_geometry_so3_sensitive)
Definition GPNEB.cpp:94
bool shouldUse(const NEBOracleEvaluationContext &context) const
Definition GPNEB.cpp:99
AdaptiveSo3SessionPolicy(bool path_geometry_so3_sensitive, double component_force_tolerance, Eigen::Index degrees_of_freedom, ConvergenceNormType convergence_norm)
Definition GPNEB.cpp:198
bool restartRequested() const noexcept
Definition GPNEB.cpp:307
void observeOptimizationOutcome(const NEBOracleOptimizationOutcome &outcome) noexcept
Definition GPNEB.cpp:263
void beginAveragedSession() noexcept
Definition GPNEB.cpp:317
AdaptiveSo3EvaluationMode evaluationMode() const noexcept
Definition GPNEB.cpp:230
void observeForceComponentRms(double component_rms) noexcept
Definition GPNEB.cpp:236
void setEvaluationContext(const NEBOracleEvaluationContext &context) noexcept
Definition GPNEB.cpp:208
double triggerForceNoise() const noexcept
Definition GPNEB.cpp:312
bool averagedSession() const noexcept
Definition GPNEB.cpp:328
NEB path: chain of images between two endpoints.
Definition NEBPath.h:57
std::optional< NEBOracleOptimizationOutcome > observe(int image_index, double force_norm)
Definition GPNEB.cpp:175
PosteriorFactorizationScope & operator=(const PosteriorFactorizationScope &)=delete
PosteriorFactorizationScope(PosteriorFactorizationCounts &counts)
Definition GPNEB.cpp:8815
PosteriorFactorizationScope(const PosteriorFactorizationScope &)=delete
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
int status
double expectedImprovementScore(double mu, double mu_best, double sigma)
Jones expected improvement for a maximizer.
The nudged elastic band: path, GP-NEB driver, configuration and result, acquisition,...
AdaptiveSo3EvaluationMode
Definition GPNEB.h:161
std::function< std::vector< std::pair< double, Eigen::VectorXd > >( const std::vector< Eigen::VectorXd > &positions)> NEBBatchOracle
Definition GPNEB.h:89
std::function< std::pair< double, Eigen::VectorXd >( const Eigen::VectorXd &positions)> NEBOracle
Oracle function: positions -> (energy, gradient).
Definition GPNEB.h:82
GPNEBStopReason
Result of GP-NEB optimization.
Definition GPNEB.h:3670
@ Unspecified
No terminal condition has been assigned.
Definition GPNEB.h:3672
@ Converged
The requested force and certificate conditions were satisfied.
Definition GPNEB.h:3674
std::function< ObservationVariance(const Eigen::VectorXd &positions)> ObservationVarianceEstimator
Posterior variance estimator for one joint oracle observation.
Definition GPNEB.h:100
constexpr int kMaxConsecutiveOracleFailures
Definition GPNEB.h:226
GPNEBConvergenceStatus
Definition GPNEB.h:228
double forceComponentRmsForNorm(double component_rms, Eigen::Index degrees_of_freedom, ConvergenceNormType norm) noexcept
Definition GPNEB.cpp:147
bool oracleContextRequestsAdaptiveSo3(const NEBOracleEvaluationContext &context)
Definition GPNEB.cpp:333
void applyConfigToGP(const GPNEBConfig &config, gpr::GaussianProcessRegression &gp)
Definition GPNEB.cpp:8296
AcquisitionType
Available acquisition strategies for image selection.
NEBMode
NEB evaluation mode.
Definition GPNEB.h:68
constexpr double defaultStencilStep() noexcept
Eigen::VectorXd projectPerpendicular(const Eigen::VectorXd &force, const Eigen::VectorXd &tangent, const Eigen::MatrixXd &force_covariance)
VecchiaResult evaluate(const Eigen::MatrixXd &points, const Eigen::VectorXd &y, double lengthscale, double noise, int max_neighbours)
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition Macros.h:16
GPModelProfile
Definition Structures.h:201
Eigen::Matrix< double, EigenDynamic, EigenDynamic, EigenMatrixStorage > EigenMatrix
Definition Macros.h:20
PriorMeanStatistic
Gaussian Process Regression algorithm.
Eigen::Matrix< double, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixd
Definition Macros.h:25
UncertaintyMode
Definition Structures.h:177
HyperparameterOptimizationMode
Definition Enums.h:56
HyperparameterObjectiveMode
Definition Enums.h:70
bool resolved(Dual value, Dual error, const BridgeResidualOptions &options)
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
Configuration for GP-NEB.
Definition GPNEB.h:246
double gp_local_pair_cutoff
Definition GPNEB.h:912
int acquisition_seed_offset
Definition GPNEB.h:476
bool remove_molecular_rigid_motion
Definition GPNEB.h:379
static constexpr double kDefaultLbfgsNewtonAgreement
Definition GPNEB.h:1019
std::vector< char > moving_atoms
Definition GPNEB.h:422
std::function< void(const NEBPath &path, int ci_image_idx, int outer_iter, ActiveLearningSession &session)> OuterIterHookReject
Definition GPNEB.h:1230
double virtual_obs_noise
Definition GPNEB.h:599
double theta_shift_skip_tol
Definition GPNEB.h:790
gpr::optim::SecantHessianConfig secant_hessian
Definition GPNEB.h:536
gpr::HyperparameterOptimizationMode hyperparameter_mode
Definition GPNEB.h:800
double lbfgs_max_move
Definition GPNEB.h:960
double gp_local_far_trust
Definition GPNEB.h:916
gpr::linalg::DistributedFactorization linalg_mode
Definition GPNEB.h:782
double gp_local_pair_spacing
Definition GPNEB.h:914
double gp_local_inner_tol_factor
Definition GPNEB.h:900
double gp_local_radius
Definition GPNEB.h:889
OuterIterHook outer_iter_hook
Definition GPNEB.h:1225
std::vector< int > symmetry_permutation
Definition GPNEB.h:670
double imspe_refit_skip_relative_tol
Definition GPNEB.h:457
gpr::GaussianProcessRegression::VarianceConvention variance_convention
Definition GPNEB.h:562
Eigen::Index oracle_batch_chunk
Definition GPNEB.h:259
bool outer_budget_per_image
Definition GPNEB.h:300
std::function< void(const NEBOracleSessionCheckpoint &)> oracle_session_path_checkpoint
Definition GPNEB.h:284
std::optional< ConvergenceNormType > convergence_force_norm
Definition GPNEB.h:263
gpr::UncertaintyMode uncertainty_mode
Definition GPNEB.h:559
bool oie_fixed_point_reparam
Definition GPNEB.h:828
bool disable_output_normalization
Definition GPNEB.h:569
bool hssvd_dual_lapack_rrr
Definition GPNEB.h:766
bool attach_manifold_chart
Definition GPNEB.h:497
const policy::TrainingPolicy * training_policy
Definition GPNEB.h:1269
bool active_posterior_refits
Definition GPNEB.h:690
bool ls_seed_chemical_floor
Definition GPNEB.h:726
bool band_midpoint_certificate
Definition GPNEB.h:866
std::vector< int > frozen_atomic_numbers
Definition GPNEB.h:388
OieFixedImageLeaseProvider oie_fixed_image_lease
Definition GPNEB.h:1265
double rgmin_initial_log_move
Definition GPNEB.h:736
static void requireLbfgsNewtonAgreement(double value)
Definition GPNEB.h:1025
double trust_ratio_at_limit
Definition GPNEB.h:1178
double lbfgs_inverse_curvature
Definition GPNEB.h:1010
unsigned int seed
Definition GPNEB.h:505
bool use_resolution_dedup
Definition GPNEB.h:658
const double * oracle_energy_noise_rms
Definition GPNEB.h:268
std::vector< double > initial_rest_lengths
Definition GPNEB.h:542
OuterIterHookReject outer_iter_hook_reject
Definition GPNEB.h:1233
double inner_unc_relative
Definition GPNEB.h:1140
OieInnerHandoffPriority oie_inner_handoff_priority
Definition GPNEB.h:1252
NEBBatchOracle batch_oracle
Definition GPNEB.h:253
double lbfgs_finite_difference
Definition GPNEB.h:1011
double lbfgs_sketch_h0_eps
Definition GPNEB.h:1097
bool force_stop_certificate
Definition GPNEB.h:847
int refit_training_revisions
Definition GPNEB.h:679
bool use_three_phase_picker
Definition GPNEB.h:451
bool hyperparameter_objective_explicit
Definition GPNEB.h:808
int hssvd_local_active_set_size
Definition GPNEB.h:767
ObservationVarianceEstimator observation_variance_estimator
Definition GPNEB.h:1209
double ci_activation_tol
Definition GPNEB.h:354
bool use_relative_neighborhood_graph
Definition GPNEB.h:415
DistanceMetricType trust_metric
Definition GPNEB.h:1160
bool environment_residuals
Definition GPNEB.h:691
std::function< void(const NEBOracleOptimizationOutcome &)> oracle_optimization_outcome
Definition GPNEB.h:275
AcquisitionType acquisition
Definition GPNEB.h:445
Eigen::VectorXd frozen_positions
Definition GPNEB.h:387
bool gp_local_initial_sweep
Definition GPNEB.h:921
gpr::optim::VibrationalStencil vibrational_stencil
Definition GPNEB.h:852
double rff_force_tol_fraction
Definition GPNEB.h:754
policy::SearchKind training_search_kind
Label published to the policy. runOCINEB sets OciNeb.
Definition GPNEB.h:1271
bool uncertainty_aware_projection
Definition GPNEB.h:441
uint64_t lbfgs_sketch_seed
Definition GPNEB.h:1088
CurrentCiOraclePriority current_ci_oracle_priority
Definition GPNEB.h:1242
double trust_adaptive_floor
Definition GPNEB.h:1174
double pair_cutoff_width
Definition GPNEB.h:428
double lbfgs_newton_agreement
Definition GPNEB.h:1020
BandEngineKind band_engine
Definition GPNEB.h:1009
double inner_step_size
Definition GPNEB.h:312
std::function< void(const NEBOracleEvaluationContext &)> oracle_evaluation_context
Definition GPNEB.h:273
bool gp_local_carry_springs
Definition GPNEB.h:959
std::string rgsaddle_library
Definition GPNEB.h:711
double first_attempt_wall_seconds
Definition GPNEB.h:502
double variance_spread_factor
Definition GPNEB.h:309
std::vector< int > atomic_numbers
Definition GPNEB.h:383
std::function< OieFixedImageLease( const NEBPath &path, int ci_image_idx, int outer_iter)> OieFixedImageLeaseProvider
Definition GPNEB.h:1263
bool subset_failure_escalation
Definition GPNEB.h:733
bool additive_pair_residuals
Definition GPNEB.h:695
bool use_psis_deterministic
Definition GPNEB.h:565
GPModelProfile model_profile
Definition GPNEB.h:689
bool * oracle_noise_updates_enabled
Definition GPNEB.h:271
double gp_local_trust
Definition GPNEB.h:894
static bool parseBandEngineKind(const std::string &name, BandEngineKind &out) noexcept
Definition GPNEB.h:1034
bool record_band_trace_snapshot
Definition GPNEB.h:516
std::optional< bool > dimer_analytic_curvature
Definition GPNEB.h:533
int hssvd_local_posterior_active_set_size
Definition GPNEB.h:768
OieFixedImage oie_fixed_image
Definition GPNEB.h:1259
double trust_delta_explore
Definition GPNEB.h:1176
bool skip_unchanged_subset_fit
Definition GPNEB.h:746
bool record_band_trace_geometry
Definition GPNEB.h:520
std::array< double, 9 > cell
Definition GPNEB.h:426
bool hold_refined_spacing
Definition GPNEB.h:873
const double * oracle_force_noise_rms
Definition GPNEB.h:269
bool record_composition_trace
Definition GPNEB.h:525
bool theta_shift_skip_auto
Definition GPNEB.h:793
static constexpr bool isRgsaddleEngine(BandEngineKind kind) noexcept
Whether a band engine kind runs on the rgsaddle library.
Definition GPNEB.h:1002
gpr::HyperparameterObjectiveMode hyperparameter_objective
Definition GPNEB.h:802
std::shared_ptr< const gpr::WallClockLimit > wall_clock_limit
Definition GPNEB.h:485
bool learn_likelihood_noise
Definition GPNEB.h:582
bool saddle_stage_follows
Definition GPNEB.h:863
std::function< int(const NEBPath &path, int ci_image_idx, int outer_iter)> OieFixedImage
Definition GPNEB.h:1257
bool use_geometric_spring
Definition GPNEB.h:434
bool stable_posterior_variance
Definition GPNEB.h:786
double ci_activation_factor
Definition GPNEB.h:355
std::function< void(gpr::InputParameters &, gpr::AtomsConfiguration &)> gp_setup
Definition GPNEB.h:1204
double unc_convergence
Definition GPNEB.h:364
@ RgsaddleRtr
rgsaddle's Riemannian trust region on the band (RTR-tCG).
Definition GPNEB.h:992
bool restricted_variance_acquisition
Definition GPNEB.h:372
double band_certificate_force_scale
Definition GPNEB.h:494
std::function< void( NEBPath &path, int ci_image_idx, int outer_iter, ActiveLearningSession &session, bool &converged, bool trap_detected)> OuterIterHook
Definition GPNEB.h:1222
bool ci_index_certificate
Definition GPNEB.h:839
bool rgmin_initial_log_move_whole_session
Definition GPNEB.h:739
double ci_stencil_step
Definition GPNEB.h:856
bool climbing_image_converged_only
Definition GPNEB.h:328
int oracle_transition_focal_image
Definition GPNEB.h:546
bool use_geodesic_image_prior
Definition GPNEB.h:421
double gp_local_pair_split
Definition GPNEB.h:949
double gp_local_fraction
Definition GPNEB.h:886
const double * oracle_noise_rms
Definition GPNEB.h:270
double trust_adaptive_A
Definition GPNEB.h:1173
double gp_local_noise
Definition GPNEB.h:909
bool oie_fixed_point_measured_step
Definition GPNEB.h:825
double spring_constant
Definition GPNEB.h:313
EigenMatrix initial_path
Definition GPNEB.h:538
bool gp_local_keep_memory
Definition GPNEB.h:942
bool use_rigid_null_deflation
Definition GPNEB.h:730
std::function< bool( const NEBPath &path, int ci_image_idx, int outer_iter, double ci_force, double max_chain_energy_variance, double posterior_variance_threshold, bool current_chain_certificate, bool planned_current_chain_or_ci, const ActiveLearningSession *session)> OieInnerHandoffPriority
Definition GPNEB.h:1247
double gp_local_grow_radius
Definition GPNEB.h:936
std::string gp_population_prior
Population prior table (gpr/prior/PopulationPrior.h); empty is none.
Definition GPNEB.h:722
int hssvd_dual_randomized_sketch
Definition GPNEB.h:765
PriorMeanStatistic prior_mean_statistic
Definition GPNEB.h:697
double spring_constant_min
Definition GPNEB.h:315
bool use_chem_factorized_hyper
Definition GPNEB.h:684
std::function< bool(const NEBPath &path, int ci_image_idx, int outer_iter, double ci_force)> CurrentCiOraclePriority
Definition GPNEB.h:1239
bool use_virtual_observations
Definition GPNEB.h:595
int adaptive_prune_max_observations
Definition GPNEB.h:640
bool use_hssvd_objective_contractions
Definition GPNEB.h:760
double gp_local_far_refresh
Definition GPNEB.h:918
bool use_lognormal_magn_prior
Definition GPNEB.h:720
bool kernel_support_freezes_band
Definition GPNEB.h:343
double gp_local_pair_tail_refresh
Definition GPNEB.h:950
double hssvd_dual_chop_tol
Definition GPNEB.h:764
double attempt_wall_seconds
Definition GPNEB.h:482
bool evidence_refit_trigger
Definition GPNEB.h:749
std::function< bool()> oracle_session_restart_requested
Definition GPNEB.h:279
std::vector< OuterIterCompositionTraceRecord > composition_trace
Definition GPNEB.h:3756
bool index_refused
A force-quiet point failed the index-1 gate and no budget remains.
Definition GPNEB.h:3690
Eigen::MatrixXd force_stop_positions
Definition GPNEB.h:3768
double ci_reverse_barrier_energy
Definition GPNEB.h:3747
double force_stop_negative_pair_upper
Definition GPNEB.h:3785
bool index_checked
The vibrational-index gate ran on this result.
Definition GPNEB.h:3688
long cholesky_factorizations
Dense Cholesky factorizations of that GP's training covariance.
Definition GPNEB.h:3792
Eigen::MatrixXd force_stop_modes
Lowest Cartesian modes of the measured Hessian, lowest first.
Definition GPNEB.h:3774
double ci_barrier_energy
Definition GPNEB.h:3746
GPNEBStopReason stop_reason
Definition GPNEB.h:3684
std::vector< OieBandTraceRecord > band_trace
Definition GPNEB.h:3753
Eigen::VectorXd force_stop_energies
Definition GPNEB.h:3772
Eigen::MatrixXd force_stop_refinement_positions
Definition GPNEB.h:3781
double force_stop_negative_upper
Definition GPNEB.h:3783
int oracle_calls_to_convergence() const
Definition GPNEB.h:3795
double returned_true_force
Definition GPNEB.h:3730
bool force_stop_center_reused
Definition GPNEB.h:3776
GPNEBConvergenceStatus convergence_status
Definition GPNEB.h:3685
bool force_stop_refinement_recorded
Definition GPNEB.h:3786
std::array< std::optional< gpr::htst::Half >, 3 > harmonic_halves
Definition GPNEB.h:3803
Eigen::MatrixXd force_stop_gradients
Definition GPNEB.h:3771
double reverse_barrier_energy
Definition GPNEB.h:3739
Eigen::MatrixXd force_stop_refinement_gradients
Definition GPNEB.h:3782
double force_stop_positive_lower
Definition GPNEB.h:3784
bool index_continue
The gate stepped the climbing image; the caller resumes the search.
Definition GPNEB.h:3692
bool force_stop_deferred
The saddle owns the index. This stage did not measure a stencil.
Definition GPNEB.h:3765
bool force_stop_refinement_higher_order
Definition GPNEB.h:3787
std::vector< double > max_force_history
Definition GPNEB.h:3748
double force_stop_wall_s
Definition GPNEB.h:3777
double index_resolution
Definition GPNEB.h:3695
int force_stop_certificate_calls
Definition GPNEB.h:3759
std::unique_ptr< NEBPath > path
Definition GPNEB.h:3682
Eigen::MatrixXd force_stop_directions
Orthonormal Cartesian directions of that stencil, one column each.
Definition GPNEB.h:3770
double force_stop_displacement
Definition GPNEB.h:3775
bool force_stop_inconclusive
The stencil was measured and did not resolve an index.
Definition GPNEB.h:3767
Predictive variance of one joint energy-and-gradient observation.