25#ifndef GPR_NEB_OCINEB_CONTROLLER_H_
26#define GPR_NEB_OCINEB_CONTROLLER_H_
36#include <unordered_map>
143struct MmfRecoveryCandidate {
145 double curvature = 0.0;
146 double recovery_force = std::numeric_limits<double>::infinity();
147 double displacement = std::numeric_limits<double>::infinity();
148 double saddle_energy = std::numeric_limits<double>::infinity();
149 bool saddle_certified =
false;
150 bool path_mode_certified =
false;
151 bool measured_descent_certified =
false;
154struct MmfRecoverySelectionStats {
155 int negative_curvature_candidates = 0;
156 int invalid_candidates = 0;
157 int force_improving_candidates = 0;
158 int out_of_trust_candidates = 0;
159 int directional_out_of_trust_candidates = 0;
160 int threshold_rejected_candidates = 0;
161 int no_trust_threshold_rejected_candidates = 0;
162 int certified_lower_energy_candidates = 0;
163 int uncertified_lower_energy_candidates = 0;
164 int uncertified_energy_descent_candidates = 0;
165 int accepted_candidates = 0;
168struct MmfRecoveryPhaseEvidence {
169 double energy = std::numeric_limits<double>::quiet_NaN();
170 Eigen::VectorXd gradient;
171 bool oracle_certified =
false;
177[[nodiscard]] MmfRecoveryPhaseEvidence recordedMmfRecoveryPhaseEvidence(
178 const atmd::AtomicDimer::DimerPhaseRecord& phase,
double energy_zero,
179 Eigen::Index expected_dimension);
181void appendAcceptedMmfRecoveryObservation(ActiveLearningSession& session,
182 int image_idx,
const Image& accepted);
184struct MmfRecoveryAcceptanceDecision {
185 bool accepted =
false;
186 bool finite_input =
false;
187 bool force_improves =
false;
188 bool has_displacement_trust =
false;
189 bool within_displacement_trust =
false;
190 bool lower_valid_saddle_energy =
false;
191 bool uncertified_energy_descent =
false;
195 bool measured_trust_bounded_progress =
false;
196 bool measured_path_continuation =
false;
197 bool threshold_limited =
false;
198 bool threshold_passed =
false;
201[[nodiscard]] MmfRecoveryAcceptanceDecision classifyMmfRecovery(
202 double pre_force,
double recovery_force,
double recovery_displacement,
203 double max_displacement,
double acceptance_force_threshold,
204 bool keep_force_improving_burst,
205 double reference_saddle_energy = std::numeric_limits<double>::quiet_NaN(),
206 double candidate_saddle_energy = std::numeric_limits<double>::quiet_NaN(),
207 double reactant_energy = std::numeric_limits<double>::quiet_NaN(),
208 double product_energy = std::numeric_limits<double>::quiet_NaN(),
209 bool candidate_saddle_certified =
false,
210 bool candidate_path_mode_certified =
false,
211 bool candidate_measured_descent_certified =
false);
213[[nodiscard]]
bool shouldAcceptMmfRecovery(
214 double pre_force,
double recovery_force,
double recovery_displacement,
215 double max_displacement,
double acceptance_force_threshold,
216 bool keep_force_improving_burst,
217 double reference_saddle_energy = std::numeric_limits<double>::quiet_NaN(),
218 double candidate_saddle_energy = std::numeric_limits<double>::quiet_NaN(),
219 double reactant_energy = std::numeric_limits<double>::quiet_NaN(),
220 double product_energy = std::numeric_limits<double>::quiet_NaN(),
221 bool candidate_saddle_certified =
false,
222 bool candidate_path_mode_certified =
false,
223 bool candidate_measured_descent_certified =
false);
225[[nodiscard]]
bool shouldRejectUncertifiedMmfRecoveryHandback(
226 double recovery_force,
double recovery_displacement,
227 double max_displacement,
double force_tolerance);
229[[nodiscard]]
double effectiveMmfRecoveryDisplacementCap(
double configured_cap,
231 double right_spacing);
233[[nodiscard]]
bool shouldRejectUncertifiedHelpedDisplacement(
234 bool dimer_converged,
bool helped_angle_certified,
235 double helped_displacement,
double max_displacement);
240[[nodiscard]]
bool shouldRejectForceOnlyHelpedBelowEndpoints(
241 bool dimer_converged,
bool helped_angle_certified,
242 double dimer_final_energy,
double reactant_energy,
double product_energy);
244[[nodiscard]] std::string forceOnlyHelpedBelowEndpointDiagnostic(
245 double dimer_final_energy,
double reactant_energy,
double product_energy);
247[[nodiscard]] std::string trustedRecoveryAdvanceDiagnostic(
249 int recovery_phase, std::size_t phase_count,
double curvature,
250 double recovery_baseline,
double recovery_force,
double raw_pre_force,
251 double raw_force,
double reference_energy,
double candidate_energy,
252 double reactant_energy,
double product_energy,
bool saddle_certified);
255[[nodiscard]]
double mmfRecoveryForceBaseline(
double pre_neb_force,
256 double pre_raw_force);
258[[nodiscard]]
int chooseMmfRecoveryPhase(
259 const std::vector<MmfRecoveryCandidate>& candidates,
double pre_force,
260 double max_displacement,
double acceptance_force_threshold,
261 bool keep_force_improving_burst,
262 double reference_saddle_energy = std::numeric_limits<double>::quiet_NaN(),
263 double reactant_energy = std::numeric_limits<double>::quiet_NaN(),
264 double product_energy = std::numeric_limits<double>::quiet_NaN(),
265 MmfRecoverySelectionStats* stats =
nullptr,
266 bool allow_directional_out_of_trust_recovery =
false);
268[[nodiscard]]
bool shouldRetainMmfObservation(
269 const Eigen::VectorXd& positions,
const Eigen::VectorXd& anchor,
270 const gpr::AtomsConfiguration& atoms_config,
double max_displacement);
272[[nodiscard]]
bool shouldCommitMmfObservation(
273 const Eigen::VectorXd& positions,
const Eigen::VectorXd& anchor,
274 const gpr::AtomsConfiguration& atoms_config,
double max_displacement);
276[[nodiscard]]
bool shouldHarvestRejectedMmfObservation(
277 bool helped,
bool trusted_recovery_advanced,
278 const Eigen::VectorXd& positions,
const Eigen::VectorXd& anchor,
279 const gpr::AtomsConfiguration& atoms_config,
double max_displacement);
281[[nodiscard]]
double successThresholdAfterMmf(
double handoff_force,
283 double baseline_threshold);
285[[nodiscard]]
double rejectedMmfBackoffThreshold(
double current_force,
286 double force_tolerance,
287 double baseline_threshold);
292enum class MmfInformationGate : std::uint8_t {
294 AwaitingFirstTrainingGrowth = 1,
297 AwaitingActionChange = 3,
300using MmfSurrogateFingerprint = ActiveLearningSession::SurrogateFingerprint;
303struct MmfPosteriorActionFingerprint {
304 MmfSurrogateFingerprint surrogate;
305 atmd::DimerSurrogateActionCertificate action;
308[[nodiscard]] MmfPosteriorActionFingerprint probeMmfPosteriorAction(
309 ActiveLearningSession& session,
int image_idx,
bool dimer_use_global_gp,
310 const Eigen::VectorXd& seed,
const Eigen::VectorXd& seed_gradient,
311 const Eigen::VectorXd& initial_mode,
const GPNEBConfig& neb_config,
312 const OCINEBConfig& oci_config);
316[[nodiscard]]
bool mmfPosteriorActionChanged(
317 const MmfPosteriorActionFingerprint& action_now,
318 const MmfPosteriorActionFingerprint& action_at_last_reject);
322[[nodiscard]] MmfInformationGate advanceMmfInformationGateOnSurrogateChange(
323 MmfInformationGate gate,
const MmfSurrogateFingerprint& surrogate_now,
324 const MmfSurrogateFingerprint& surrogate_at_last_reject,
325 bool* refresh_snapshot);
327[[nodiscard]]
bool mmfSurrogateChanged(
328 const MmfSurrogateFingerprint& surrogate_now,
329 const MmfSurrogateFingerprint& surrogate_at_last_reject);
331[[nodiscard]]
bool shouldSuppressMmfUntilTrainingGrows(MmfInformationGate gate);
333[[nodiscard]]
double mmfThresholdForce(
double neb_force,
double raw_force);
338[[nodiscard]]
bool ciPosteriorConfident(
const NEBPath& path,
int ci_idx,
346[[nodiscard]]
bool isPrematureForceOnlyHelped(
bool is_helped_status,
347 bool force_certified,
348 bool helped_angle_certified,
349 int ci_stable_outer_count,
350 bool helped_negative_curvature);
356[[nodiscard]]
bool forceOnlyHelpedPathCertified(
bool helped_angle_certified,
358 double alignment_cos_tol);
362[[nodiscard]]
bool shouldSearchMmfRecoveryPortfolio(
bool dimer_converged,
363 bool helped_ran_away,
364 bool helped_path_certified,
365 bool found_saddle_mode);
367[[nodiscard]]
bool mmfForceCertifiedForConvergence(
double dimer_force,
369 double force_tolerance);
376[[nodiscard]]
bool mmfBurstConvergedAfterAcceptance(
378 double final_mode_curvature,
bool helped_path_certified =
false);
380[[nodiscard]]
bool applyDimerSaddleSummary(GPNEBResult& result,
381 int dimer_saddle_image_idx);
383[[nodiscard]]
bool shouldPureLockAfterMmfReject(
386[[nodiscard]]
bool shouldPureLockAfterMmfReject(
388 bool adaptive_threshold_seeded,
393[[nodiscard]]
bool isRecoveryPortfolioExhaustedReject(
394 bool recovery_selection_exhausted,
int accepted_candidates);
398[[nodiscard]]
bool isMmfRecoveryPortfolioExhausted(
bool found_saddle_mode,
400 int accepted_candidates);
409[[nodiscard]]
bool shouldAcquireMmfMinModeProbe(
410 bool found_saddle_mode,
int selected_phase,
int accepted_candidates,
411 int negative_curvature_candidates,
int force_improving_candidates,
412 int out_of_trust_candidates = 0);
417[[nodiscard]]
bool shouldHoldMmfForExpectedImprovement(
418 bool wait_for_true_sample, Eigen::Index ntrain,
419 Eigen::Index ntrain_at_hold);
424[[nodiscard]]
double mmfMinModeProbeStep(
double recovery_disp_cap,
426 double max_burst_displacement);
430[[nodiscard]] Eigen::VectorXd minModeProbePosition(
const Eigen::VectorXd& seed,
431 const Eigen::VectorXd& mode,
434[[nodiscard]]
bool isMmfAdaptiveThresholdSeeded(
double current_threshold);
438[[nodiscard]]
bool shouldLeaseAfterPureRejectProgress(
439 bool pure_reject_lock,
bool improved_under_backoff,
440 bool improved_since_pure_reject =
false);
448[[nodiscard]]
bool shouldLeaseAfterExhaustedQuietStall(
449 bool pure_reject_lock,
bool exhausted_recovery_reject_applies,
450 bool oie_quiet_handoff_stalled,
bool oie_acquisition_quiet,
451 bool current_chain_certificate,
bool current_saddle_stencil_certificate,
452 bool ci_posterior_confident,
bool ci_is_energy_maximum);
457[[nodiscard]]
bool shouldBlockRejectedSeedReplay(
458 bool rejected_seed_replay,
bool trap_detected,
459 bool improved_since_pure_reject,
bool exhausted_quiet_stall_lease);
463[[nodiscard]]
bool shouldSkipMmfAfterSpentMinModeProbe(
464 bool min_mode_probe_spent,
bool rejected_seed_replay,
465 bool rejected_seed_position_matches);
469[[nodiscard]]
bool isTruePesRecoverySaddleEnergyCertified(
470 double true_energy,
double reactant_energy,
double product_energy);
474[[nodiscard]]
bool isTruePesRecoverySaddleCertified(
double true_energy,
475 double recovery_force,
476 double force_tolerance,
477 double reactant_energy,
478 double product_energy);
484struct PureLockHopState {
485 bool pure_reject_lock =
false;
486 double pure_reject_force = std::numeric_limits<double>::quiet_NaN();
487 bool force_improving_recovery_active =
false;
488 bool trusted_recovery_active =
false;
490[[nodiscard]] PureLockHopState pureLockStateAfterCiHop(PureLockHopState state);
492[[nodiscard]]
double resolveMmfSeedDisplacement(
493 double configured_displacement,
bool force_improving_recovery_active,
494 bool trusted_recovery_active);
499[[nodiscard]]
bool shouldImmediateRereleaseAfterFi(
500 bool force_improving_recovery_active,
double post_force,
501 double current_threshold,
double force_tolerance);
503[[nodiscard]]
bool shouldImmediateRereleaseAfterOciRecovery(
504 bool force_improving_recovery_active,
bool trusted_recovery_active,
505 double post_force,
double current_threshold,
double force_tolerance,
506 bool current_saddle_stencil_certificate =
false);
508[[nodiscard]]
bool shouldImmediateRereleaseAfterOciRecovery(
509 const MMFRunResult& burst,
double current_threshold,
double force_tolerance,
510 bool current_saddle_stencil_certificate =
false);
515[[nodiscard]]
bool mmfAttemptConsumedAfterRecovery(
516 bool mmf_attempted,
bool trusted_recovery_advanced,
517 bool requires_outer_path_refresh);
523template <
typename ThresholdProvider,
typename StencilProvider,
524 typename SessionRestartProvider,
typename RereleaseRunner>
525MMFRunResult continueImmediateOciRecovery(
526 MMFRunResult burst,
double force_tolerance,
527 ThresholdProvider current_threshold, StencilProvider current_stencil,
528 SessionRestartProvider session_restart_requested, RereleaseRunner rerelease)
530 const std::function<bool()> restart_requested =
531 std::move(session_restart_requested);
533 throwIfOracleSessionRestartRequested(restart_requested);
534 if (burst.convergedAfterMMF)
break;
535 const double threshold = current_threshold();
536 if (!shouldImmediateRereleaseAfterOciRecovery(
537 burst, threshold, force_tolerance, current_stencil())) {
540 burst = rerelease(burst, threshold);
545template <
typename ThresholdProvider,
typename StencilProvider,
546 typename RereleaseRunner>
547MMFRunResult continueImmediateOciRecovery(MMFRunResult burst,
548 double force_tolerance,
549 ThresholdProvider current_threshold,
550 StencilProvider current_stencil,
551 RereleaseRunner rerelease)
553 return continueImmediateOciRecovery(
554 std::move(burst), force_tolerance, std::move(current_threshold),
555 std::move(current_stencil), [] {
return false; }, std::move(rerelease));
558[[nodiscard]]
bool shouldPreserveFiRecoveryGateAfterRetry(
559 bool force_improving_recovery_active,
double pre_force,
560 double current_threshold,
double force_tolerance,
561 bool recovery_selection_exhausted =
false);
563[[nodiscard]]
bool shouldPreserveTrustedRecoveryGateAfterRetry(
565 bool trusted_recovery_advanced,
bool rejected_helped_handback,
567 bool recovery_selection_exhausted =
false);
569[[nodiscard]]
bool shouldRecordRejectedSeedForRecoveryGate(
570 bool preserve_fi_recovery_gate,
bool preserve_trusted_recovery_gate);
572[[nodiscard]]
double trustedRetryRejectForceAfterRetry(
573 bool preserve_trusted_recovery_gate,
574 double existing_trusted_retry_reject_force,
double retry_reject_force);
576[[nodiscard]]
bool shouldHarvestAcceptedRecoveryObservation(
577 bool trusted_recovery_advanced);
579[[nodiscard]]
bool shouldKeepTrustedRecoveryGateAfterAdvance(
580 bool trusted_recovery_advanced,
bool force_improved);
585[[nodiscard]]
bool shouldPromoteCurrentCiHandoffMismatchToTrap(
586 int handoff_outer_iter,
int hook_outer_iter,
double gp_force,
587 double oracle_force,
double handoff_threshold);
591[[nodiscard]]
bool shouldRefreshCurrentCiHandoffPrediction(
592 bool pending_request,
int pending_ci,
bool current_request,
593 int current_ci)
noexcept;
600[[nodiscard]]
bool isBandInformationExhaustedForMmf(
601 double max_chain_energy_variance,
double likelihood_noise_variance,
602 double posterior_variance_threshold,
double inner_unc_relative);
609[[nodiscard]]
bool isOieAcquisitionQuietForMmf(
610 double max_chain_energy_variance,
double posterior_variance_threshold);
615[[nodiscard]]
bool hasCurrentOciSaddleStencilCertificate(
616 const ActiveLearningSession& session,
const NEBPath& path,
int ci_idx);
622[[nodiscard]]
bool isOracleTransitionFocalHandoff(
623 int configured_focal_image,
int ci_image_idx,
624 bool current_chain_certificate,
bool current_saddle_stencil_certificate);
630[[nodiscard]]
bool isOciMmfHandoffDataReady(
631 bool band_acquisition_quiet,
bool current_saddle_stencil_certificate,
632 bool ci_posterior_confident,
bool ci_is_energy_maximum);
634[[nodiscard]]
bool isForceImprovingRecoveryStalledHandoff(
635 bool force_improving_recovery_active,
bool ci_posterior_confident,
636 bool current_chain_certificate,
bool oie_acquisition_quiet,
637 bool oie_quiet_handoff_stalled);
639[[nodiscard]]
bool isTrustedRecoveryStalledHandoff(
640 bool trusted_recovery_active,
bool ci_posterior_confident,
641 bool current_chain_certificate,
bool ci_is_energy_maximum,
642 bool oie_acquisition_quiet,
bool oie_quiet_handoff_stalled);
644[[nodiscard]]
bool shouldUseTrustedRecoveryStalledHandoff(
645 bool trusted_retry_progress_pending,
bool trusted_recovery_stalled_handoff);
647[[nodiscard]]
bool isTrustedRecoveryProgressHandoff(
648 bool trusted_recovery_active,
double trusted_retry_reject_force,
649 double conv_force,
double current_threshold,
bool ci_posterior_confident,
650 bool ci_is_energy_maximum,
bool rejected_seed_replay,
651 bool current_chain_certificate,
bool oie_quiet_handoff_stalled,
652 bool oie_acquisition_quiet);
654[[nodiscard]]
bool isCurrentChainCertifiedHandoff(
655 bool trusted_retry_progress_pending,
bool current_chain_certificate,
656 bool rejected_seed_replay,
bool ci_posterior_confident,
657 bool ci_is_energy_maximum,
bool oie_acquisition_quiet,
658 bool exhausted_recovery_reject_active =
false);
660[[nodiscard]]
bool exhaustedRecoveryRejectAppliesToCi(
661 bool exhausted_recovery_reject_active,
long reject_climbing_image,
662 long climbing_image);
666[[nodiscard]]
bool shouldRequestCurrentCiOracleForExhaustedRecovery(
667 bool exhausted_recovery_reject_active,
long reject_climbing_image,
668 long climbing_image);
672[[nodiscard]]
bool isRefreshedExhaustedRecoveryHandoff(
673 bool exhausted_recovery_reject_applies,
bool current_chain_certificate,
674 bool current_saddle_stencil_certificate,
bool rejected_seed_replay,
675 bool rejected_seed_position_matches,
bool ci_posterior_confident,
676 bool ci_is_energy_maximum);
680[[nodiscard]]
bool activeMmfRecoveryOwnsClimbingImage(
681 bool force_improving_recovery_active,
bool trusted_recovery_active);
683[[nodiscard]]
int activeOieRecoveryOwnerImage(
684 int recorded_owner_image,
int current_ci_image,
685 bool force_improving_recovery_active,
bool trusted_recovery_active);
690[[nodiscard]]
bool shouldHoldOieFixedImage(
bool force_improving_recovery_active,
691 bool trusted_recovery_active);
693[[nodiscard]]
bool shouldHoldOieFixedImage(
bool force_improving_recovery_active,
694 bool trusted_recovery_active,
695 bool rejected_recovery_seed);
697[[nodiscard]]
bool shouldRequestOieRecoveryModelGrowth(
698 bool force_improving_recovery_active,
bool trusted_recovery_active,
699 bool rejected_recovery_seed, MmfInformationGate info_gate);
701[[nodiscard]]
bool shouldSuppressMmfRecoveryRetry(
702 bool force_improving_recovery_active,
bool trusted_recovery_active,
703 MmfInformationGate info_gate);
705[[nodiscard]]
bool shouldReleaseOieRecoveryForCertifiedHandover(
706 bool active_recovery,
int recovery_owner_image,
int candidate_image,
707 bool candidate_posterior_confident,
bool candidate_chain_certificate,
708 bool candidate_saddle_stencil_certificate);
710[[nodiscard]]
bool shouldReleaseOieExhaustedRecoveryForCertifiedHandover(
711 bool exhausted_recovery_reject_active,
int rejected_image,
712 int candidate_image,
bool candidate_posterior_confident,
713 bool candidate_chain_certificate,
714 bool candidate_saddle_stencil_certificate);
716[[nodiscard]]
bool shouldReleaseOieRecoveryForInvalidatedOwner(
717 bool active_recovery,
int recovery_owner_image,
int retry_image,
718 bool recovery_model_growth_ready,
bool band_force_converged,
719 bool owner_chain_certificate,
bool owner_saddle_stencil_certificate,
720 bool owner_posterior_confident,
bool owner_is_energy_maximum);
722[[nodiscard]]
bool shouldAdvanceOieRecoveryInformationGate(
723 bool active_recovery,
int recovery_owner_image,
int retry_image);
725[[nodiscard]] OieFixedImageLease makeOieRecoveryFixedImageLease(
726 int ci_image_idx,
bool force_improving_recovery_active,
727 bool trusted_recovery_active,
bool rejected_recovery_seed,
728 MmfInformationGate info_gate,
bool recovery_retry_blocked =
false);
732[[nodiscard]] OieFixedImageLease makeOieExhaustedRecoveryFixedImageLease(
733 int ci_image_idx,
bool exhausted_recovery_reject_active,
734 long reject_climbing_image);
739[[nodiscard]] OieFixedImageLease makeOieExhaustedRecoveryEvidenceLease(
740 int ci_image_idx,
bool exhausted_recovery_reject_active,
741 long reject_climbing_image,
int candidate_image);
743[[nodiscard]]
bool isOieRecoveryOwnerModelGrowthReady(
744 bool model_growth_requested,
const MmfSurrogateFingerprint& surrogate_now,
745 const MmfSurrogateFingerprint& surrogate_at_request);
747[[nodiscard]]
bool isOieRecoveryModelGrowthCertified(
748 int recovery_owner_image,
int retry_image,
bool recovery_model_growth_ready,
749 bool current_chain_certificate,
bool current_saddle_stencil_certificate,
750 bool recovery_owner_is_energy_maximum);
752[[nodiscard]]
bool isOieExhaustedRecoveryModelGrowthCertified(
753 int recovery_owner_image,
int retry_image,
bool recovery_model_growth_ready,
754 bool current_chain_certificate,
bool current_saddle_stencil_certificate,
755 bool recovery_owner_is_energy_maximum,
bool rejected_seed_replay);
757[[nodiscard]]
bool shouldUseSurfaceUpdatedTrapRetryForCurrentCiOracle(
758 bool trap_surface_updated,
bool trusted_recovery_active,
759 double trusted_retry_reject_force,
double conv_force,
760 double current_threshold);
762[[nodiscard]]
bool shouldRetireTrustedRetryAfterProgress(
763 bool trusted_recovery_active,
double trusted_retry_reject_force,
764 double conv_force,
double current_threshold);
766[[nodiscard]]
bool shouldTriggerMmf(
767 const OCINEBConfig& cfg,
double convForce,
bool ci_active,
768 long climbingImage,
long numImages,
bool ci_posterior_confident,
769 double current_threshold,
bool trap_detected,
bool trap_backoff_active,
770 bool trap_surface_updated =
false,
771 MmfInformationGate info_gate = MmfInformationGate::Open,
772 bool ci_is_energy_maximum =
false,
bool band_information_exhausted =
false,
773 bool oie_acquisition_quiet =
false,
bool oie_acquisition_stalled =
false,
774 bool certified_recovery_stalled_handoff =
false,
775 bool certified_handoff =
false);
777[[nodiscard]]
double resolveDimerVarianceTauRelative(
778 const GPNEBConfig& neb_config,
const OCINEBConfig& oci_config);
780[[nodiscard]]
bool shouldInstallOciMmfHook(
const GPNEBConfig& neb_config,
781 const OCINEBConfig& oci_config);
786[[nodiscard]]
bool shouldUseHssvdAnalyticDimerCurvature(
787 const GPNEBConfig& neb_config);
788[[nodiscard]]
bool shouldUseHssvdAnalyticDimerCurvature(
789 const GPNEBConfig& neb_config,
bool has_spectral_posterior);
791[[nodiscard]]
double resolveOciForceTolerance(
const OCINEBConfig& oci_config);
796[[nodiscard]]
double mmfLeaseForceTolerance(
const OCINEBConfig& oci_config);
798[[nodiscard]] gpr::InputParameters buildDimerParameters(
799 const GPNEBConfig& neb_config,
const OCINEBConfig& oci_config,
800 gpr::AtomsConfiguration& tmp);
802[[nodiscard]] gpr::InputParameters buildDimerParameters(
803 const GPNEBConfig& neb_config,
const OCINEBConfig& oci_config,
804 gpr::AtomsConfiguration& tmp,
bool use_analytic_hssvd);
959 std::numeric_limits<double>::quiet_NaN();
960 detail::MmfInformationGate
info_gate = detail::MmfInformationGate::Open;
978[[nodiscard]] std::vector<StagedDimerObservation> stageDimerObservationUpdates(
981 double energy_origin);
1001 return baseline_force_ > 0.0;
1004 bool handoff_data_ready =
false);
1010 bool trap_detected =
false,
bool band_information_exhausted =
false,
1011 bool current_chain_certificate =
false)
const;
1023 bool shouldTrigger(
double convForce,
bool ci_active,
long climbingImage,
1024 long numImages,
bool ci_posterior_confident,
1025 bool trap_detected =
false, std::size_t ntrain_now = 0,
1026 bool ci_is_energy_maximum =
false,
1027 bool band_information_exhausted =
false,
1028 bool oie_acquisition_quiet =
false,
1029 bool rejected_seed_replay =
false,
1030 bool current_chain_certificate =
false,
1031 bool current_saddle_stencil_certificate =
false,
1032 bool rejected_seed_position_matches =
false,
1033 bool stagnation_handoff =
false)
const;
1041 detail::MmfSurrogateFingerprint surrogate);
1045 detail::MmfPosteriorActionFingerprint action);
1058 min_mode_probe_spent_ =
true;
1059 pending_min_mode_probe_lease_ =
false;
1060 trap_surface_updated_ =
false;
1061 uncertified_hook_reject_active_ =
false;
1074 const Eigen::VectorXd& owner_position,
long owner_image);
1091 const Eigen::VectorXd& ci_position,
1092 detail::MmfSurrogateFingerprint surrogate_now,
long climbingImage = -1)
1094 if (uncertified_hook_reject_active_)
return;
1095 if (detail::shouldSuppressMmfRecoveryRetry(
1096 force_improving_recovery_active_, trusted_recovery_active_,
1110 mmf_info_gate_ = detail::MmfInformationGate::Open;
1119 const Eigen::VectorXd& ci_position,
1121 long climbingImage = -1)
const;
1126 const Eigen::VectorXd& ci_position,
1127 detail::MmfSurrogateFingerprint surrogate,
long climbingImage = -1,
1131 const Eigen::VectorXd& ci_position,
1132 const detail::MmfPosteriorActionFingerprint& action,
1133 long climbingImage = -1,
1139 long climbingImage = -1)
1141 mmf_reject_ci_position_ = ci_position;
1142 mmf_reject_climbing_image_ = climbingImage;
1148 double convForce,
const Eigen::VectorXd& ci_position,
1149 detail::MmfSurrogateFingerprint surrogate,
long climbingImage = -1);
1152 double convForce,
const Eigen::VectorXd& ci_position,
1153 detail::MmfPosteriorActionFingerprint action,
long climbingImage = -1);
1158 long climbingImage,
long numImages,
int outerIter,
1159 bool ci_posterior_confident,
1160 bool trap_detected =
false,
1161 std::size_t ntrain_now = 0,
1162 bool ci_is_energy_maximum =
false);
1185 bool trap_detected =
false);
1190 return current_threshold_;
1196 return {current_threshold_,
1198 soft_quiet_blocked_after_reject_,
1200 trap_backoff_active_,
1201 trap_surface_updated_,
1202 uncertified_hook_reject_active_,
1203 oie_quiet_handoff_stalled_,
1204 force_improving_recovery_active_,
1205 trusted_recovery_active_,
1206 exhausted_recovery_reject_active_,
1207 trusted_retry_reject_force_,
1209 mmf_surrogate_at_last_reject_,
1210 mmf_reject_climbing_image_,
1211 recovery_owner_image_};
1218 void runBurstUnderSessionModelLease(
1223 std::vector<StagedDimerObservation>& staged_dimer_observations);
1228 void runBurstOnTruePotential(
1231 const Eigen::VectorXd& initialMode,
1233 double pre_neb_force,
bool has_gp,
MMFRunResult& result,
1234 std::vector<StagedDimerObservation>& staged_dimer_observations);
1239 void recordBurstOutcome(
NEBPath& path,
int ci_image_idx,
1242 const Eigen::VectorXd& savedPositions,
1243 bool adaptive_threshold_seeded,
bool force_improved,
1244 double threshold_pre_force,
1247 struct CiAdaptiveState {
1248 double current_threshold = -1.0;
1249 double baseline_force = -1.0;
1250 bool trap_backoff_active =
false;
1251 bool trap_surface_updated =
false;
1252 bool has_cached_mode =
false;
1253 bool mmf_attempted =
false;
1254 bool soft_quiet_blocked_after_reject =
false;
1255 bool uncertified_hook_reject_active =
false;
1256 bool oie_quiet_handoff_stalled =
false;
1257 bool exhausted_recovery_reject_active =
false;
1258 double best_oie_quiet_handoff_force =
1259 std::numeric_limits<double>::quiet_NaN();
1260 double trusted_retry_reject_force =
1261 std::numeric_limits<double>::quiet_NaN();
1262 Eigen::VectorXd cached_mode;
1266 [[nodiscard]]
double forceTolerance()
const;
1267 [[nodiscard]] std::optional<Eigen::VectorXd> initialModeForPath(
1268 const NEBPath& path,
int ci_image_idx)
const;
1271 double current_threshold_ = -1.0;
1272 double baseline_force_ = -1.0;
1277 bool soft_quiet_blocked_after_reject_ =
false;
1284 bool pure_reject_lock_ =
false;
1287 double pure_reject_force_ = std::numeric_limits<double>::quiet_NaN();
1291 long previousClimbingImage_ = -1;
1292 int lastStabilityOuter_ = -1;
1293 long lastStabilityClimbingImage_ = -1;
1294 long mmf_iterations_used_ = 0;
1295 long mmf_bursts_fired_ = 0;
1296 bool mmf_attempted_ =
false;
1297 bool trap_backoff_active_ =
false;
1298 bool trap_surface_updated_ =
false;
1299 bool uncertified_hook_reject_active_ =
false;
1300 bool oie_quiet_handoff_stalled_ =
false;
1301 bool force_improving_recovery_active_ =
false;
1302 bool trusted_recovery_active_ =
false;
1303 int recovery_owner_image_ = -1;
1304 bool exhausted_recovery_reject_active_ =
false;
1305 bool pending_min_mode_probe_lease_ =
false;
1306 bool min_mode_probe_spent_ =
false;
1307 bool mmf_wait_for_true_sample_ =
false;
1308 Eigen::Index mmf_wait_ntrain_ = 0;
1309 double trusted_retry_reject_force_ =
1310 std::numeric_limits<double>::quiet_NaN();
1311 double best_oie_quiet_handoff_force_ =
1312 std::numeric_limits<double>::quiet_NaN();
1313 detail::MmfInformationGate mmf_info_gate_ =
1314 detail::MmfInformationGate::Open;
1315 detail::MmfSurrogateFingerprint mmf_surrogate_at_last_reject_;
1316 detail::MmfPosteriorActionFingerprint mmf_action_at_last_reject_;
1317 Eigen::VectorXd mmf_reject_ci_position_;
1318 long mmf_reject_climbing_image_ = -1;
1323 bool has_cached_mode_ =
false;
1324 Eigen::VectorXd cached_mode_;
1325 std::unordered_map<long, CiAdaptiveState> ci_adaptive_state_;
1327 void saveAdaptiveState(
long climbingImage);
1328 void loadAdaptiveState(
long climbingImage);
1329 void retireTrustedRetryIfProgressed(
double handoff_force);
1330 void updateThresholdSuccess(
double convForce,
double newForce);
1331 void updateThresholdBackoff(
double convForce);
1384 const bool converged =
1419 const int neb_breakdown =
1420 neb.oracle_calls_endpoints +
neb.oracle_calls_initial +
1421 neb.oracle_calls_outer +
neb.oracle_calls_validation;
1422 if (neb_breakdown !=
neb.oracle_calls ||
1424 throw std::logic_error(
"inconsistent OCINEB oracle accounting");
1427 endpoints_ +=
neb.oracle_calls_endpoints;
1428 initial_ +=
neb.oracle_calls_initial;
1429 outer_ +=
neb.oracle_calls_outer;
1430 validation_ +=
neb.oracle_calls_validation;
1432 outer_iterations_ +=
neb.outer_iterations;
1433 hyperparameter_refits_ +=
neb.hyperparameter_refits;
1434 fixed_theta_refreshes_ +=
neb.fixed_theta_refreshes;
1442 if (calls < 0)
throw std::logic_error(
"negative polish oracle count");
1452 throw std::logic_error(
"negative certificate oracle count");
1453 certificate_ += calls;
1460 throw std::logic_error(
"negative validation oracle count");
1461 validation_ += calls;
1466 const int completed_calls = endpoints_ + initial_ + outer_ +
1467 validation_ + dimer_ + certificate_;
1468 if (provider_calls < completed_calls) {
1469 throw std::logic_error(
1470 "provider oracle count is smaller than completed attempts (" +
1471 std::to_string(provider_calls) +
" < " +
1472 std::to_string(completed_calls) +
")");
1478 summary.
outer = outer_;
1480 summary.
dimer = dimer_;
1482 summary.
transition = provider_calls - completed_calls;
1484 summary.
total = provider_calls;
1496 int validation_ = 0;
1498 int certificate_ = 0;
1499 int outer_iterations_ = 0;
1500 int hyperparameter_refits_ = 0;
1501 int fixed_theta_refreshes_ = 0;
1510 const Eigen::VectorXd& final_state,
int n_images,
1511 const GPNEBConfig& neb_config,
1512 const OCINEBConfig& oci_config,
1513 ActiveLearningSession& session);
1528 const Eigen::VectorXd& final_state,
int n_images,
1529 GPNEBConfig neb_config,
1530 const OCINEBConfig& oci_config,
1531 ActiveLearningSession& session);
1537 const Eigen::VectorXd& initial,
1538 const Eigen::VectorXd& final_state,
int n_images,
1539 const GPNEBConfig& neb_config,
1540 const OCINEBConfig& oci_config,
1541 ActiveLearningSession& session);
1555 double force = std::numeric_limits<double>::quiet_NaN();
1556 double curvature = std::numeric_limits<double>::quiet_NaN();
1558 double energy = std::numeric_limits<double>::quiet_NaN();
1572 const Eigen::VectorXd& x_seed,
double e_seed,
const Eigen::VectorXd& g_seed,
1573 const Eigen::VectorXd& mode_seed,
double energy_ceiling);
GP-accelerated NEB: AIE and OIE variants.
ActiveLearningSession: shared GP + training data across GP-NEB and GP-Dimer phases.
NEB path: chain of images between two endpoints.
void noteMmfRejectActionSnapshot(detail::MmfPosteriorActionFingerprint action)
Enter the information wait with the posterior action MMF would consume.
void recordUncertifiedMmfHookReject(double convForce, const Eigen::VectorXd &ci_position, detail::MmfSurrogateFingerprint surrogate, long climbingImage=-1)
MMFRunResult run(NEBPath &path, int ci_image_idx, NEBOracle &oracle, const GPNEBConfig &neb_config, ActiveLearningSession &session, bool trap_detected=false)
bool wantsCurrentCiOracle(double convForce, bool ci_active, long climbingImage, long numImages, int outerIter, bool ci_posterior_confident, bool trap_detected=false, std::size_t ntrain_now=0, bool ci_is_energy_maximum=false)
void updateStabilityForOuter(long climbingImage, int outerIter)
Idempotent stability update keyed by GP-NEB outer iteration.
void noteMmfRejectSurrogateSnapshot(detail::MmfSurrogateFingerprint surrogate)
Enter AwaitingFirstTrainingGrowth with the model lease MMF consumed.
bool shouldTrigger(double convForce, bool ci_active, long climbingImage, long numImages, bool ci_posterior_confident, bool trap_detected=false, std::size_t ntrain_now=0, bool ci_is_energy_maximum=false, bool band_information_exhausted=false, bool oie_acquisition_quiet=false, bool rejected_seed_replay=false, bool current_chain_certificate=false, bool current_saddle_stencil_certificate=false, bool rejected_seed_position_matches=false, bool stagnation_handoff=false) const
void releaseRecoveryOwnerForCertifiedHandover(const Eigen::VectorXd &owner_position, long owner_image)
OCINEBController(OCINEBConfig cfg)
bool rejectedMmfSeedReplay(const Eigen::VectorXd &ci_position, detail::MmfSurrogateFingerprint surrogate, long climbingImage=-1, const gpr::AtomsConfiguration *atoms_config=nullptr) const
void noteMmfActionChange(detail::MmfPosteriorActionFingerprint action)
void noteMmfSurrogateChange(detail::MmfSurrogateFingerprint surrogate)
void initBaseline(double baseline_force)
OCINEBDiagnostics diagnostics() const
Snapshot of trigger-gate state for verbose run diagnostics.
bool rejectedMmfSeedPositionMatches(const Eigen::VectorXd &ci_position, const gpr::AtomsConfiguration *atoms_config=nullptr, long climbingImage=-1) const
double threshold() const
Current adaptive trigger threshold (eOn ~current_threshold_~).
bool shouldPrepareMmfHandoff(bool trap_detected=false, bool band_information_exhausted=false, bool current_chain_certificate=false) const
void noteMmfMinModeProbeConsumed()
Record that the rejected action consumed a true-potential mode probe.
void openInformationGateAtNoiseFloor(const Eigen::VectorXd &ci_position, detail::MmfSurrogateFingerprint surrogate_now, long climbingImage=-1)
detail::MmfPosteriorActionFingerprint previewMmfAction(ActiveLearningSession &session, const NEBPath &path, int ci_image_idx, const GPNEBConfig &neb_config) const
void noteMmfRejectCiPosition(const Eigen::VectorXd &ci_position, long climbingImage=-1)
void updateStability(long climbingImage)
void releaseExhaustedRecoveryForCertifiedHandover()
void recordMmfPosteriorUpdate()
void recordMmfHandoffForce(double handoff_force, bool handoff_data_ready=false)
OCINEBOracleCallSummary reconcile(int provider_calls) const
void recordPolish(int calls)
void record(const OCINEBResult &attempt)
void recordCertificate(int calls)
void recordValidation(int calls)
Independent force measurements made solely to validate the final saddle.
DimerRelaxationTerminationReason
The nudged elastic band: path, GP-NEB driver, configuration and result, acquisition,...
int reduceOracleProviderCalls(int local_calls)
void certifyOCINEBResult(OCINEBResult &result, NEBOracle oracle, const Eigen::VectorXd &initial, const Eigen::VectorXd &final_state, int active_n_images, const GPNEBConfig &neb_config, const OCINEBConfig &oci_config, ActiveLearningSession &session)
double testingHelpedModeCurvature()
std::function< std::pair< double, Eigen::VectorXd >( const Eigen::VectorXd &positions)> NEBOracle
Oracle function: positions -> (energy, gradient).
OCINEBResult runOCINEB(NEBOracle oracle, const Eigen::VectorXd &initial, const Eigen::VectorXd &final_state, int n_images, const GPNEBConfig &neb_config, const OCINEBConfig &oci_config_in, ActiveLearningSession &session)
bool ciIndexCertificateRefuted(const OCINEBResult &result)
bool ocinebReportsConverged(const OCINEBResult &result)
@ RecoveryPortfolioExhausted
IndexEscapeResult runIndexEscapeGpDimer(const OCINEBConfig &oci_config, const GPNEBConfig &neb_config, ActiveLearningSession &session, NEBOracle &oracle, const Eigen::VectorXd &x_seed, double e_seed, const Eigen::VectorXd &g_seed, const Eigen::VectorXd &mode_seed, double energy_ceiling)
OCINEBResult runOCINEBRefined(NEBOracle oracle, const Eigen::VectorXd &initial, const Eigen::VectorXd &final_state, int n_images, GPNEBConfig neb_config, const OCINEBConfig &oci_config, ActiveLearningSession &session)
MMFStatus
Outcome of one MMF burst, mirroring eOn's enum class.
@ Helped
Mode converged, alignment in tol.
@ MaxIterations
Hit dimer iter cap; usable but no signal.
@ Skipped
Invalid input or mode drifted outside tol.
@ PositiveCurvature
CI was a minimum; restore position.
NEBMode
NEB evaluation mode.
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Eigen::Matrix< double, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixd
Stores configurations of all atoms in the system.
Observation data: energy, gradient and positions.
Configuration for GP-NEB.
bool index_refused
A force-quiet point failed the index-1 gate and no budget remains.
Eigen::VectorXd positions
final midpoint
int oracle_calls
oracle rows the search paid
bool converged
true-force convergence at the midpoint
int phases
measured dimer phases
Eigen::VectorXd gradient
true gradient at the final midpoint
bool wall_clock_limit
shared search deadline expired
Result of one ~OCINEBControllerrun~ invocation.
MMFRejectKind reject_kind
Reason for rejected_helped_handback, used by recovery-gate policy.
bool shouldResetOptimizer
Whether the caller should reset its outer optimiser state.
bool certified_lower_saddle_advanced
bool rejected_helped_handback
double alignment
Alignment of final mode to current path tangent.
bool convergedAfterMMF
True iff newForce < force_tolerance.
double final_mode_curvature
bool min_mode_angle_certified
bool trusted_recovery_advanced
A non-Helped recovery phase was accepted and written to the chain.
bool recovery_saddle_certified
bool force_improving_recovery_advanced
MMFStatus status
Final dimer-status for reporting / accounting.
double final_rotation_omega
double previousForce
Oracle force at CI image before this MMF burst.
bool recovery_selection_exhausted
The recovery selector found no acceptable phase to hand back.
bool requires_outer_path_refresh
MmfHandoffPolicy handoff_policy
double perturb_along_tangent
double max_burst_displacement
bool use_mmf
Master switch. False -> ~runOCINEB~ degenerates to bare NEB.
bool keep_force_improving_burst
double dimer_variance_tau_rel
double dimer_imspe_soft_threshold
int dimer_imspe_history_size
EMD-filtered ring-buffer size for the dimer IMSPE soft-skip.
std::function< double()> effective_force_tolerance
double dimer_variance_tau_abs
Eigen::VectorXd initial_orient
double dimer_kappa_beta
Xiao contour curvature restraint; zero disables, paper uses 5 Angstrom.
detail::MmfInformationGate info_gate
bool uncertified_hook_reject_active
double trusted_retry_reject_force
bool soft_quiet_blocked_after_reject
bool force_improving_recovery_active
long mmf_reject_climbing_image
bool trap_surface_updated
detail::MmfSurrogateFingerprint mmf_surrogate_at_last_reject
bool trusted_recovery_active
bool exhausted_recovery_reject_active
bool oie_quiet_handoff_stalled
int fixed_theta_refreshes
int hyperparameter_refits
bool band_certificate_evaluated
double band_certificate_residual
bool band_certificate_holds
int refinements
Number of band refinements (image doublings) folded into this result.
int ci_index_oracle_calls
double ci_index_residual1
double ci_index_residual2
bool ci_index_evaluated
Climbing-image index certificate (see certifyClimbingImageIndex).
double band_midpoint_excess
double ci_index_curvature2
bool band_midpoint_evaluated
Surrogate midpoint check of the returned band (certifyBandMidpoints).
Eigen::VectorXd ci_final_position
int band_midpoint_segment
double ci_index_curvature1
double band_certificate_leak
Eigen::VectorXd positions