Loading...
Searching...
No Matches
gpr::neb::ActiveLearningSession Struct Reference

#include <gpr/neb/Session.h>

Classes

struct  IndexedObservation
struct  SurrogateFingerprint
struct  ImageModel
struct  LocalKernelSeed
class  ModelLease
class  PolicyScope

Public Types

using AfterInitialise

Public Member Functions

void setSecantHessianConfig (const optim::SecantHessianConfig &config)
template<class Measure>
bool purchaseSecantConsistencyProbe (Measure &&measure)
const optim::SecantHessian & globalSecantHessian () const noexcept
const optim::SecantHessian * imageSecantHessian (int image_idx) const noexcept
void noteTrueForceSecant (int image_idx, const Eigen::VectorXd &positions, double energy, const Eigen::VectorXd &gradient)
 True-force secant only. Training retention is unchanged.
std::size_t secantReplaySize () const noexcept
 Samples kept so reconfigure can rebuild per-image secant seeds.
std::size_t secantReplayTrainingRows () const noexcept
 Replay samples that record an admitted training row.
bool secantReplayHoldsTrainingRow (const Eigen::VectorXd &position) const
 True when an admitted-row sample still holds ~position~.
optim::SecantCurvatureCounts secantCounts () const
void addSecantCounts (const optim::SecantCurvatureCounts &extra)
SharedParameterState sharedParameterState () const
bool sharesGlobalHyperparameters (const gpr::GaussianProcessRegression &model) const
std::uint64_t imageModelSurrogateRevision (int image_idx) const
std::uint64_t trainingRevision () const noexcept
std::uint64_t globalModelSurrogateRevision () const
SurrogateFingerprint surrogateFingerprint (int owner) const
int mmfModelOwner (int image_idx, bool dimer_use_global_gp) const
SurrogateFingerprint mmfSurrogateFingerprint (int image_idx, bool dimer_use_global_gp) const
void setLikelihoodNoiseFloorRms (const double *noise_rms) noexcept
void setRefitTrainingRevisions (std::uint64_t revisions) noexcept
std::uint64_t refitTrainingRevisions () const noexcept
std::uint64_t surfaceEpoch () const noexcept
void refreshLikelihoodNoiseFloor ()
void initialise ()
bool applySeededModel ()
void setAfterInitialise (AfterInitialise hook)
int priorObservations () const noexcept
 Rows loaded from a seed file. Not an oracle-call count.
void notePriorObservations (int count) noexcept
void noteLocalKernelSeed (double signal_variance, double length_scale) noexcept
const LocalKernelSeed & localKernelSeed () const noexcept
void noteExternalHyperparameterFit () noexcept
bool updateFrozenEnvironment (const gpr::Coord &band)
void initializePerImage (int n_images)
int boundActiveSetToBand (const gpr::Coord &band_positions, Eigen::Index max_rows)
double observationResolutionFloor () const
double nearestTrainingDistance (const Eigen::VectorXd &positions) const
void appendObservation (const Eigen::VectorXd &positions, double energy, const Eigen::VectorXd &gradient, ObservationRetention retention=ObservationRetention::RecordAcquisition, optim::SecantAccounting secant_accounting=optim::SecantAccounting::Count)
void setEndpointSymmetry (EndpointSymmetry symmetry)
const EndpointSymmetry & endpointSymmetry () const noexcept
long symmetryRowsAdmitted () const noexcept
long symmetryRowsRejected () const noexcept
void setResolutionDedup (bool on) noexcept
bool withinTrainingResolution (const Eigen::VectorXd &positions) const
long resolutionDedupRejected () const noexcept
int admitObservation (const Eigen::VectorXd &positions, double energy, const Eigen::VectorXd &gradient, optim::SecantAccounting secant_accounting=optim::SecantAccounting::Count)
void appendSymmetryImage (int source_row, const Eigen::VectorXd &positions, double energy, const Eigen::VectorXd &gradient)
void syncTrainingMultiplicity ()
void noteExternalTrainingEdit () noexcept
void markCurrentTrainingRevisionRetainedByPolicy (const policy::TrainingPolicy *policy) noexcept
bool retainTrainingRowsForPolicy (const policy::TrainingPolicy &policy)
bool addVirtualObservation (const Eigen::VectorXd &positions, double retire_radius)
void retireVirtualObservationsNear (const Eigen::VectorXd &positions)
void syncVirtualNoiseTag ()
gpr::Observation composedTrainingObs () const
void appendObservation (int image_idx, const Eigen::VectorXd &positions, double energy, const Eigen::VectorXd &gradient, ObservationRetention retention=ObservationRetention::RecordAcquisition, optim::SecantAccounting secant_accounting=optim::SecantAccounting::Count)
bool attachImageObservation (int image_idx, int global_row_index)
void appendCurrentChainObservation (int image_idx, const Eigen::VectorXd &positions, double energy, const Eigen::VectorXd &gradient, ObservationRetention retention=ObservationRetention::RecordAcquisition, optim::SecantAccounting secant_accounting=optim::SecantAccounting::Count)
void recordCurrentChainCertificate (int image_idx, const Eigen::VectorXd &positions)
void recordCurrentChainCertificate (int image_idx, const Eigen::VectorXd &positions, double energy, const Eigen::VectorXd &gradient)
bool currentChainCertificateMatchesGeometry (int image_idx, const Eigen::VectorXd &positions) const
std::optional< IndexedObservation > currentChainObservation (int image_idx, const Eigen::VectorXd &positions) const
bool hasCurrentChainCertificate (int image_idx, const Eigen::VectorXd &positions) const
void setImageNeighborhood (int i, const std::vector< int > &emd_indices, const Eigen::VectorXd *image_position=nullptr)
std::vector< uint64_t > selectArchivedNeighbors (const std::vector< int > &kept, const Eigen::VectorXd *image_position, Eigen::Index D)
bool setImageInternalCoordinateChart (int i, std::shared_ptr< const gpr::geometry::InternalCoordinateChart > chart)
bool setGlobalInternalCoordinateChart (std::shared_ptr< const gpr::geometry::InternalCoordinateChart > chart)
void clearGlobalInternalCoordinateChart ()
const std::shared_ptr< const gpr::geometry::InternalCoordinateChart > & globalInternalCoordinateChart () const noexcept
double globalInternalCoordinateLengthScale () const noexcept
bool setBandGeodesicReferencePath (const gpr::Coord &reference_path)
bool setImageGeodesicReferencePath (int i, const gpr::Coord &reference_path)
bool refitImageGP (int i)
void ensureSingletonForGlobal ()
bool ensureSingletonForImage (int i)
void markModelMaterialized (int owner, const Eigen::VectorXd &theta, const SharedParameterState &shared_state)
ModelLease acquireGlobalModel ()
ModelLease acquireImageModel (int i)
bool imageModelEligibleForPrediction (int i) const
void predictAtImage (int i, gpr::Observation &probe)
void observationVarianceAtImage (int i, gpr::Observation &probe)
template<typename Use>
void withImageChartFallback (int i, Use &&use)
template<typename Use>
void withImageModel (int i, Use &&use)
void compactAfterRowRemoval (int removed_row)
bool rollbackTrainingObservations (Eigen::Index row_count)
void appendIndexedObservations (const std::vector< IndexedObservation > &observations)
bool rollbackTrainingObservationsRetaining (Eigen::Index row_count, const std::vector< IndexedObservation > &retained_observations)
int pruneTrainingObservationsAdaptive (const gpr::Coord &band_positions)
int pruneTrainingObservationsToBudget (const gpr::Coord &band_positions, Eigen::Index max_rows)
int pruneLeastInfluentialRow (const gpr::Coord &band_positions, bool ignore_noise)
int pruneImageModelsAdaptive (const gpr::Coord &band_positions)
bool refitGP (bool reinit_seeds)
const policy::PolicyContext * activePolicyContext () const noexcept
void publishPolicyProgress (int iteration, int oracle_calls, int refits, int training_size) noexcept
bool hyperparametersNeedRefit () const noexcept
bool refitGPIfTrainingChanged (bool reinit_seeds)
bool wouldRefitAtNextRefresh () const noexcept
void refreshCovarianceCache ()
bool conditionGPOnConsistentRows (const gpr::Observation &acquired, ConvergenceNormType force_norm, Eigen::Index max_rows=0, double force_tolerance=std::numeric_limits< double >::infinity(), gpr::GaussianProcessRegression::RefitTrustReport *trust_report=nullptr)
void setEvidenceRefitTrigger (bool enabled) noexcept
bool evidenceRefitTrigger () const noexcept
double acquiredEvidenceNats () const noexcept
bool acquiredEvidenceRequestsRefit (double batch_nats) noexcept
bool conditionGPOnResolvedRows (const gpr::Observation &acquired, ConvergenceNormType force_norm, Eigen::Index max_rows, double force_tolerance)
void conditionGPOnTrainingData ()

Static Public Member Functions

static int selectMmfModelOwner (bool dimer_use_global_gp, bool image_model_eligible, int image_idx)
static bool integratesHyperparameters (const gpr::GaussianProcessRegression &model)

Public Attributes

gpr::Observation training_obs
gpr::Observation virtual_obs
std::vector< double > virtual_retire_radii
 Per-row coordinate-norm retire radii, aligned with ~virtual_obs~.
double virtual_obs_noise_sigma2 = 0.04
bool ci_active_at_outer_start = false
int ci_stable_outer_count = 0
bool stagnation_handoff = false
double last_max_chain_energy_variance
std::vector< IndexedObservation > current_chain_certificates
gpr::GaussianProcessRegression gp
std::vector< ImageModel > image_models
int min_per_image_n_train = 3
int per_image_knn = 10
double per_image_prior_s2_log = 0.1
gpr::AtomsConfiguration atoms_config
gpr::InputParameters input_parameters
std::function< void(gpr::InputParameters &, gpr::AtomsConfiguration &)> gp_setup
double path_energy_ceiling = std::numeric_limits<double>::infinity()
bool initialised = false
bool resolution_dedup_enabled_ = false
long resolution_dedup_rejected_ = 0
EndpointSymmetry endpoint_symmetry_
long symmetry_rows_admitted_ = 0
long symmetry_rows_rejected_ = 0
std::vector< int > training_multiplicity

Detailed Description

Shared GP + training data state for an active-learning saddle search session. Caller-owned, passed by pointer to ~gpNEB~ and ~AtomicDimer~ entry points.

Two GP tiers live here:

  • ~gp~ + ~training_obs~ :: the global GP, owning every oracle call from every phase (NEB explore, NEB CI, Dimer MMF). Used for hyperparameter optimisation and for prediction when the local GP at a given image lacks data.
  • ~image_models[i]~ :: per-image local GP slot. Each image i owns the subset of oracle calls evaluated while it was the worst image (NEB picker) or while it was the CI image (OCINEB burst). Local GPs inherit global theta; compatible EB and Laplace models also share its hyperparameter distribution. The image GP answers ~predictAtImage~ when the slot has at least ~min_per_image_n_train~ direct oracle rows; otherwise the call falls back to the global GP.

Definition at line 198 of file Session.h.

Member Typedef Documentation

◆ AfterInitialise

Initial value:
std::function<bool(GaussianProcessRegression&,
Stores configurations of all atoms in the system.
Definition Structures.h:832
Observation data: energy, gradient and positions.

Definition at line 1276 of file Session.h.

Member Function Documentation

◆ acquiredEvidenceNats()

double gpr::neb::ActiveLearningSession::acquiredEvidenceNats ( ) const
inlinenodiscardnoexcept

Contradiction evidence (nats) of the rows conditioned since the last hyperparameter fit.

Definition at line 3463 of file Session.h.

3464 {
3465 return acquired_evidence_nats_;
3466 }

◆ acquiredEvidenceRequestsRefit()

bool gpr::neb::ActiveLearningSession::acquiredEvidenceRequestsRefit ( double batch_nats)
inlinenoexcept

Add a batch's evidence to the running sum. True when the sum reaches one nat, the amount a refit can learn about theta; the sum then restarts at the next fit and is left unchanged here.

Definition at line 3470 of file Session.h.

3471 {
3472 const double total = acquired_evidence_nats_ + batch_nats;
3473 if (total >= 1.0) return true;
3474 acquired_evidence_nats_ = total;
3475 return false;
3476 }

◆ acquireGlobalModel()

ModelLease gpr::neb::ActiveLearningSession::acquireGlobalModel ( )
inlinenodiscard

Definition at line 2787 of file Session.h.

2788 {
2789 return ModelLease(*this, -1);
2790 }

◆ acquireImageModel()

ModelLease gpr::neb::ActiveLearningSession::acquireImageModel ( int i)
inlinenodiscard

Definition at line 2792 of file Session.h.

2793 {
2794 return ModelLease(*this, i);
2795 }

◆ activePolicyContext()

const policy::PolicyContext * gpr::neb::ActiveLearningSession::activePolicyContext ( ) const
inlinenodiscardnoexcept

Definition at line 3275 of file Session.h.

3277 {
3278 return policy_context_.get();
3279 }

◆ addSecantCounts()

void gpr::neb::ActiveLearningSession::addSecantCounts ( const optim::SecantCurvatureCounts & extra)
inline

A dimer that owns its surrogate passes its full counts. A dimer leasing this session's GP passes the ledger only; the shared GP's quadratic-mean uses are already on gp.

Definition at line 406 of file Session.h.

407 {
408 secant_counts_.pairs_accepted += extra.pairs_accepted;
409 secant_counts_.pairs_rejected += extra.pairs_rejected;
410 secant_counts_.hvp_calls += extra.hvp_calls;
411 secant_counts_.consistency_rejections += extra.consistency_rejections;
412 secant_counts_.quadratic_mean_uses += extra.quadratic_mean_uses;
413 }

◆ addVirtualObservation()

bool gpr::neb::ActiveLearningSession::addVirtualObservation ( const Eigen::VectorXd & positions,
double retire_radius )
inline

Pin the posterior toward the prior at ~positions~ with a conditioning-only virtual observation (targets = prior mean and prior gradient there, residual zero under the model's own prior-mean subtraction). Skipped when a real or virtual row already sits within ~retire_radius~ (coordinate norm): a real row means the model has genuine information there; a virtual one means the pin already exists. Bounded at ~kMaxVirtualObservations~ rows, oldest replaced first. Returns true when a row was inserted; the caller re-conditions via ~refreshCovarianceCache~.

Definition at line 1860 of file Session.h.

1862 {
1863 if (!(retire_radius > 0.0) || !std::isfinite(retire_radius))
1864 return false;
1865 for (Eigen::Index r = 0; r < training_obs.R.rows(); ++r) {
1866 if ((training_obs.R.row(r).transpose() - positions).norm() <
1867 retire_radius)
1868 return false;
1869 }
1870 for (Eigen::Index r = 0; r < virtual_obs.R.rows(); ++r) {
1871 if ((virtual_obs.R.row(r).transpose() - positions).norm() <
1872 retire_radius)
1873 return false;
1874 }
1875 if (virtual_obs.R.rows() >=
1876 static_cast<Eigen::Index>(kMaxVirtualObservations)) {
1877 detail::eraseObservationRow(virtual_obs, 0);
1879 }
1880 double prior_energy = 0.0;
1881 Eigen::VectorXd prior_gradient;
1882 gp.evaluatePriorMeanTargets(positions, prior_energy, prior_gradient);
1883 detail::appendObservationRow(virtual_obs, positions, prior_energy,
1884 prior_gradient);
1885 virtual_retire_radii.push_back(retire_radius);
1887 return true;
1888 }
std::vector< double > virtual_retire_radii
Per-row coordinate-norm retire radii, aligned with ~virtual_obs~.
Definition Session.h:427
gpr::Observation training_obs
Definition Session.h:246
gpr::GaussianProcessRegression gp
Definition Session.h:471
gpr::Observation virtual_obs
Definition Session.h:425

◆ admitObservation()

int gpr::neb::ActiveLearningSession::admitObservation ( const Eigen::VectorXd & positions,
double energy,
const Eigen::VectorXd & gradient,
optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count )
inline

The row holding positions after a merge or an append, or -1 when the resolution gate refused it.

Definition at line 1671 of file Session.h.

1674 {
1675 const int existing = detail::findPositionRow(training_obs, positions);
1676 if (existing >= 0) {
1677 // The geometry is already a training row. This draw updates
1678 // that row; it is another true-force note, not a second seed.
1679 observeSecant(-1, positions, gradient, energy, secant_accounting,
1680 /*training_row=*/false);
1681 mergeRepeatedObservation(existing, energy, gradient);
1682 return existing;
1683 }
1684 // Admission at the model's own resolution. Without this the only
1685 // test is an exact position match, so a band that shifts by a
1686 // hair between outer iterations contributes a full new row every
1687 // time and the training set grows without bound -- which is what
1688 // makes the run cost grow, the kernel order being the row count
1689 // times (1 + 3 natoms).
1691 const double floor_d = observationResolutionFloor();
1692 if (floor_d > 0.0 && training_obs.R.rows() > 0 &&
1693 nearestTrainingDistance(positions) < floor_d) {
1694 // Declined rows never enter ~training_obs~, so they must
1695 // not be exempt from the replay cap.
1696 observeSecant(-1, positions, gradient, energy,
1697 secant_accounting, /*training_row=*/false);
1699 return -1;
1700 }
1701 }
1702 observeSecant(-1, positions, gradient, energy, secant_accounting,
1703 /*training_row=*/true);
1704 detail::appendObservationRow(training_obs, positions, energy, gradient);
1707 recordTrainingMutation();
1708 return static_cast<int>(training_obs.R.rows()) - 1;
1709 }
double nearestTrainingDistance(const Eigen::VectorXd &positions) const
Definition Session.h:1555
double observationResolutionFloor() const
Definition Session.h:1530
void retireVirtualObservationsNear(const Eigen::VectorXd &positions)
Definition Session.h:1893

◆ appendCurrentChainObservation()

void gpr::neb::ActiveLearningSession::appendCurrentChainObservation ( int image_idx,
const Eigen::VectorXd & positions,
double energy,
const Eigen::VectorXd & gradient,
ObservationRetention retention = ObservationRetention::RecordAcquisition,
optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count )
inline

Append a force-quality observation at the live chain geometry and bind its certificate to that image and position. The row is durable because path certificates must survive restart and covariance refresh.

Definition at line 1994 of file Session.h.

1999 {
2000 appendObservation(image_idx, positions, energy, gradient, retention,
2001 secant_accounting);
2002 if (detail::hasPosition(training_obs, positions)) {
2003 recordCurrentChainCertificate(image_idx, positions, energy,
2004 gradient);
2005 }
2006 }
void recordCurrentChainCertificate(int image_idx, const Eigen::VectorXd &positions)
Definition Session.h:2010
void appendObservation(const Eigen::VectorXd &positions, double energy, const Eigen::VectorXd &gradient, ObservationRetention retention=ObservationRetention::RecordAcquisition, optim::SecantAccounting secant_accounting=optim::SecantAccounting::Count)
Definition Session.h:1574

◆ appendIndexedObservations()

void gpr::neb::ActiveLearningSession::appendIndexedObservations ( const std::vector< IndexedObservation > & observations)
inline

Definition at line 2895 of file Session.h.

2897 {
2898 for (const auto& observation: observations) {
2899 appendObservation(observation.image_index, observation.positions,
2900 observation.energy, observation.gradient);
2901 }
2902 if (!observations.empty()) refreshCovarianceCache();
2903 }

◆ appendObservation() [1/2]

void gpr::neb::ActiveLearningSession::appendObservation ( const Eigen::VectorXd & positions,
double energy,
const Eigen::VectorXd & gradient,
ObservationRetention retention = ObservationRetention::RecordAcquisition,
optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count )
inline

Append one observation row to ~training_obs~. Mirrors the internal ~appendObservation~ helper in ~GPNEB.cpp~; lives here so the controller can use it directly without leaking that helper. Every distinct oracle acquisition is a joint energy-and-force observation and is retained in full.

Definition at line 1574 of file Session.h.

1578 {
1579#ifdef USE_READCON_DB
1580 // Every acquisition reaches the ledger, merged draws included.
1581 if (observation_archive_ &&
1583 (void)observation_archive_->append(positions, energy, gradient);
1584#else
1585 (void)retention;
1586#endif
1587 const int row =
1588 admitObservation(positions, energy, gradient, secant_accounting);
1589 if (row >= 0) appendSymmetryImage(row, positions, energy, gradient);
1590 }
void appendSymmetryImage(int source_row, const Eigen::VectorXd &positions, double energy, const Eigen::VectorXd &gradient)
Definition Session.h:1718
int admitObservation(const Eigen::VectorXd &positions, double energy, const Eigen::VectorXd &gradient, optim::SecantAccounting secant_accounting=optim::SecantAccounting::Count)
Definition Session.h:1671

◆ appendObservation() [2/2]

void gpr::neb::ActiveLearningSession::appendObservation ( int image_idx,
const Eigen::VectorXd & positions,
double energy,
const Eigen::VectorXd & gradient,
ObservationRetention retention = ObservationRetention::RecordAcquisition,
optim::SecantAccounting secant_accounting = optim::SecantAccounting::Count )
inline

Dual-update overload: append to the global ~training_obs~ AND to image ~image_idx~'s local training set. The per-image set drives ~predictAtImage(image_idx, ...)~ once its direct row count crosses the ~min_per_image_n_train~ threshold; below threshold those calls fall through to the global ~gp~. Out-of-range ~image_idx~ (or per-image storage uninitialised) just degenerates to a global-only append, matching the single-argument overload.

Definition at line 1941 of file Session.h.

1945 {
1946#ifdef USE_READCON_DB
1947 if (observation_archive_ &&
1949 (void)observation_archive_->append(positions, energy, gradient);
1950#else
1951 (void)retention;
1952#endif
1953 int global_row_index =
1954 detail::findPositionIndex(training_obs, positions);
1955 const bool appended = global_row_index < 0;
1956 // A merged draw keeps the admitting sample's image index. The new
1957 // image is a true-force note and stays under the non-training cap.
1958 observeSecant(image_idx, positions, gradient, energy, secant_accounting,
1959 /*training_row=*/appended);
1960 if (appended) {
1961 global_row_index = static_cast<int>(training_obs.R.rows());
1962 detail::appendObservationRow(training_obs, positions, energy,
1963 gradient);
1965 recordTrainingMutation();
1966 } else {
1967 mergeRepeatedObservation(global_row_index, energy, gradient);
1968 }
1969 appendSymmetryImage(global_row_index, positions, energy, gradient);
1970 (void)attachImageObservation(image_idx, global_row_index);
1971 }
bool attachImageObservation(int image_idx, int global_row_index)
Definition Session.h:1977

◆ appendSymmetryImage()

void gpr::neb::ActiveLearningSession::appendSymmetryImage ( int source_row,
const Eigen::VectorXd & positions,
double energy,
const Eigen::VectorXd & gradient )
inline

Enter the symmetry image of the row at source_row. A repeated image merges like a repeated draw, which keeps it the image of the source row's count-weighted target. The resolution gate applies whatever –gp-resolution-dedup says: the image of a geometry the symmetry fixes, the saddle among them, lands on its source to rounding, and a derived row inside the model's resolution of a training row adds nothing.

Definition at line 1718 of file Session.h.

1720 {
1721 if (endpoint_symmetry_.empty()) return;
1722 const Eigen::VectorXd image =
1723 endpoint_symmetry_.mapPositions(positions);
1724 const Eigen::VectorXd image_gradient =
1725 endpoint_symmetry_.mapGradient(gradient);
1726 const int existing = detail::findPositionRow(training_obs, image);
1727 if (existing == source_row) {
1729 return;
1730 }
1731 if (existing >= 0) {
1732 mergeRepeatedObservation(existing, energy, image_gradient);
1733 return;
1734 }
1735 const double floor_d = observationResolutionFloor();
1736 const double nearest = nearestTrainingDistance(image);
1737 if ((floor_d > 0.0 && nearest < floor_d) ||
1738 nearest <= endpoint_symmetry_.resolution()) {
1740 return;
1741 }
1742 detail::appendObservationRow(training_obs, image, energy,
1743 image_gradient);
1746 recordTrainingMutation();
1748 }
EndpointSymmetry endpoint_symmetry_
Definition Session.h:1665

◆ applySeededModel()

bool gpr::neb::ActiveLearningSession::applySeededModel ( )
inline

Install a warm-start kernel after the search has applied its model profile and pair cutoff. initialise() leaves the GP on the profile default, so the saved kernel would not match yet. False when this search had no seed or the seed hook refused to install the kernel.

Definition at line 1267 of file Session.h.

1268 {
1269 if (!after_initialise_) return false;
1270 const bool installed =
1271 after_initialise_(gp, atoms_config, training_obs);
1272 after_initialise_ = nullptr;
1273 return installed;
1274 }
gpr::AtomsConfiguration atoms_config
Definition Session.h:1129

◆ attachImageObservation()

bool gpr::neb::ActiveLearningSession::attachImageObservation ( int image_idx,
int global_row_index )
inlinenodiscard

Bind an acquired canonical row to an image without treating its reuse as another draw from the oracle. Image targets use the canonical mean.

Definition at line 1977 of file Session.h.

1979 {
1980 if (image_idx < 0 ||
1981 image_idx >= static_cast<int>(image_models.size()) ||
1982 global_row_index < 0 || global_row_index >= training_obs.R.rows())
1983 return false;
1984 image_models[image_idx].appendObservation(
1985 training_obs.R.row(global_row_index).transpose(),
1986 training_obs.E(global_row_index, 0),
1987 training_obs.G.row(global_row_index).transpose(), global_row_index);
1988 return true;
1989 }
std::vector< ImageModel > image_models
Definition Session.h:997

◆ boundActiveSetToBand()

int gpr::neb::ActiveLearningSession::boundActiveSetToBand ( const gpr::Coord & band_positions,
Eigen::Index max_rows )
inline

Retain band support and acquired corrections within a row budget. A sweep of recent acquisitions protects rejected trial and dimer observations outside the retained band. Each band image then reserves its nearest row in the prediction kernel's metric. Among the other rows the one whose removal changes the posterior mean least in the kernel norm is dropped first; the observation archive is intact.

Definition at line 1406 of file Session.h.

1408 {
1409 const Eigen::Index rows = training_obs.R.rows();
1410 if (!initialised || max_rows <= 0 || rows <= max_rows) return 0;
1411 const Eigen::Index dimensions = training_obs.R.cols();
1412 if (dimensions <= 0 || band_positions.cols() != dimensions ||
1413 band_positions.rows() == 0)
1414 return 0;
1415
1416 gpr::FieldMatrixd distances;
1417 const auto& covariance = gp.getSexpAtCovarianceFunction();
1418 const auto& scales = covariance.getLengthScaleRef();
1419 if (scales.size() > 0 && scales.allFinite() &&
1420 scales.minCoeff() > 0.0) {
1421 covariance.correlationDistances(band_positions, training_obs.R,
1422 atoms_config, distances);
1423 } else {
1424 aux::Distance metric;
1425 metric.dist_emd(band_positions, training_obs.R, atoms_config,
1426 distances);
1427 }
1428 if (distances.rows() != band_positions.rows() ||
1429 distances.cols() != rows)
1430 return 0;
1431
1432 std::vector<char> protected_row(static_cast<std::size_t>(rows), 0);
1433 const Eigen::Index recent = std::min(
1434 band_positions.rows(), std::max<Eigen::Index>(1, max_rows / 2));
1435 for (Eigen::Index row = rows - recent; row < rows; ++row)
1436 protected_row[static_cast<std::size_t>(row)] = 1;
1437 Eigen::Index protected_count = recent;
1438 for (Eigen::Index image = 0;
1439 image < distances.rows() && protected_count < max_rows; ++image) {
1440 Eigen::Index nearest;
1441 const double distance = distances.row(image).minCoeff(&nearest);
1442 if (std::isfinite(distance) &&
1443 !protected_row[static_cast<std::size_t>(nearest)]) {
1444 protected_row[static_cast<std::size_t>(nearest)] = 1;
1445 ++protected_count;
1446 }
1447 }
1448
1449 const Eigen::Index removed = rows - max_rows;
1450 const auto erase_row = [&](Eigen::Index row) {
1451 detail::eraseObservationRow(training_obs, row);
1452 if (static_cast<std::size_t>(row) < training_multiplicity.size())
1454 row);
1455 for (auto& model: image_models)
1456 model.compactAfterRowRemoval(static_cast<int>(row));
1457 protected_row.erase(protected_row.begin() + row);
1458 };
1459 // The row whose removal changes the posterior mean least in the
1460 // kernel norm goes first. That norm bounds the change at every
1461 // geometry, so a measured row far from the band that still holds
1462 // the band out of the region it left is kept, and a row its
1463 // neighbours reproduce is dropped. One removal changes what every
1464 // remaining row is worth, so the norms are evaluated again before
1465 // the next one.
1466 Eigen::Index pending = removed;
1467 while (pending > 0 && gp_model_ready_ && gp.hasBeenOptimized()) {
1468 Eigen::VectorXd influence, removal_norm;
1469 if (!gp.observationBandInfluence(training_obs, band_positions,
1470 influence, /*collective=*/true,
1471 protected_row, &removal_norm) ||
1472 removal_norm.size() != training_obs.R.rows())
1473 break;
1474 Eigen::Index least = -1;
1475 for (Eigen::Index row = 0; row < removal_norm.size(); ++row) {
1476 if (protected_row[static_cast<std::size_t>(row)] ||
1477 !std::isfinite(removal_norm(row)))
1478 continue;
1479 if (least < 0 || removal_norm(row) < removal_norm(least))
1480 least = row;
1481 }
1482 if (least < 0) break;
1483 erase_row(least);
1484 --pending;
1485 }
1486 if (pending > 0 && training_obs.R.rows() == rows) {
1487 // Without a fitted model the kernel norm is undefined: the rows
1488 // farthest from the band in the prediction metric are dropped.
1489 std::vector<std::pair<double, Eigen::Index>> candidates;
1490 for (Eigen::Index row = 0; row < rows; ++row) {
1491 if (protected_row[static_cast<std::size_t>(row)]) continue;
1492 double distance = distances.col(row).minCoeff();
1493 if (!std::isfinite(distance))
1494 distance = std::numeric_limits<double>::infinity();
1495 candidates.emplace_back(distance, row);
1496 }
1497 std::stable_sort(candidates.begin(), candidates.end(),
1498 [](const auto& left, const auto& right) {
1499 return left.first > right.first;
1500 });
1501 std::vector<Eigen::Index> removed_rows;
1502 for (std::size_t i = 0; i < candidates.size() &&
1503 static_cast<Eigen::Index>(i) < pending;
1504 ++i)
1505 removed_rows.push_back(candidates[i].second);
1506 std::sort(removed_rows.begin(), removed_rows.end(),
1507 std::greater<>());
1508 for (const Eigen::Index row: removed_rows)
1509 erase_row(row);
1510 pending -= static_cast<Eigen::Index>(removed_rows.size());
1511 }
1512 if (pending == removed) return 0;
1513 discardPrunedSecantReplay();
1514 recordTrainingMutation();
1515 return static_cast<int>(removed - pending);
1516 }
void dist_emd(const gpr::Coord &x1, const gpr::Coord &x2, const gpr::AtomsConfiguration &conf_info, gpr::FieldMatrixd &dist)
Calculates the Earth Mover's Distance between sets of configurations.
Eigen::Matrix< double, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixd
Definition Macros.h:25
std::vector< int > training_multiplicity
Definition Session.h:1848

◆ clearGlobalInternalCoordinateChart()

void gpr::neb::ActiveLearningSession::clearGlobalInternalCoordinateChart ( )
inline

Definition at line 2349 of file Session.h.

2350 {
2351 const bool had_chart =
2352 static_cast<bool>(global_internal_coordinate_chart_);
2353 bool gp_uses_chart = false;
2354 if (initialised) {
2355 gp_uses_chart =
2356 gp.getSexpAtCovarianceFunction().usesManifoldChart();
2357 if (gp_uses_chart) {
2358 gp.getSexpAtCovarianceFunction().clearManifoldChart();
2359 }
2360 }
2361 global_internal_coordinate_chart_.reset();
2362 global_internal_coordinate_length_scale_ =
2363 std::numeric_limits<double>::quiet_NaN();
2364 if (had_chart || gp_uses_chart) {
2365 kernel_requires_refit_ = true;
2366 if (initialised && training_obs.R.rows() > 0) {
2367 materializeWithNoiseFloor(gp, training_obs,
2368 likelihoodNoiseFloorSigma2());
2369 }
2370 ++global_surrogate_revision_;
2371 }
2372 }

◆ compactAfterRowRemoval()

void gpr::neb::ActiveLearningSession::compactAfterRowRemoval ( int removed_row)
inline

A row was removed from ~training_obs~ (rollback of speculative rows): compact every per-image model's index views in step.

Definition at line 2865 of file Session.h.

2866 {
2867 for (auto& model: image_models) {
2868 model.compactAfterRowRemoval(removed_row);
2869 }
2870 }

◆ composedTrainingObs()

gpr::Observation gpr::neb::ActiveLearningSession::composedTrainingObs ( ) const
inlinenodiscard

~training_obs~ with the virtual rows appended, for covariance conditioning and prediction. Hyperparameter fitting keeps using ~training_obs~ directly.

Definition at line 1922 of file Session.h.

1923 {
1924 gpr::Observation composed = training_obs;
1925 for (Eigen::Index r = 0; r < virtual_obs.R.rows(); ++r) {
1926 detail::appendObservationRow(
1927 composed, virtual_obs.R.row(r).transpose(), virtual_obs.E(r, 0),
1928 virtual_obs.G.row(r).transpose());
1929 }
1930 return composed;
1931 }

◆ conditionGPOnConsistentRows()

bool gpr::neb::ActiveLearningSession::conditionGPOnConsistentRows ( const gpr::Observation & acquired,
ConvergenceNormType force_norm,
Eigen::Index max_rows = 0,
double force_tolerance = std::numeric_limits<double>::infinity(),
gpr::GaussianProcessRegression::RefitTrustReport * trust_report = nullptr )
inline

Condition acquired rows when their forces agree with the proposing posterior. The caller appends them to training_obs without conditioning the GP first, so the comparison uses predictions made without the rows. Exceeding the row ceiling requires pruning and a full refit.

Definition at line 3411 of file Session.h.

3416 {
3417 if (trust_report) *trust_report = {};
3418 if (!initialised || !gp_model_ready_ || kernel_requires_refit_ ||
3419 (max_rows > 0 && training_obs.R.rows() > max_rows) ||
3420 !gp.hasBeenOptimized() || !(force_tolerance > 0.0))
3421 return false;
3422 double force_error = 0.0, force_sd = 0.0, evidence = 0.0;
3423 if (gp.measuredRowsAgreeWithPosterior(acquired, force_norm,
3424 &force_error, &force_sd,
3425 &evidence, 1.0, trust_report) !=
3427 return false;
3428 if (evidence_refit_trigger_) {
3429 // The refit decision weighs the rows by what they say about the
3430 // kernel: the contradiction evidence accumulated since the last
3431 // fit. A broad posterior that explains its rows carries no
3432 // evidence against theta, so its spread alone requests no fit.
3433 if (acquired_evidence_nats_ + evidence >= 1.0) return false;
3434 } else if (std::max(force_error, force_sd) >= force_tolerance) {
3435 // Statistical agreement with a broad posterior cannot certify
3436 // the force resolution. Unresolved rows retain the kernel-refit
3437 // policy.
3438 return false;
3439 }
3440 gp.clearModeRefitHint();
3442 if (!gp.isDecomposedSuccessfully()) return false;
3443 // The batch counts against theta only once it is conditioned: a
3444 // failed conditioning requests a refit, and a retried batch must not
3445 // be counted twice.
3446 if (evidence_refit_trigger_) acquired_evidence_nats_ += evidence;
3447 return true;
3448 }

◆ conditionGPOnResolvedRows()

bool gpr::neb::ActiveLearningSession::conditionGPOnResolvedRows ( const gpr::Observation & acquired,
ConvergenceNormType force_norm,
Eigen::Index max_rows,
double force_tolerance )
inline

Assimilate a statistically consistent measurement, then require its conditioned force error and uncertainty to resolve the physical scale. A broad predictive distribution can narrow when the measured row is added; broad uncertainty alone is not evidence against the kernel. False requests a refit and may leave the new rows conditioned.

Definition at line 3483 of file Session.h.

3487 {
3488 if (!(std::isfinite(force_tolerance) && force_tolerance > 0.0) ||
3489 !conditionGPOnConsistentRows(acquired, force_norm, max_rows))
3490 return false;
3491 double force_error = 0.0, force_sd = 0.0;
3492 const auto verdict = gp.measuredRowsAgreeWithPosterior(
3493 acquired, force_norm, &force_error, &force_sd);
3494 return verdict == gpr::GaussianProcessRegression::MeasuredRowVerdict::
3495 Consistent &&
3496 std::max(force_error, force_sd) < force_tolerance;
3497 }
bool conditionGPOnConsistentRows(const gpr::Observation &acquired, ConvergenceNormType force_norm, Eigen::Index max_rows=0, double force_tolerance=std::numeric_limits< double >::infinity(), gpr::GaussianProcessRegression::RefitTrustReport *trust_report=nullptr)
Definition Session.h:3411

◆ conditionGPOnTrainingData()

void gpr::neb::ActiveLearningSession::conditionGPOnTrainingData ( )
inline

Condition every retained observation at the fitted kernel parameters. The fitted training revision remains unchanged so a continued search can distinguish posterior conditioning from hyperparameter fitting.

Definition at line 3502 of file Session.h.

3503 {
3504 syncSecantQuadraticPrior();
3505 if (!initialised || training_obs.R.rows() == 0) return;
3506 // Refactorizing the same measured rows does not change p(theta | D).
3507 // Preserve its existing measure while rebuilding conditional factors;
3508 // changed observations or parameter state require a new measure.
3509 const auto posterior =
3510 conditioned_training_revision_ == training_revision_ &&
3511 virtual_obs.R.rows() == 0
3512 ? gp.currentHyperparameterPosterior()
3513 : gpr::GaussianProcessRegression::HyperparameterPosterior{};
3514 if (!gp_model_ready_) {
3515 gp.setHyperparameters(training_obs, atoms_config, true, true, true);
3516 }
3517 parkActiveModelBeforeSwitch(-1);
3518 if (virtual_obs.R.rows() > 0) {
3519 materializeWithNoiseFloor(gp, composedTrainingObs(),
3520 likelihoodNoiseFloorSigma2());
3521 } else {
3522 materializeWithNoiseFloor(gp, training_obs,
3523 likelihoodNoiseFloorSigma2());
3524 }
3525 gp_model_ready_ = true;
3526 conditioned_training_revision_ = training_revision_;
3527 if (!posterior.empty())
3528 (void)gp.conditionOnHyperparameterPosterior(posterior);
3529 markActiveModel(-1);
3530 }
gpr::Observation composedTrainingObs() const
Definition Session.h:1922

◆ currentChainCertificateMatchesGeometry()

bool gpr::neb::ActiveLearningSession::currentChainCertificateMatchesGeometry ( int image_idx,
const Eigen::VectorXd & positions ) const
inlinenodiscard

Definition at line 2045 of file Session.h.

2047 {
2048 if (image_idx < 0) return false;
2049 const auto slot = static_cast<std::size_t>(image_idx);
2050 if (slot >= current_chain_certificates.size()) return false;
2051 const auto& certificate = current_chain_certificates[slot];
2052 return certificate.image_index == image_idx &&
2053 detail::positionsCoincide(certificate.positions, positions);
2054 }
std::vector< IndexedObservation > current_chain_certificates
Definition Session.h:466

◆ currentChainObservation()

std::optional< IndexedObservation > gpr::neb::ActiveLearningSession::currentChainObservation ( int image_idx,
const Eigen::VectorXd & positions ) const
inlinenodiscard

Definition at line 2056 of file Session.h.

2058 {
2059 if (!currentChainCertificateMatchesGeometry(image_idx, positions)) {
2060 return std::nullopt;
2061 }
2062 const auto& certificate =
2063 current_chain_certificates[static_cast<std::size_t>(image_idx)];
2064 if (std::isfinite(certificate.energy) &&
2065 certificate.gradient.size() == positions.size() &&
2066 certificate.gradient.allFinite()) {
2067 return certificate;
2068 }
2069 const int row = detail::findPositionIndex(training_obs, positions);
2070 if (row < 0 || row >= training_obs.E.rows() ||
2071 row >= training_obs.G.rows() || training_obs.E.cols() <= 0 ||
2072 training_obs.G.cols() != positions.size() ||
2073 !std::isfinite(training_obs.E(row, 0)) ||
2074 !training_obs.G.row(row).allFinite()) {
2075 return std::nullopt;
2076 }
2077 return IndexedObservation{image_idx, positions, training_obs.E(row, 0),
2078 training_obs.G.row(row).transpose(), true};
2079 }
bool currentChainCertificateMatchesGeometry(int image_idx, const Eigen::VectorXd &positions) const
Definition Session.h:2045

◆ endpointSymmetry()

const EndpointSymmetry & gpr::neb::ActiveLearningSession::endpointSymmetry ( ) const
inlinenodiscardnoexcept

Definition at line 1616 of file Session.h.

1617 {
1618 return endpoint_symmetry_;
1619 }

◆ ensureSingletonForGlobal()

void gpr::neb::ActiveLearningSession::ensureSingletonForGlobal ( )
inline

Ensure the global ~gp~ owns the singleton. Cheap when already active with a usable posterior; refactorises the global K when the recorded owner has lost the process-wide factor or when switching from a per-image owner. Call before any ~gp.calculate*~ or any ~gp~ predict that needs the cached factor.

Definition at line 2515 of file Session.h.

2516 {
2517 if (training_obs.R.rows() == 0) return;
2518 // Factor ownership does not identify the observations it conditions.
2519 // Appended or corrected canonical rows change the shared posterior
2520 // even while theta and the process-wide factor owner remain fixed.
2521 if (gp_model_ready_ &&
2522 conditioned_training_revision_ != training_revision_) {
2524 return;
2525 }
2526 const double noise_floor_sigma2 = likelihoodNoiseFloorSigma2();
2527 if (activeModelIs(-1)) {
2528 (void)gp.applyLikelihoodNoiseVarianceFloor(noise_floor_sigma2,
2529 training_obs);
2530 if (!gp.activateMaterializedPosterior()) {
2531 materializeWithNoiseFloor(gp, training_obs, noise_floor_sigma2);
2532 }
2533 markActiveModel(-1);
2534 return;
2535 }
2536 parkActiveModelBeforeSwitch(-1);
2537 if (!gp.applyLikelihoodNoiseVarianceFloor(noise_floor_sigma2,
2538 training_obs) &&
2539 gp.activateMaterializedPosterior()) {
2540 markActiveModel(-1);
2541 return;
2542 }
2543 materializeWithNoiseFloor(gp, training_obs, noise_floor_sigma2);
2544 markActiveModel(-1);
2545 }

◆ ensureSingletonForImage()

bool gpr::neb::ActiveLearningSession::ensureSingletonForImage ( int i)
inlinenodiscard

Ensure image ~i~'s local GP owns the singleton, refitting on demand. Cheap when already active; otherwise re-syncs theta from the global and refactorises the per-image K. Call before any ~image_models[i].gp()->calculate*~ predict.

Definition at line 2551 of file Session.h.

2552 {
2553 if (gp.atomicEnvironmentModelEnabled()) return false;
2554 if (i < 0 || i >= static_cast<int>(image_models.size())) return false;
2555 ImageModel& model = image_models[i];
2556 gpr::GaussianProcessRegression* local_gp = model.gp();
2557 if (!local_gp) return false;
2558 const gpr::Observation& local_obs = model.observations();
2559 if (local_obs.R.rows() == 0) return false;
2560 const Eigen::VectorXd theta_global = gp.packInlaHyperparameters();
2561 const double noise_floor_sigma2 = likelihoodNoiseFloorSigma2();
2562 if (model.materializedFor(theta_global, noise_floor_sigma2,
2564 if (activeModelIs(i)) {
2565 if (!local_gp->activateMaterializedPosterior()) {
2566 if (sharesGlobalHyperparameters(*local_gp))
2567 return refitImageGP(i);
2568 local_gp->updateModelWithFullData(local_obs);
2570 if (!local_gp->activateMaterializedPosterior()) {
2571 return false;
2572 }
2573 markActiveModel(i);
2574 }
2575 return true;
2576 }
2577 parkActiveModelBeforeSwitch(i);
2578 if (local_gp->activateMaterializedPosterior()) {
2579 markActiveModel(i);
2580 return true;
2581 }
2582 if (sharesGlobalHyperparameters(*local_gp)) return refitImageGP(i);
2583 local_gp->updateModelWithFullData(local_obs);
2585 if (!local_gp->activateMaterializedPosterior()) return false;
2586 markActiveModel(i);
2587 return true;
2588 }
2589 return refitImageGP(i);
2590 }
void claimActiveTrainingCholeskyFactor()
Associate the live ScaLAPACK factor with this GP after a materialize.
void updateModelWithFullData(const Observation &full_observation)
SharedParameterState sharedParameterState() const
Definition Session.h:999
bool sharesGlobalHyperparameters(const gpr::GaussianProcessRegression &model) const
Definition Session.h:1021

◆ evidenceRefitTrigger()

bool gpr::neb::ActiveLearningSession::evidenceRefitTrigger ( ) const
inlinenodiscardnoexcept

Definition at line 3457 of file Session.h.

3458 {
3459 return evidence_refit_trigger_;
3460 }

◆ globalInternalCoordinateChart()

const std::shared_ptr< const gpr::geometry::InternalCoordinateChart > & gpr::neb::ActiveLearningSession::globalInternalCoordinateChart ( ) const
inlinenodiscardnoexcept

Definition at line 2376 of file Session.h.

2377 {
2378 return global_internal_coordinate_chart_;
2379 }

◆ globalInternalCoordinateLengthScale()

double gpr::neb::ActiveLearningSession::globalInternalCoordinateLengthScale ( ) const
inlinenodiscardnoexcept

Definition at line 2381 of file Session.h.

2382 {
2383 return global_internal_coordinate_length_scale_;
2384 }

◆ globalModelSurrogateRevision()

std::uint64_t gpr::neb::ActiveLearningSession::globalModelSurrogateRevision ( ) const
inlinenodiscard

Definition at line 1048 of file Session.h.

1049 {
1050 const Eigen::VectorXd theta = gp.packInlaHyperparameters();
1051 const auto shared_state = sharedParameterState();
1052 const double effective_noise_sigma2 =
1053 effectiveModelNoiseVariance(&gp, likelihoodNoiseFloorSigma2());
1054 if (!global_surrogate_inputs_initialized_ ||
1055 global_surrogate_training_revision_ != training_revision_ ||
1056 global_surrogate_shared_state_ != shared_state ||
1057 !surrogateInputsMatch(global_surrogate_theta_,
1058 global_surrogate_noise_sigma2_, theta,
1059 effective_noise_sigma2)) {
1060 ++global_surrogate_revision_;
1061 global_surrogate_training_revision_ = training_revision_;
1062 global_surrogate_theta_ = theta;
1063 global_surrogate_noise_sigma2_ = effective_noise_sigma2;
1064 global_surrogate_shared_state_ = shared_state;
1065 global_surrogate_inputs_initialized_ = true;
1066 }
1067 return global_surrogate_revision_;
1068 }

◆ globalSecantHessian()

const optim::SecantHessian & gpr::neb::ActiveLearningSession::globalSecantHessian ( ) const
inlinenodiscardnoexcept

Definition at line 345 of file Session.h.

347 {
348 return global_secant_;
349 }

◆ hasCurrentChainCertificate()

bool gpr::neb::ActiveLearningSession::hasCurrentChainCertificate ( int image_idx,
const Eigen::VectorXd & positions ) const
inlinenodiscard

Definition at line 2081 of file Session.h.

2083 {
2084 return currentChainObservation(image_idx, positions).has_value();
2085 }
std::optional< IndexedObservation > currentChainObservation(int image_idx, const Eigen::VectorXd &positions) const
Definition Session.h:2056

◆ hyperparametersNeedRefit()

bool gpr::neb::ActiveLearningSession::hyperparametersNeedRefit ( ) const
inlinenodiscardnoexcept

A covariance refresh can condition the current theta on new rows, but only ~refitGP~ calibrates theta against those rows. This predicate keeps the two states distinct for phases that append data between outer-loop refits.

Definition at line 3292 of file Session.h.

3293 {
3294 return training_obs.R.rows() > 0 &&
3295 (!gp_model_ready_ || kernel_requires_refit_ ||
3296 fitted_training_revision_ != training_revision_);
3297 }

◆ imageModelEligibleForPrediction()

bool gpr::neb::ActiveLearningSession::imageModelEligibleForPrediction ( int i) const
inlinenodiscard

Definition at line 2797 of file Session.h.

2798 {
2799 return !gp.atomicEnvironmentModelEnabled() && i >= 0 &&
2800 i < static_cast<int>(image_models.size()) &&
2801 image_models[i].gp() &&
2802 image_models[i].hasEnoughRows(min_per_image_n_train);
2803 }

◆ imageModelSurrogateRevision()

std::uint64_t gpr::neb::ActiveLearningSession::imageModelSurrogateRevision ( int image_idx) const
inlinenodiscard

Definition at line 1030 of file Session.h.

1031 {
1032 if (image_idx < 0 ||
1033 image_idx >= static_cast<int>(image_models.size())) {
1034 return 0;
1035 }
1036 const double effective_noise_sigma2 = effectiveModelNoiseVariance(
1037 image_models[image_idx].gp(), likelihoodNoiseFloorSigma2());
1038 return image_models[image_idx].synchronizeSurrogateRevision(
1039 gp.packInlaHyperparameters(), effective_noise_sigma2,
1041 }

◆ imageSecantHessian()

const optim::SecantHessian * gpr::neb::ActiveLearningSession::imageSecantHessian ( int image_idx) const
inlinenodiscardnoexcept

Definition at line 351 of file Session.h.

353 {
354 if (image_idx < 0 ||
355 image_idx >= static_cast<int>(image_secants_.size()))
356 return nullptr;
357 return &image_secants_[static_cast<std::size_t>(image_idx)];
358 }

◆ initialise()

void gpr::neb::ActiveLearningSession::initialise ( )
inline

Idempotent: build ~gp~ + ~atoms_config~ from ~gp_setup~. After this the GP is ready for ~setHyperparameters~ + ~optimize~ but holds no training data yet.

Definition at line 1254 of file Session.h.

1255 {
1256 if (initialised) return;
1257 if (!gp_setup) return;
1259 gp.initialize(input_parameters, atoms_config);
1260 initialised = true;
1261 }
gpr::InputParameters input_parameters
Definition Session.h:1134
std::function< void(gpr::InputParameters &, gpr::AtomsConfiguration &)> gp_setup
Definition Session.h:1141

◆ initializePerImage()

void gpr::neb::ActiveLearningSession::initializePerImage ( int n_images)
inline

Allocate per-image local GPs sized to the NEB chain. Each local GP gets the same kernel setup as the global ~gp~ (same ~gp_setup~ -> identical kernel functions / atoms config) but starts with an empty training set. Idempotent: redundant calls with the same ~n_images~ are no-ops; resizing to a different chain length blows away the previous per-image state.

Definition at line 1367 of file Session.h.

1368 {
1369 if (!initialised) initialise();
1370 if (!gp_setup) return;
1371 bool changed = false;
1372 if (static_cast<int>(image_models.size()) != n_images) {
1373 image_models.clear();
1374 image_models.resize(n_images);
1375 changed = true;
1376 }
1377 gpr::Observation seed_obs;
1378 for (auto& model: image_models) {
1379 // The compact atomic posterior is shared by every image. Slots
1380 // retain their measured rows without owning duplicate posteriors.
1381 if (gp.atomicEnvironmentModelEnabled()) {
1382 if (model.gp()) {
1383 model.setGP({});
1384 changed = true;
1385 }
1386 model.clearInternalCoordinateChart();
1387 model.clearGeodesicReferencePath();
1388 continue;
1389 }
1390 if (model.gp()) continue;
1391 auto local = std::make_unique<gpr::GaussianProcessRegression>();
1392 local->initialize(input_parameters, atoms_config);
1393 local->setHyperparameters(seed_obs, atoms_config, true, true, true);
1394 model.setGP(std::move(local));
1395 changed = true;
1396 }
1397 if (changed) markActiveModel(-1);
1398 }

◆ integratesHyperparameters()

bool gpr::neb::ActiveLearningSession::integratesHyperparameters ( const gpr::GaussianProcessRegression & model)
inlinestaticnodiscard

Definition at line 1013 of file Session.h.

1015 {
1016 const auto mode = model.getUncertaintyMode();
1017 return mode == gpr::UncertaintyMode::EB ||
1019 }

◆ localKernelSeed()

const LocalKernelSeed & gpr::neb::ActiveLearningSession::localKernelSeed ( ) const
inlinenodiscardnoexcept

Definition at line 1318 of file Session.h.

1319 {
1320 return local_kernel_seed_;
1321 }

◆ markCurrentTrainingRevisionRetainedByPolicy()

void gpr::neb::ActiveLearningSession::markCurrentTrainingRevisionRetainedByPolicy ( const policy::TrainingPolicy * policy)
inlinenoexcept

Definition at line 1766 of file Session.h.

1768 {
1769 policy_retained_owner_ = policy;
1770 policy_retained_training_revision_ = training_revision_;
1771 }

◆ markModelMaterialized()

void gpr::neb::ActiveLearningSession::markModelMaterialized ( int owner,
const Eigen::VectorXd & theta,
const SharedParameterState & shared_state )
inline

Definition at line 2592 of file Session.h.

2594 {
2595 const double noise_floor_sigma2 = likelihoodNoiseFloorSigma2();
2596 if (owner >= 0 && owner < static_cast<int>(image_models.size())) {
2597 ImageModel& model = image_models[owner];
2598 if (model.gp() && model.observations().R.rows() > 0) {
2599 (void)model.gp()->applyLikelihoodNoiseVarianceFloor(
2600 noise_floor_sigma2, model.observations());
2601 }
2602 model.recordMaterialized(theta, noise_floor_sigma2, shared_state);
2603 } else if (owner < 0 && training_obs.R.rows() > 0) {
2604 (void)gp.applyLikelihoodNoiseVarianceFloor(noise_floor_sigma2,
2605 training_obs);
2606 conditioned_training_revision_ = training_revision_;
2607 }
2608 markActiveModel(owner);
2609 }

◆ mmfModelOwner()

int gpr::neb::ActiveLearningSession::mmfModelOwner ( int image_idx,
bool dimer_use_global_gp ) const
inlinenodiscard

Definition at line 1080 of file Session.h.

1082 {
1083 const bool image_model_eligible =
1085 if (image_model_eligible &&
1086 image_models[image_idx].internalCoordinateChart()) {
1087 return image_idx;
1088 }
1089 return selectMmfModelOwner(dimer_use_global_gp, image_model_eligible,
1090 image_idx);
1091 }
bool imageModelEligibleForPrediction(int i) const
Definition Session.h:2797
static int selectMmfModelOwner(bool dimer_use_global_gp, bool image_model_eligible, int image_idx)
Definition Session.h:235

◆ mmfSurrogateFingerprint()

SurrogateFingerprint gpr::neb::ActiveLearningSession::mmfSurrogateFingerprint ( int image_idx,
bool dimer_use_global_gp ) const
inlinenodiscard

Definition at line 1093 of file Session.h.

1095 {
1096 return surrogateFingerprint(
1097 mmfModelOwner(image_idx, dimer_use_global_gp));
1098 }
int mmfModelOwner(int image_idx, bool dimer_use_global_gp) const
Definition Session.h:1080
SurrogateFingerprint surrogateFingerprint(int owner) const
Definition Session.h:1070

◆ nearestTrainingDistance()

double gpr::neb::ActiveLearningSession::nearestTrainingDistance ( const Eigen::VectorXd & positions) const
inlinenodiscard

Nearest training row to positions, in the metric the floor is stated in.

EMD, not a Cartesian norm. The floor above is the dimer's, and the dimer compares it against dist_emd; the archive's own neighbourhood selection uses dist_emd too. A Cartesian norm would be a different metric wearing the same threshold, and it would also call two configurations far apart when they differ only by relabelling equivalent atoms.

Definition at line 1555 of file Session.h.

1557 {
1558 if (training_obs.R.rows() == 0)
1559 return std::numeric_limits<double>::infinity();
1560 gpr::Coord query(1, positions.size());
1561 query.row(0) = positions.transpose();
1562 aux::Distance distance;
1564 distance.dist_emd(query, training_obs.R, atoms_config, d);
1565 if (d.size() == 0) return std::numeric_limits<double>::infinity();
1566 return d.minCoeff();
1567 }
FieldMatrixd Coord
Definition Macros.h:35

◆ noteExternalHyperparameterFit()

void gpr::neb::ActiveLearningSession::noteExternalHyperparameterFit ( )
inlinenoexcept

applySeededModel() installed hyperparameters for the rows held now. Later appends still request a refit.

Definition at line 1325 of file Session.h.

1326 {
1327 gp_model_ready_ = training_obs.R.rows() > 0;
1328 fitted_training_revision_ = training_revision_;
1329 conditioned_training_revision_ = training_revision_;
1330 kernel_requires_refit_ = false;
1331 }

◆ noteExternalTrainingEdit()

void gpr::neb::ActiveLearningSession::noteExternalTrainingEdit ( )
inlinenoexcept

Rows of ~training_obs~ were replaced outside append and prune. The fitted factor no longer matches, so the next refit rebuilds it.

Definition at line 1761 of file Session.h.

1762 {
1763 recordTrainingMutation();
1764 }

◆ noteLocalKernelSeed()

void gpr::neb::ActiveLearningSession::noteLocalKernelSeed ( double signal_variance,
double length_scale )
inlinenoexcept

Definition at line 1307 of file Session.h.

1309 {
1310 if (!(std::isfinite(signal_variance) && signal_variance > 0.0 &&
1311 std::isfinite(length_scale) && length_scale > 0.0))
1312 return;
1313 local_kernel_seed_.present = true;
1314 local_kernel_seed_.signal_variance = signal_variance;
1315 local_kernel_seed_.length_scale = length_scale;
1316 }

◆ notePriorObservations()

void gpr::neb::ActiveLearningSession::notePriorObservations ( int count)
inlinenoexcept

Definition at line 1293 of file Session.h.

1294 {
1295 prior_observations_ = count;
1296 }

◆ noteTrueForceSecant()

void gpr::neb::ActiveLearningSession::noteTrueForceSecant ( int image_idx,
const Eigen::VectorXd & positions,
double energy,
const Eigen::VectorXd & gradient )
inline

True-force secant only. Training retention is unchanged.

Definition at line 361 of file Session.h.

363 {
364 observeSecant(image_idx, positions, gradient, energy,
366 /*training_row=*/false);
367 }

◆ observationResolutionFloor()

double gpr::neb::ActiveLearningSession::observationResolutionFloor ( ) const
inlinenodiscard

Spacing below which a new row carries no information the model can use, taken from the model's own state rather than set as a number.

This is the dimer's information floor, d = l * sqrt(noise/magn) / 2: the posterior curvature recoverable from observations spaced d apart halves there, so rows closer than that add no curvature information at the live noise level and only degrade conditioning. The dimer has bounded itself with it for a while; GPNEB.h says in as many words that the band path needs the same and does not have it.

Returns a non-positive value when the model cannot state one yet, in which case the caller admits the row.

Definition at line 1530 of file Session.h.

1531 {
1532 if (!initialised) return -1.0;
1533 const auto& cov = gp.getSexpAtCovarianceFunction();
1534 const double magn = cov.getMagnSigma2();
1535 const double noise = gp.getSigma2();
1536 const auto& ls = cov.getLengthScaleRef();
1537 if (ls.size() == 0 || !std::isfinite(magn) || !(magn > 0.0) ||
1538 !std::isfinite(noise) || !(noise > 0.0))
1539 return -1.0;
1540 const double l_min = ls.minCoeff();
1541 if (!std::isfinite(l_min) || !(l_min > 0.0)) return -1.0;
1542 const double d = 0.5 * l_min * std::sqrt(noise / magn);
1543 return std::isfinite(d) ? d : -1.0;
1544 }

◆ observationVarianceAtImage()

void gpr::neb::ActiveLearningSession::observationVarianceAtImage ( int i,
gpr::Observation & probe )
inline

Per-image joint energy-and-gradient variance with global fallback. The returned Observation carries every channel used by acquisition.

Definition at line 2819 of file Session.h.

2820 {
2821 withImageChartFallback(i, [&](gpr::GaussianProcessRegression& gp) {
2822 gp.calculateVarianceDispatched(probe);
2823 });
2824 }
void withImageChartFallback(int i, Use &&use)
Definition Session.h:2836

◆ predictAtImage()

void gpr::neb::ActiveLearningSession::predictAtImage ( int i,
gpr::Observation & probe )
inline

Per-image predict with global fallback. Returns the predicted (energy, gradient) in ~probe~. If image ~i~'s local set has at least ~min_per_image_n_train~ neighbourhood rows the call goes through the local GP; otherwise it routes through the global ~gp~.

Definition at line 2810 of file Session.h.

2811 {
2812 withImageChartFallback(i, [&](gpr::GaussianProcessRegression& gp) {
2813 gp.calculatePotentialDispatched(probe);
2814 });
2815 }

◆ priorObservations()

int gpr::neb::ActiveLearningSession::priorObservations ( ) const
inlinenodiscardnoexcept

Rows loaded from a seed file. Not an oracle-call count.

Definition at line 1288 of file Session.h.

1289 {
1290 return prior_observations_;
1291 }

◆ pruneImageModelsAdaptive()

int gpr::neb::ActiveLearningSession::pruneImageModelsAdaptive ( const gpr::Coord & band_positions)
inline

Per-image adaptive pruning across every activated single-image GP: each model prunes against its own band point only. The global set stays as the double-GP concept demands – the global model hands over to the single-image ones, and each of those conditions on an adaptively pruned local set.

Definition at line 3089 of file Session.h.

3090 {
3091 if (!initialised) return 0;
3092 int pruned = 0;
3093 const Eigen::Index rows = band_positions.rows();
3094 for (std::size_t i = 0; i < image_models.size(); ++i) {
3095 if (static_cast<Eigen::Index>(i) >= rows) break;
3096 auto& model = image_models[i];
3097 if (!model.gp()) continue;
3098 const Eigen::VectorXd point =
3099 band_positions.row(static_cast<Eigen::Index>(i)).transpose();
3100 pruned += model.pruneAdaptiveAtPoint(point);
3101 }
3102 return pruned;
3103 }

◆ pruneLeastInfluentialRow()

int gpr::neb::ActiveLearningSession::pruneLeastInfluentialRow ( const gpr::Coord & band_positions,
bool ignore_noise )
inline

Remove the single least influential row. ignore_noise drops it regardless of the one-sigma test, which is what a budget needs: the question there is not whether the row is redundant but whether it is the least useful of the ones that no longer fit.

Definition at line 2979 of file Session.h.

2981 {
2982 if (!initialised || training_obs.R.rows() == 0) return 0;
2983 // Keep enough rows that the posterior stays determined; the
2984 // floor is the joint block size, not a tuning knob.
2985 const Eigen::Index min_rows = 4;
2986 if (training_obs.R.rows() <= min_rows) return 0;
2987
2988 // Influence belongs to the retained observations, including acquired
2989 // rows. Activate their distributed factor so pruning can stream its
2990 // solves without replicating a full covariance on every rank.
2992 // Rows the band stands on are the support of the region it may
2993 // relax in: an image may step only while it stays within one
2994 // kernel correlation length of some training row (the ARD metric
2995 // r^2 = sum ((1/r_ij - 1/r_ij')/l_ij)^2, r <= 1). Every row within
2996 // that length of a current band image is kept; pruning it shrank
2997 // the support the next step needs, and a point acquired past the
2998 // boundary was dropped in the same outer (irc 11_trans_butadiene
2999 // ocineb: one call per outer for 999 outers).
3000 std::vector<char> protected_row(
3001 static_cast<std::size_t>(training_obs.R.rows()), 0);
3002 if (band_positions.rows() > 0 &&
3003 band_positions.cols() == training_obs.R.cols()) {
3004 gpr::FieldMatrixd kernel_distance_matrix;
3005 gp.getSexpAtCovarianceFunction().correlationDistances(
3006 band_positions, training_obs.R, atoms_config,
3007 kernel_distance_matrix);
3008 for (Eigen::Index b = 0; b < kernel_distance_matrix.rows(); ++b) {
3009 for (Eigen::Index r = 0; r < kernel_distance_matrix.cols();
3010 ++r) {
3011 const double d = kernel_distance_matrix(b, r);
3012 if (std::isfinite(d) && d <= 1.0 &&
3013 r < static_cast<Eigen::Index>(protected_row.size())) {
3014 protected_row[static_cast<std::size_t>(r)] = 1;
3015 }
3016 }
3017 }
3018 }
3019 const Eigen::Index recent =
3020 std::min(band_positions.rows(), training_obs.R.rows());
3021 for (Eigen::Index r = training_obs.R.rows() - recent;
3022 r < training_obs.R.rows(); ++r)
3023 protected_row[static_cast<std::size_t>(r)] = 1;
3024 Eigen::VectorXd influence;
3025 if (!gp.observationBandInfluence(training_obs, band_positions,
3026 influence, /*collective=*/true,
3027 protected_row)) {
3028 return 0;
3029 }
3030 if (influence.size() != training_obs.R.rows()) return 0;
3031 const double noise_sigma =
3032 std::sqrt(std::max(gp.getLikGaussian().getSigma2(), 0.0));
3033 if (!(noise_sigma > 0.0) || !std::isfinite(noise_sigma)) return 0;
3034
3035 // The single-row downdate behind the influence score is exact for
3036 // ONE deletion: removing a row changes every remaining row's
3037 // influence (a near-duplicate of a deleted row becomes essential),
3038 // so batch deletion against a stale influence vector collapses
3039 // correlated groups. Remove only the minimum-influence row per
3040 // prune event; the cadence gate in the caller bounds the rate.
3041 int pruned = 0;
3042 Eigen::Index r_min = -1;
3043 double v_min = std::numeric_limits<double>::infinity();
3044 for (Eigen::Index r = 0; r < influence.size(); ++r) {
3045 if (protected_row[static_cast<std::size_t>(r)]) continue;
3046 if (influence(r) < v_min) {
3047 v_min = influence(r);
3048 r_min = r;
3049 }
3050 }
3051 if (r_min >= 0 && (ignore_noise || v_min < noise_sigma)) {
3052 detail::eraseObservationRow(training_obs, r_min);
3053 if (static_cast<size_t>(r_min) < training_multiplicity.size()) {
3055 r_min);
3056 }
3057 for (auto& model: image_models) {
3058 model.compactAfterRowRemoval(static_cast<int>(r_min));
3059 }
3060 ++pruned;
3061 }
3062 if (pruned > 0) {
3063 discardPrunedSecantReplay();
3064 recordTrainingMutation();
3065 // Row removal changes the design, not the evidence for theta:
3066 // rebuild the posterior on the surviving rows at the CURRENT
3067 // hyperparameters. Running SCG here would also break the
3068 // acquisition bootstrap, which relies on the outer-0
3069 // activation seeing the unfitted prior variance.
3070 parkActiveModelBeforeSwitch(-1);
3071 if (virtual_obs.R.rows() > 0) {
3072 materializeWithNoiseFloor(gp, composedTrainingObs(),
3073 likelihoodNoiseFloorSigma2());
3074 } else {
3075 materializeWithNoiseFloor(gp, training_obs,
3076 likelihoodNoiseFloorSigma2());
3077 }
3078 conditioned_training_revision_ = training_revision_;
3079 markActiveModel(-1);
3080 }
3081 return pruned;
3082 }

◆ pruneTrainingObservationsAdaptive()

int gpr::neb::ActiveLearningSession::pruneTrainingObservationsAdaptive ( const gpr::Coord & band_positions)
inline

Adaptive pruning: drop training observations whose removal moves the posterior energy and every Cartesian force at every band point by less than the likelihood noise. The influence is the exact block downdate (see ~GaussianProcessRegression::observationBandInfluence~ and scripts/derive_adaptive_pruning_influence.py), so the threshold is a unit comparison against noise rather than a tuned constant: a row that cannot move any band prediction by one sigma carries no information the band posterior uses, while it still costs O(n^3) in every later refit.

Per-image models hold global row indices, so every removal is mirrored through ~ImageModel::compactAfterRowRemoval~, which drops references to the removed row and shifts the rest down. Removals run highest index first so earlier compactions never disturb the indices still to be removed. Returns the number of pruned observations.

Definition at line 2935 of file Session.h.

2936 {
2937 return pruneLeastInfluentialRow(band_positions, /*ignore_noise=*/false);
2938 }
int pruneLeastInfluentialRow(const gpr::Coord &band_positions, bool ignore_noise)
Definition Session.h:2979

◆ pruneTrainingObservationsToBudget()

int gpr::neb::ActiveLearningSession::pruneTrainingObservationsToBudget ( const gpr::Coord & band_positions,
Eigen::Index max_rows )
inline

Prune down to a row budget, least influential first.

The threshold prune below removes a row only when it moves the band by less than one likelihood sigma. On these runs that never holds: no [prune] line appears in any campaign log while the training set climbs past 150 observations. Nothing is redundant by that test, so nothing is dropped, and the set grows without bound.

That is what makes an outer iteration cost grow: the kernel order is the observation count times (1 + 3 natoms), the append is two O(m^3) steps, and summing that over a run is quartic in the outer count. A budget converts it to linear.

Influence is recomputed between removals for the reason the threshold prune states: deleting a row changes what every other row is worth, so a batch decided against one stale vector collapses correlated groups. That costs an influence evaluation per removal, which is cheap beside the factorisation it saves.

Returns
rows removed.

Definition at line 2960 of file Session.h.

2962 {
2963 if (!initialised || max_rows <= 0) return 0;
2964 int removed = 0;
2965 while (training_obs.R.rows() > max_rows) {
2966 const int dropped = pruneLeastInfluentialRow(band_positions,
2967 /*ignore_noise=*/true);
2968 if (dropped == 0) break; // floor reached, or no influence
2969 removed += dropped;
2970 }
2971 if (removed > 0) recordTrainingMutation();
2972 return removed;
2973 }

◆ publishPolicyProgress()

void gpr::neb::ActiveLearningSession::publishPolicyProgress ( int iteration,
int oracle_calls,
int refits,
int training_size )
inlinenoexcept

Definition at line 3281 of file Session.h.

3283 {
3284 policy::publishPolicyProgress(policy_context_.get(), iteration,
3285 oracle_calls, refits, training_size);
3286 }
void publishPolicyProgress(PolicyContext *context, int iteration, int oracle_calls, int refits, int training_size) noexcept

◆ purchaseSecantConsistencyProbe()

template<class Measure>
bool gpr::neb::ActiveLearningSession::purchaseSecantConsistencyProbe ( Measure && measure)
inline

Compare the fitted GP Hessian action with the latest true-force secant. A disagreement buys one forward force probe. measure evaluates that probe and retains it, and returns false when the oracle budget or the oracle itself did not deliver it; that probe is not counted.

Definition at line 303 of file Session.h.

304 {
305 if (!secant_config_.consistency_check) return false;
306 if (!global_secant_.available() ||
307 global_secant_.pairs() <= secant_pairs_checked_)
308 return false;
309 const double length = global_secant_.lastDirection().norm();
310 if (!(length > 0.0) || !std::isfinite(length))
311 throw std::runtime_error(
312 "secant consistency requested but the latest step is "
313 "degenerate");
314 const Eigen::VectorXd direction =
315 global_secant_.lastDirection() / length;
316 gpr::Coord at_reference(1, direction.size());
317 at_reference.row(0) = global_secant_.referencePosition().transpose();
318 Eigen::VectorXd posterior_action;
319 if (!gp.isDecomposedSuccessfully() && !gp.hasActivePosterior())
320 return false;
321 if (!gp.calculateMeanHessianVectorDispatched(at_reference, direction,
322 posterior_action))
323 return false;
324 const optim::SecantConsistency consistency = global_secant_.consistency(
325 posterior_action, secant_config_.consistency_relative_tolerance);
326 if (!consistency.available)
327 throw std::runtime_error(
328 "secant consistency requested but comparison is invalid");
329 secant_pairs_checked_ = global_secant_.pairs();
330 if (consistency.trusted) return false;
331 ++secant_counts_.consistency_rejections;
332 if (secant_counts_.hvp_calls != 0) return false;
333 if (!(secant_config_.finite_difference_step > 0.0) ||
334 !std::isfinite(secant_config_.finite_difference_step))
335 throw std::invalid_argument(
336 "secant finite-difference step must be positive");
337 const Eigen::VectorXd probe =
338 global_secant_.referencePosition() +
339 secant_config_.finite_difference_step * consistency.direction;
340 if (!std::forward<Measure>(measure)(probe)) return false;
341 ++secant_counts_.hvp_calls;
342 return true;
343 }

◆ recordCurrentChainCertificate() [1/2]

void gpr::neb::ActiveLearningSession::recordCurrentChainCertificate ( int image_idx,
const Eigen::VectorXd & positions )
inline

Definition at line 2010 of file Session.h.

2012 {
2013 if (image_idx < 0) return;
2014 const auto slot = static_cast<std::size_t>(image_idx);
2015 if (current_chain_certificates.size() <= slot) {
2016 current_chain_certificates.resize(slot + 1);
2017 }
2018 auto& certificate = current_chain_certificates[slot];
2019 if (certificate.image_index == image_idx &&
2020 detail::positionsCoincide(certificate.positions, positions)) {
2021 return;
2022 }
2023 certificate = IndexedObservation{};
2024 certificate.image_index = image_idx;
2025 certificate.positions = positions;
2026 certificate.certificate_row = true;
2027 }

◆ recordCurrentChainCertificate() [2/2]

void gpr::neb::ActiveLearningSession::recordCurrentChainCertificate ( int image_idx,
const Eigen::VectorXd & positions,
double energy,
const Eigen::VectorXd & gradient )
inline

Definition at line 2029 of file Session.h.

2033 {
2034 recordCurrentChainCertificate(image_idx, positions);
2035 if (image_idx < 0 || !std::isfinite(energy) ||
2036 gradient.size() != positions.size() || !gradient.allFinite()) {
2037 return;
2038 }
2039 auto& certificate =
2040 current_chain_certificates[static_cast<std::size_t>(image_idx)];
2041 certificate.energy = energy;
2042 certificate.gradient = gradient;
2043 }

◆ refitGP()

bool gpr::neb::ActiveLearningSession::refitGP ( bool reinit_seeds)
inline

Convenience: refit hyperparameters then optimize. ~reinit_seeds~ controls whether ~setHyperparameters~ re-derives seeds from data statistics (cold) or warm-starts from the previous fit. See ~GPNEB.cpp~ for the cold/warm rationale. Returns false when a training policy keeps the hyperparameters and only the factor is updated.

Definition at line 3111 of file Session.h.

3112 {
3113 syncSecantQuadraticPrior();
3114 bool pruned_now = false;
3115 if (policy_context_ != nullptr && policy_context_->policy != nullptr &&
3116 (policy_retained_owner_ != policy_context_->policy ||
3117 policy_retained_training_revision_ != training_revision_)) {
3118 pruned_now = retainTrainingRowsForPolicy(*policy_context_->policy);
3119 }
3120 if (policy_context_ != nullptr && policy_context_->policy != nullptr) {
3121 policy::SearchState state;
3122 state.kind = policy_context_->kind;
3123 state.iteration = policy_context_->iteration;
3124 state.oracle_calls = policy_context_->oracle_calls;
3125 state.training_size = static_cast<int>(training_obs.R.rows());
3126 state.hyperparameter_refits =
3127 policy_context_->hyperparameter_refits;
3128 state.engine_would_retrain = true;
3129 state.engine_would_rebuild_factor = true;
3130 state.gp = &gp;
3131 const policy::TrainingPolicy* policy = policy_context_->policy;
3133 state)) {
3134 const bool rebuild =
3136 gp.clearModeRefitHint();
3137 if (!initialised) initialise();
3138 if (!rebuild && gp_model_ready_ &&
3139 gp.trainingFactorAppendable(training_obs.R.rows())) {
3140 parkActiveModelBeforeSwitch(-1);
3141 gp.updateModelWithFullData(virtual_obs.R.rows() > 0
3143 : training_obs);
3144 conditioned_training_revision_ = training_revision_;
3145 markActiveModel(-1);
3146 } else if (!pruned_now || !gp_model_ready_) {
3147 if (rebuild && gp_model_ready_) {
3148 parkActiveModelBeforeSwitch(-1);
3149 gp.invalidateTrainingFactorCache();
3150 }
3152 } else if (rebuild && gp_model_ready_) {
3153 // retainTrainingRowsForPolicy already invalidated and
3154 // rebuilt the factor on the pruned rows.
3155 }
3156 fitted_training_revision_ = training_revision_;
3157 conditioned_training_revision_ = training_revision_;
3158 kernel_requires_refit_ = false;
3159 gp_model_ready_ = training_obs.R.rows() > 0;
3160 return false;
3161 }
3162 }
3163 if (!initialised) initialise();
3164 parkActiveModelBeforeSwitch(-1);
3165 // Coordinate updates retain the other component in the likelihood.
3166 // The heat amplitude is re-estimated on the supplied path after the
3167 // base parameters have been optimized.
3168 if (global_geodesic_reference_path_.size() == 0)
3169 gp.clearGeodesicHeatPrior();
3170 if (global_internal_coordinate_chart_) {
3171 gp.setInternalCoordinateChart(
3172 global_internal_coordinate_chart_,
3173 global_internal_coordinate_length_scale_);
3174 }
3175 gp.setHyperparameters(training_obs, atoms_config, reinit_seeds,
3176 reinit_seeds, reinit_seeds);
3177 const double noise_floor_sigma2 = likelihoodNoiseFloorSigma2();
3178 (void)gp.applyLikelihoodNoiseVarianceFloor(noise_floor_sigma2,
3179 training_obs);
3180 if (!gp.atomicEnvironmentModelEnabled() &&
3181 global_internal_coordinate_chart_) {
3182 // The charted likelihood uses its analytic parameter gradient.
3183 // The pair-distance stationarity shortcut does not represent
3184 // this covariance and cannot certify its parameter fit.
3185 gp.optimize(training_obs);
3186 (void)gp.applyLikelihoodNoiseVarianceFloor(noise_floor_sigma2,
3187 training_obs);
3188 materializeWithNoiseFloor(gp, training_obs, noise_floor_sigma2);
3189 } else {
3190 // The objective's stationarity test runs first: a stationary
3191 // optimum holds theta, a moved one takes its Newton step at one
3192 // evaluation, and the optimizer runs only when neither applies.
3193 // Per-append SCG at 30 evaluations was the wall of every slow
3194 // cell (Birkholz 11_grignard: 394 s of a 448 s outer).
3195 const bool held_or_stepped =
3196 !reinit_seeds &&
3197 gp.refreshFullDataPosteriorIfObjectiveStationary(training_obs);
3198 if (!held_or_stepped) gp.optimize(training_obs);
3199 (void)gp.applyLikelihoodNoiseVarianceFloor(noise_floor_sigma2,
3200 training_obs);
3201 }
3202 if (!gp.atomicEnvironmentModelEnabled() &&
3203 global_internal_coordinate_chart_) {
3204 global_internal_coordinate_length_scale_ =
3205 gp.getSexpAtCovarianceFunction().getLengthScaleRef()(0, 0);
3206 }
3207 if (!gp.atomicEnvironmentModelEnabled() &&
3208 global_geodesic_reference_path_.size() > 0) {
3209 (void)gp.fitGeodesicHeatPrior(global_geodesic_reference_path_,
3210 training_obs);
3211 }
3212 if (virtual_obs.R.rows() > 0) {
3213 materializeWithNoiseFloor(gp, composedTrainingObs(),
3214 likelihoodNoiseFloorSigma2());
3215 }
3216 gp_model_ready_ = true;
3217 fitted_training_revision_ = training_revision_;
3218 conditioned_training_revision_ = training_revision_;
3219 kernel_requires_refit_ = false;
3220 acquired_evidence_nats_ = 0.0;
3221 markActiveModel(-1);
3222 return true;
3223 }
bool consensusShouldRebuildFactor(const TrainingPolicy &policy, const SearchState &state)
bool consensusShouldRetrainHyperparameters(const TrainingPolicy &policy, const SearchState &state)
bool retainTrainingRowsForPolicy(const policy::TrainingPolicy &policy)
Definition Session.h:1777

◆ refitGPIfTrainingChanged()

bool gpr::neb::ActiveLearningSession::refitGPIfTrainingChanged ( bool reinit_seeds)
inline

Warm-refit only when the training set changed since the fitted theta. Returns true when a refit was performed.

Definition at line 3301 of file Session.h.

3302 {
3303 if (!hyperparametersNeedRefit()) return false;
3304 refitGP(reinit_seeds);
3305 return true;
3306 }
bool hyperparametersNeedRefit() const noexcept
Definition Session.h:3292
bool refitGP(bool reinit_seeds)
Definition Session.h:3111

◆ refitImageGP()

bool gpr::neb::ActiveLearningSession::refitImageGP ( int i)
inline

Refit image ~i~'s local GP on its current training data, with theta inherited from the global ~gp~. Compatible EB and Laplace models share its parameter measure and condition on local rows. Distinct conditioning sets can give different boundary predictions. Returns false when no valid local posterior can be materialized.

Definition at line 2432 of file Session.h.

2433 {
2434 if (gp.atomicEnvironmentModelEnabled()) return false;
2435 if (i < 0 || i >= static_cast<int>(image_models.size())) return false;
2436 ImageModel& model = image_models[i];
2437 gpr::GaussianProcessRegression* local_gp = model.gp();
2438 if (!local_gp) return false;
2439 const gpr::Observation& local_obs = model.observations();
2440 if (local_obs.R.rows() == 0) return false;
2441 gpr::GaussianProcessRegression::HyperparameterPosterior
2442 shared_posterior;
2443 if (sharesGlobalHyperparameters(*local_gp)) {
2445 shared_posterior = gp.retainHyperparameterPosterior();
2446 if (shared_posterior.empty()) return false;
2447 }
2448 // No per-image SCG. The local set is a geometric
2449 // neighbourhood of an image that may have been oracled many
2450 // times at nearly the same geometry, so it carries
2451 // near-duplicate rows. A per-image hyperparameter search on
2452 // that ill-conditioned covariance drives theta_i to extremes
2453 // and the per-image variance blows up -- the chain barrier
2454 // then runs away. The local GP instead inherits the global
2455 // MAP theta and only conditions on its local rows. Integrated
2456 // uncertainty uses the global weights without counting this
2457 // subset's likelihood a second time.
2458 const Eigen::VectorXd theta_global = gp.packInlaHyperparameters();
2459 const auto shared_state = sharedParameterState();
2460 const double noise_floor_sigma2 = likelihoodNoiseFloorSigma2();
2461 parkActiveModelBeforeSwitch(i);
2462 local_gp->restoreLengthScaleFitState(shared_state.length_scales);
2463 local_gp->setHyperparameters(local_obs, atoms_config, true, true, true);
2465 auto& local_covariance = local_gp->getSexpAtCovarianceFunction();
2466 const auto& global_covariance = gp.getSexpAtCovarianceFunction();
2467 local_covariance.getAtomisticLengthScaleRef() =
2468 global_covariance.getAtomisticLengthScaleRef();
2469 local_covariance.setMagnSigma2(global_covariance.getMagnSigma2());
2471 gp.getConstantCovarianceFunction().getConstSigma2());
2472 if (model.internalCoordinateChart()) {
2474 model.internalCoordinateChart(),
2475 model.internalCoordinateLengthScale());
2476 }
2477 // Pack this model's parameter domain: the global pair metric can
2478 // have several lengths while a local chart has exactly one.
2479 Eigen::VectorXd local_parameters = local_covariance.combineParameters();
2480 if (theta_global.size() >
2481 global_covariance.getLengthScaleRef().size() + 1) {
2482 const Eigen::Index count = local_parameters.size();
2483 local_parameters.conservativeResize(count + 1);
2484 local_parameters(count) = std::log(gp.likelihoodNoiseVariance());
2485 }
2486 local_gp->setParameters(local_parameters);
2487 // Fixed likelihood noise belongs to the shared model even when its
2488 // variance is absent from the optimized parameter vector.
2489 (void)local_gp->setLikelihoodNoiseVariance(
2490 gp.outputScale() * gp.outputScale() * gp.likelihoodNoiseVariance());
2491 if (model.hasGeodesicReferencePath()) {
2492 (void)local_gp->applyLikelihoodNoiseVarianceFloor(
2493 noise_floor_sigma2, local_obs);
2494 (void)local_gp->fitGeodesicHeatPrior(model.geodesicReferencePath(),
2495 local_obs);
2496 } else {
2497 materializeWithNoiseFloor(*local_gp, local_obs, noise_floor_sigma2);
2498 }
2500 if (!local_gp->activateMaterializedPosterior()) return false;
2501 if (!shared_posterior.empty() &&
2502 !local_gp->conditionOnHyperparameterPosterior(shared_posterior))
2503 return false;
2504 model.recordMaterialized(theta_global, noise_floor_sigma2,
2505 shared_state);
2506 markActiveModel(i);
2507 return true;
2508 }
void setConstSigma2(const double _constSigma2)
Set the constSigma2 value.
LikelihoodNoiseVarianceUpdate setLikelihoodNoiseVariance(double physical_sigma2, const Observation *full_observation=nullptr)
Set the likelihood noise variance in physical output units.
bool conditionOnHyperparameterPosterior(const HyperparameterPosterior &posterior)
void setParameters(const GPRSetup &parameters)
Set parameters of the GPR model.
void setInternalCoordinateChart(std::shared_ptr< const geometry::InternalCoordinateChart > chart, double length_scale)
void synchronizeOutputTransformFrom(const GaussianProcessRegression &source)
double fitGeodesicHeatPrior(const Coord &reference_path, const Observation &training_data)
void setHyperparameters(const Observation &all_obs, const AtomsConfiguration &conf_info, const bool update_sexpat_cf_param=true, const bool update_const_cf_param=true, const bool update_sqrt_prior_param=true)
Set up hyperparameters for GPR.
bool applyLikelihoodNoiseVarianceFloor(double floor_sigma2, const Observation &full_observation)
Raise the Gaussian likelihood noise variance to a floor.
void restoreLengthScaleFitState(const LengthScaleFitState &state)

◆ refitTrainingRevisions()

std::uint64_t gpr::neb::ActiveLearningSession::refitTrainingRevisions ( ) const
inlinenodiscardnoexcept

Definition at line 1169 of file Session.h.

1170 {
1171 return refit_training_revisions_;
1172 }

◆ refreshCovarianceCache()

void gpr::neb::ActiveLearningSession::refreshCovarianceCache ( )
inline

Rebuild ~gp~'s internal model state (R_matrix, R_indices, energy_and_gradient, distributed Cholesky factor, posterior weights) from the current ~training_obs~ WITHOUT re-running hyperparameter optimisation. Use after a sibling phase (e.g. OCINEB MMF burst) mutates ~training_obs~ between outer-iter retrains: the burst's internal AtomicDimer GP factorises a different-sized covariance into the singleton ~DistributedState~ cache, so ~gp~'s distributed L is stale by the time the next NEB iter probes variance / runs a solve. ~updateModelWithFullData~ reassembles R_matrix and calls ~decomposeCovarianceMatrix~, which repopulates the singleton cache with ~gp~'s factor at the new training size. Cheaper than ~refitGP~ (no SCG NLML evaluations); the next outer iter's natural retrain handles hyperparameter updates.

Definition at line 3344 of file Session.h.

3345 {
3346 if (!initialised) return;
3347 if (training_obs.R.rows() == 0) return;
3348 // SCG runs on the training-revision cadence for every model
3349 // profile. Measured on the Baker contract
3350 // boards: per-append SCG random-walks the sloppy NLML
3351 // magnitude/lengthscale valley (09/17 barrier flips with 2-3x
3352 // mag2 swings between consecutive outers), an uncapped
3353 // stationarity trigger degenerates to per-append on descending
3354 // runs (06 and 20 timed out on its objective-evaluation cost),
3355 // and even a stationarity SKIP at cadence points costs one
3356 // objective evaluation each -- enough to push a borderline cell
3357 // (03, 127 s) over the 130 s cap for a marginal quiet-stretch
3358 // saving. Plain cadence graded best (21/24).
3360 const bool never_fitted = fitted_training_revision_ ==
3361 std::numeric_limits<std::uint64_t>::max();
3362 const std::uint64_t growth =
3363 never_fitted ? refit_training_revisions_
3364 : (training_revision_ - fitted_training_revision_);
3365 if (kernel_requires_refit_ || never_fitted ||
3366 growth >= refit_training_revisions_) {
3367 refitGP(/*reinit_seeds=*/false);
3368 return;
3369 }
3370 }
3371 if (policy_context_ != nullptr && policy_context_->policy != nullptr) {
3372 bool pruned_now = false;
3373 if (policy_retained_owner_ != policy_context_->policy ||
3374 policy_retained_training_revision_ != training_revision_) {
3375 pruned_now =
3376 retainTrainingRowsForPolicy(*policy_context_->policy);
3377 }
3378 if (training_obs.R.rows() == 0) return;
3379 policy::SearchState state;
3380 state.kind = policy_context_->kind;
3381 state.iteration = policy_context_->iteration;
3382 state.oracle_calls = policy_context_->oracle_calls;
3383 state.training_size = static_cast<int>(training_obs.R.rows());
3384 state.hyperparameter_refits =
3385 policy_context_->hyperparameter_refits;
3386 state.engine_would_retrain = false;
3387 state.engine_would_rebuild_factor =
3388 !pruned_now &&
3389 !gp.trainingFactorAppendable(training_obs.R.rows());
3390 state.gp = &gp;
3391 const policy::TrainingPolicy* policy = policy_context_->policy;
3393 refitGP(/*reinit_seeds=*/false);
3394 return;
3395 }
3396 const bool rebuild =
3398 if (pruned_now && gp_model_ready_) return;
3399 if (rebuild && gp_model_ready_) {
3400 parkActiveModelBeforeSwitch(-1);
3401 gp.invalidateTrainingFactorCache();
3402 }
3403 }
3405 }

◆ refreshLikelihoodNoiseFloor()

void gpr::neb::ActiveLearningSession::refreshLikelihoodNoiseFloor ( )
inline

Reduce the rank-owned noise floor into the shared value the materialise paths read. This call is collective: every rank must reach it, so it belongs at a point in the outer loop that no rank-local branch can skip – after an oracle batch, never inside a per-image or owned-image block.

Definition at line 1245 of file Session.h.

1246 {
1247 likelihood_noise_floor_sigma2_ = detail::allreduceFinitePositiveMaximum(
1248 localLikelihoodNoiseFloorSigma2());
1249 }

◆ resolutionDedupRejected()

long gpr::neb::ActiveLearningSession::resolutionDedupRejected ( ) const
inlinenodiscardnoexcept

Definition at line 1658 of file Session.h.

1659 {
1661 }

◆ retainTrainingRowsForPolicy()

bool gpr::neb::ActiveLearningSession::retainTrainingRowsForPolicy ( const policy::TrainingPolicy & policy)
inline

Apply ~policy.retain_training_rows~. An identity list does nothing. Any other list rebuilds the training set, the multiplicity, every image index map, and the factor at the current hyperparameters. The fitted revision is left alone: theta was not re-optimised.

Definition at line 1777 of file Session.h.

1778 {
1779 const int n = static_cast<int>(training_obs.R.rows());
1780 if (n == 0) {
1782 return false;
1783 }
1784 std::vector<Eigen::VectorXd> rows;
1785 rows.reserve(static_cast<std::size_t>(n));
1786 for (Eigen::Index row = 0; row < training_obs.R.rows(); ++row)
1787 rows.emplace_back(training_obs.R.row(row).transpose());
1788 const std::vector<int> keep =
1790 const std::vector<int> accepted =
1792 if (policy::indexListIsIdentity(accepted, n)) {
1794 return false;
1795 }
1796
1797 std::vector<int> old_to_new(static_cast<std::size_t>(n), -1);
1798 gpr::Observation next;
1799 std::vector<int> next_multiplicity;
1800 next_multiplicity.reserve(accepted.size());
1801 for (std::size_t pos = 0; pos < accepted.size(); ++pos) {
1802 const int index = accepted[pos];
1803 old_to_new[static_cast<std::size_t>(index)] = static_cast<int>(pos);
1804 const Eigen::Index row = index;
1805 const double energy =
1806 row < training_obs.E.rows() ? training_obs.E(row, 0) : 0.0;
1807 Eigen::VectorXd gradient(training_obs.R.cols());
1808 if (row < training_obs.G.rows())
1809 gradient = training_obs.G.row(row).transpose();
1810 else
1811 gradient.setZero();
1812 detail::appendObservationRow(
1813 next, training_obs.R.row(row).transpose(), energy, gradient);
1814 const int count =
1815 static_cast<std::size_t>(index) < training_multiplicity.size()
1816 ? training_multiplicity[static_cast<std::size_t>(index)]
1817 : 1;
1818 next_multiplicity.push_back(count);
1819 }
1820 if (policy::indexListIsIdentity(accepted, n)) {
1822 return false;
1823 }
1824
1825 training_obs = std::move(next);
1826 training_multiplicity = std::move(next_multiplicity);
1827 discardPrunedSecantReplay();
1828 for (auto& model: image_models)
1829 model.remapGlobalRows(old_to_new, training_obs);
1830 recordTrainingMutation();
1832 acquired_evidence_nats_ = 0.0;
1833 if (training_obs.R.rows() == 0) {
1834 gp_model_ready_ = false;
1835 kernel_requires_refit_ = true;
1836 return true;
1837 }
1838 if (initialised && gp_model_ready_) {
1839 parkActiveModelBeforeSwitch(-1);
1840 gp.invalidateTrainingFactorCache();
1842 }
1843 return true;
1844 }
std::vector< int > canonicalizeRetainedIndices(const std::vector< int > &keep, int n)
std::vector< int > consensusRetainTrainingRows(const TrainingPolicy &policy, const std::vector< Eigen::VectorXd > &rows)
bool indexListIsIdentity(const std::vector< int > &indices, int n)
void markCurrentTrainingRevisionRetainedByPolicy(const policy::TrainingPolicy *policy) noexcept
Definition Session.h:1766

◆ retireVirtualObservationsNear()

void gpr::neb::ActiveLearningSession::retireVirtualObservationsNear ( const Eigen::VectorXd & positions)
inline

Drop every virtual row whose retire radius covers ~positions~. Called on each real append: a genuine measurement supersedes the prior pin in its neighbourhood.

Definition at line 1893 of file Session.h.

1894 {
1895 bool changed = false;
1896 for (Eigen::Index r = virtual_obs.R.rows() - 1; r >= 0; --r) {
1897 const double d =
1898 (virtual_obs.R.row(r).transpose() - positions).norm();
1899 if (d < virtual_retire_radii[static_cast<std::size_t>(r)]) {
1900 detail::eraseObservationRow(virtual_obs, r);
1902 static_cast<std::ptrdiff_t>(r));
1903 changed = true;
1904 }
1905 }
1906 if (changed) syncVirtualNoiseTag();
1907 }

◆ rollbackTrainingObservations()

bool gpr::neb::ActiveLearningSession::rollbackTrainingObservations ( Eigen::Index row_count)
inline

Remove speculative suffix rows from the global training buffer and compact every per-image view that references those rows.

Definition at line 2874 of file Session.h.

2875 {
2876 if (row_count < 0) return false;
2877 const Eigen::Index current = training_obs.R.rows();
2878 if (row_count >= current) return false;
2879 for (Eigen::Index r = current; r > row_count; --r) {
2880 compactAfterRowRemoval(static_cast<int>(r - 1));
2881 }
2882 training_obs.R.conservativeResize(row_count, training_obs.R.cols());
2883 training_obs.E.conservativeResize(row_count, training_obs.E.cols());
2884 training_obs.G.conservativeResize(row_count, training_obs.G.cols());
2885 if (training_multiplicity.size() > static_cast<size_t>(row_count)) {
2886 training_multiplicity.resize(static_cast<size_t>(row_count));
2887 }
2888 discardPrunedSecantReplay();
2889 gp_model_ready_ = false;
2890 recordTrainingMutation();
2891 markActiveModel(-1);
2892 return true;
2893 }
void compactAfterRowRemoval(int removed_row)
Definition Session.h:2865

◆ rollbackTrainingObservationsRetaining()

bool gpr::neb::ActiveLearningSession::rollbackTrainingObservationsRetaining ( Eigen::Index row_count,
const std::vector< IndexedObservation > & retained_observations )
inline

Definition at line 2905 of file Session.h.

2908 {
2909 const bool rolled_back = rollbackTrainingObservations(row_count);
2910 if (!retained_observations.empty()) {
2911 appendIndexedObservations(retained_observations);
2912 } else if (rolled_back) {
2914 }
2915 return rolled_back;
2916 }
bool rollbackTrainingObservations(Eigen::Index row_count)
Definition Session.h:2874
void appendIndexedObservations(const std::vector< IndexedObservation > &observations)
Definition Session.h:2895

◆ secantCounts()

optim::SecantCurvatureCounts gpr::neb::ActiveLearningSession::secantCounts ( ) const
inlinenodiscard

Definition at line 396 of file Session.h.

397 {
398 optim::SecantCurvatureCounts counts = secant_counts_;
399 counts.quadratic_mean_uses += gp.secantQuadraticPriorUses();
400 return counts;
401 }

◆ secantReplayHoldsTrainingRow()

bool gpr::neb::ActiveLearningSession::secantReplayHoldsTrainingRow ( const Eigen::VectorXd & position) const
inlinenodiscard

True when an admitted-row sample still holds ~position~.

Definition at line 385 of file Session.h.

387 {
388 for (const SecantReplaySample& sample: secant_replay_) {
389 if (!sample.training_row) continue;
390 if (detail::positionsCoincide(sample.position, position))
391 return true;
392 }
393 return false;
394 }

◆ secantReplaySize()

std::size_t gpr::neb::ActiveLearningSession::secantReplaySize ( ) const
inlinenodiscardnoexcept

Samples kept so reconfigure can rebuild per-image secant seeds.

Definition at line 370 of file Session.h.

371 {
372 return secant_replay_.size();
373 }

◆ secantReplayTrainingRows()

std::size_t gpr::neb::ActiveLearningSession::secantReplayTrainingRows ( ) const
inlinenodiscardnoexcept

Replay samples that record an admitted training row.

Definition at line 376 of file Session.h.

377 {
378 std::size_t count = 0;
379 for (const SecantReplaySample& sample: secant_replay_)
380 if (sample.training_row) ++count;
381 return count;
382 }

◆ selectArchivedNeighbors()

std::vector< uint64_t > gpr::neb::ActiveLearningSession::selectArchivedNeighbors ( const std::vector< int > & kept,
const Eigen::VectorXd * image_position,
Eigen::Index D )
inlinenodiscard

Archived-row candidates for one image: rows in the corpus that no longer coincide with any active training row and whose EMD to the image position is within the admission radius (the image's farthest kept training row; unbounded while no rows are kept). At most ~per_image_knn~ rows, nearest first.

Definition at line 2188 of file Session.h.

2191 {
2192 std::vector<uint64_t> archived;
2193#ifdef USE_READCON_DB
2194 if (!observation_archive_ || !image_position ||
2195 image_position->size() != D || D <= 0) {
2196 return archived;
2197 }
2198 refreshArchivePool();
2199 if (archive_pool_.empty()) return archived;
2200
2201 aux::Distance distance;
2202 gpr::Coord query(1, D);
2203 for (Eigen::Index c = 0; c < D; ++c) {
2204 query(0, c) = (*image_position)(c);
2205 }
2206
2207 double radius = std::numeric_limits<double>::infinity();
2208 if (!kept.empty()) {
2209 gpr::Coord kept_r(static_cast<Eigen::Index>(kept.size()), D);
2210 for (Eigen::Index r = 0; r < static_cast<Eigen::Index>(kept.size());
2211 ++r) {
2212 kept_r.row(r) =
2213 training_obs.R.row(kept[static_cast<size_t>(r)]);
2214 }
2215 gpr::FieldMatrixd kept_dist;
2216 distance.dist_emd(query, kept_r, atoms_config, kept_dist);
2217 radius = kept_dist.maxCoeff();
2218 }
2219
2220 gpr::Coord pool_r(static_cast<Eigen::Index>(archive_pool_.size()), D);
2221 for (Eigen::Index r = 0;
2222 r < static_cast<Eigen::Index>(archive_pool_.size()); ++r) {
2223 if (archive_pool_[static_cast<size_t>(r)].positions.size() != D) {
2224 return archived; // composition mismatch: archive unusable
2225 }
2226 pool_r.row(r) =
2227 archive_pool_[static_cast<size_t>(r)].positions.transpose();
2228 }
2229 gpr::FieldMatrixd pool_dist;
2230 distance.dist_emd(query, pool_r, atoms_config, pool_dist);
2231
2232 std::vector<uint64_t> order(archive_pool_.size());
2233 for (size_t k = 0; k < order.size(); ++k)
2234 order[k] = k;
2235 std::sort(order.begin(), order.end(), [&](uint64_t a, uint64_t b) {
2236 return pool_dist(static_cast<Eigen::Index>(a)) <
2237 pool_dist(static_cast<Eigen::Index>(b));
2238 });
2239
2240 const int n_train = static_cast<int>(training_obs.R.rows());
2241 for (const uint64_t k: order) {
2242 if (static_cast<int>(archived.size()) >= per_image_knn) break;
2243 const double d = pool_dist(static_cast<Eigen::Index>(k));
2244 if (!std::isfinite(d) || d > radius) break;
2245 const Eigen::VectorXd& pos =
2246 archive_pool_[static_cast<size_t>(k)].positions;
2247 bool active = false;
2248 for (int src = 0; src < n_train; ++src) {
2249 const Eigen::VectorXd row = training_obs.R.row(src).transpose();
2250 if (detail::positionsCoincide(pos, row)) {
2251 active = true;
2252 break;
2253 }
2254 }
2255 if (active) continue;
2256 bool dup = false;
2257 for (const uint64_t chosen: archived) {
2258 if (detail::positionsCoincide(
2259 pos,
2260 archive_pool_[static_cast<size_t>(chosen)].positions)) {
2261 dup = true;
2262 break;
2263 }
2264 }
2265 if (!dup) archived.push_back(k);
2266 }
2267 std::sort(archived.begin(), archived.end());
2268#else
2269 (void)kept;
2270 (void)image_position;
2271 (void)D;
2272#endif
2273 return archived;
2274 }

◆ selectMmfModelOwner()

int gpr::neb::ActiveLearningSession::selectMmfModelOwner ( bool dimer_use_global_gp,
bool image_model_eligible,
int image_idx )
inlinestaticnodiscard

Definition at line 235 of file Session.h.

238 {
239 return !dimer_use_global_gp && image_model_eligible && image_idx >= 0
240 ? image_idx
241 : -1;
242 }

◆ setAfterInitialise()

void gpr::neb::ActiveLearningSession::setAfterInitialise ( AfterInitialise hook)
inline

Runs from applySeededModel(), after the search profile and the pair cutoff are on the GP. A warm start installs saved hyperparameters here.

Definition at line 1282 of file Session.h.

1283 {
1284 after_initialise_ = std::move(hook);
1285 }

◆ setBandGeodesicReferencePath()

bool gpr::neb::ActiveLearningSession::setBandGeodesicReferencePath ( const gpr::Coord & reference_path)
inline

Supply the GLOBAL GP with a band reference path for the soft geodesic heat prior, without touching per-image local models. The additive amplitude is evidence-fitted at each ~refitGP~ (a zero optimum retains the base covariance; see docs/orgmode/explanation/theory/soft_geodesic_heat_kernel.org and scripts/derive_soft_geodesic_energy_force_gp.py).

Definition at line 2392 of file Session.h.

2393 {
2394 if (gp.atomicEnvironmentModelEnabled()) return false;
2395 if (reference_path.rows() <= 0 || reference_path.cols() <= 0 ||
2396 !reference_path.allFinite()) {
2397 return false;
2398 }
2399 if (atoms_config.positions.cols() > 0 &&
2400 reference_path.cols() != atoms_config.positions.cols()) {
2401 return false;
2402 }
2403 setGlobalGeodesicReferencePath(reference_path);
2404 return true;
2405 }

◆ setEndpointSymmetry()

void gpr::neb::ActiveLearningSession::setEndpointSymmetry ( EndpointSymmetry symmetry)
inline

Exchange symmetry of the band's endpoints. While it is set, every admitted oracle row also enters at its symmetry image, which is an exact observation of the same potential (see ~EndpointSymmetry~). The image is not an acquisition: it never reaches the observation archive, and an archived row regenerates it on adoption. Rows already in the training set enter at their images when it is set, unless the image is already a row. An empty symmetry clears it.

Definition at line 1601 of file Session.h.

1602 {
1603 endpoint_symmetry_ = std::move(symmetry);
1604 if (endpoint_symmetry_.empty()) return;
1605 const Eigen::Index measured = training_obs.R.rows();
1606 for (Eigen::Index r = 0; r < measured; ++r) {
1607 const Eigen::VectorXd x = training_obs.R.row(r).transpose();
1608 const int existing = detail::findPositionRow(
1609 training_obs, endpoint_symmetry_.mapPositions(x));
1610 if (existing >= 0 && existing != static_cast<int>(r)) continue;
1611 appendSymmetryImage(static_cast<int>(r), x, training_obs.E(r, 0),
1612 training_obs.G.row(r).transpose());
1613 }
1614 }
@ x
Definition Enums.h:28
Half measured(const GradientOracle &oracle, const Eigen::VectorXd &x, Kind kind, const Options &options)
Full central difference of the oracle gradient: 2 d calls.

◆ setEvidenceRefitTrigger()

void gpr::neb::ActiveLearningSession::setEvidenceRefitTrigger ( bool enabled)
inlinenoexcept

Switch the refit decision of ~conditionGPOnConsistentRows~ from the force-resolution test to the accumulated contradiction evidence.

Definition at line 3453 of file Session.h.

3454 {
3455 evidence_refit_trigger_ = enabled;
3456 }

◆ setGlobalInternalCoordinateChart()

bool gpr::neb::ActiveLearningSession::setGlobalInternalCoordinateChart ( std::shared_ptr< const gpr::geometry::InternalCoordinateChart > chart)
inline

Anchor the GLOBAL Sexpat energy-force tensor on a nonredundant molecular tangent chart. The isotropic intrinsic length is matched to the current global force variance. A missing metric or an invalid chart leaves Cartesian Sexpat in place; a heat prior composes with it.

Definition at line 2316 of file Session.h.

2318 {
2319 if (!chart || !chart->valid()) {
2321 return false;
2322 }
2323 if (global_internal_coordinate_chart_ == chart &&
2324 gp.getSexpAtCovarianceFunction().manifoldChart() == chart) {
2325 return true;
2326 }
2327 const std::optional<double> length_scale =
2328 gp.inferInternalCoordinateLengthScale(*chart);
2329 if (!length_scale) {
2331 return false;
2332 }
2333 kernel_requires_refit_ = true;
2334 global_internal_coordinate_chart_ = std::move(chart);
2335 global_internal_coordinate_length_scale_ = *length_scale;
2336 parkActiveModelBeforeSwitch(-1);
2337 gp.setInternalCoordinateChart(global_internal_coordinate_chart_,
2338 global_internal_coordinate_length_scale_);
2339 if (training_obs.R.rows() > 0) {
2340 materializeWithNoiseFloor(gp, training_obs,
2341 likelihoodNoiseFloorSigma2());
2342 conditioned_training_revision_ = training_revision_;
2343 }
2344 ++global_surrogate_revision_;
2345 markActiveModel(-1);
2346 return true;
2347 }

◆ setImageGeodesicReferencePath()

bool gpr::neb::ActiveLearningSession::setImageGeodesicReferencePath ( int i,
const gpr::Coord & reference_path )
inline

Supply image ~i~'s local GP with the live whole-band geometry used to construct its soft geodesic heat covariance. The path amplitude is fitted from this image's joint energy-gradient observations at refit.

Definition at line 2410 of file Session.h.

2411 {
2412 if (gp.atomicEnvironmentModelEnabled()) return false;
2413 if (i < 0 || i >= static_cast<int>(image_models.size()) ||
2414 reference_path.rows() <= 0 || reference_path.cols() <= 0 ||
2415 !reference_path.allFinite()) {
2416 return false;
2417 }
2418 if (atoms_config.positions.cols() > 0 &&
2419 reference_path.cols() != atoms_config.positions.cols()) {
2420 return false;
2421 }
2422 setGlobalGeodesicReferencePath(reference_path);
2423 image_models[i].setGeodesicReferencePath(reference_path);
2424 return true;
2425 }

◆ setImageInternalCoordinateChart()

bool gpr::neb::ActiveLearningSession::setImageInternalCoordinateChart ( int i,
std::shared_ptr< const gpr::geometry::InternalCoordinateChart > chart )
inline

Anchor image ~i~'s local GP to a nonredundant molecular tangent chart. The intrinsic scalar length is inherited by matching the fitted global GP's tangent force variance. An unavailable global metric clears a stale chart and leaves prediction on the ordinary global fallback.

Definition at line 2294 of file Session.h.

2297 {
2298 if (i < 0 || i >= static_cast<int>(image_models.size()) || !chart) {
2299 return false;
2300 }
2301 const std::optional<double> length_scale =
2302 gp.inferInternalCoordinateLengthScale(*chart);
2303 if (!length_scale) {
2304 image_models[i].clearInternalCoordinateChart();
2305 return false;
2306 }
2307 image_models[i].setInternalCoordinateChart(std::move(chart),
2308 *length_scale);
2309 return true;
2310 }

◆ setImageNeighborhood()

void gpr::neb::ActiveLearningSession::setImageNeighborhood ( int i,
const std::vector< int > & emd_indices,
const Eigen::VectorXd * image_position = nullptr )
inline

Rebuild image ~i~'s local training set as the trajectory-aware union of two index sets over the global ~training_obs~:

  • ~emd_indices~ :: the EMD k-nearest observations to image ~i~'s current position. Tracks the moving chain so an image picks up its neighbours' oracle calls.
  • ~model.directIndices()~ :: every row image ~i~ was oracled at directly – its own search / climb trajectory.

The EMD set alone is a recent spatial cluster: for a climbing image it is the last few uphill steps, and a GP fit on that extrapolates the ascent without bound. Unioning the image's own oracle history keeps the trajectory that bounds the climb. Recomputed every outer iteration; a no-op when the union already matches the slot's selection, otherwise the row set changed and the cached per-image factor is invalidated so the next predict refits. image_position, when given, additionally re-selects archived rows: acquisitions the global pruner removed from ~training_obs~ but which sit EMD-nearer to this image than its farthest kept training row come back from the readcon-db corpus. The double-GP sets are disjoint views; the archive is what makes that divergence non-destructive.

Definition at line 2110 of file Session.h.

2112 {
2113 if (i < 0 || i >= static_cast<int>(image_models.size())) return;
2114 ImageModel& model = image_models[i];
2115
2116 const int n_train = static_cast<int>(training_obs.R.rows());
2117 std::vector<int> indices;
2118 indices.reserve(emd_indices.size() + model.directIndices().size());
2119 for (int src: emd_indices) {
2120 if (src >= 0 && src < n_train) indices.push_back(src);
2121 }
2122 for (int src: model.directIndices()) {
2123 if (src >= 0 && src < n_train) indices.push_back(src);
2124 }
2125 std::sort(indices.begin(), indices.end());
2126 indices.erase(std::unique(indices.begin(), indices.end()),
2127 indices.end());
2128
2129 // Position-dedup: distinct global rows can still sit at the
2130 // same configuration (a dimer burst re-oracling a stored stop
2131 // point). Keep one row per distinct geometry so the per-image
2132 // covariance stays full rank.
2133 const Eigen::Index D = training_obs.R.cols();
2134 std::vector<int> kept;
2135 kept.reserve(indices.size());
2136 for (int src: indices) {
2137 const Eigen::VectorXd pos = training_obs.R.row(src).transpose();
2138 bool dup = false;
2139 for (int k: kept) {
2140 const Eigen::VectorXd kpos = training_obs.R.row(k).transpose();
2141 if (detail::positionsCoincide(pos, kpos)) {
2142 dup = true;
2143 break;
2144 }
2145 }
2146 if (!dup) kept.push_back(src);
2147 }
2148
2149 const std::vector<uint64_t> archived =
2150 selectArchivedNeighbors(kept, image_position, D);
2151
2152 if (model.selectedIndices() == kept &&
2153 model.archivedKeys() == archived) {
2154 return;
2155 }
2156
2157 const Eigen::Index n_sel = static_cast<Eigen::Index>(kept.size());
2158 const Eigen::Index n_arch = static_cast<Eigen::Index>(archived.size());
2159 gpr::Observation neigh;
2160 if (n_sel + n_arch > 0 && D > 0) {
2161 neigh.R.resize(n_sel + n_arch, D);
2162 neigh.E.resize(n_sel + n_arch, 1);
2163 neigh.G.resize(n_sel + n_arch, D);
2164 for (Eigen::Index r = 0; r < n_sel; ++r) {
2165 const int src = kept[static_cast<size_t>(r)];
2166 neigh.R.row(r) = training_obs.R.row(src);
2167 neigh.E(r, 0) = training_obs.E(src, 0);
2168 neigh.G.row(r) = training_obs.G.row(src);
2169 }
2170#ifdef USE_READCON_DB
2171 for (Eigen::Index r = 0; r < n_arch; ++r) {
2172 const auto& row = archive_pool_[static_cast<size_t>(
2173 archived[static_cast<size_t>(r)])];
2174 neigh.R.row(n_sel + r) = row.positions.transpose();
2175 neigh.E(n_sel + r, 0) = row.energy;
2176 neigh.G.row(n_sel + r) = row.gradient.transpose();
2177 }
2178#endif
2179 }
2180 model.replaceNeighborhood(std::move(neigh), std::move(kept), archived);
2181 }
FieldMatrixd E
std::vector< uint64_t > selectArchivedNeighbors(const std::vector< int > &kept, const Eigen::VectorXd *image_position, Eigen::Index D)
Definition Session.h:2188

◆ setLikelihoodNoiseFloorRms()

void gpr::neb::ActiveLearningSession::setLikelihoodNoiseFloorRms ( const double * noise_rms)
inlinenoexcept

Set a live RMS floor for the Gaussian likelihood noise. The session squares valid positive values into sigma^2 during ~refitGP~; null, non-finite, and non-positive values disable the floor.

Definition at line 1156 of file Session.h.

1157 {
1158 likelihood_noise_floor_rms_ = noise_rms;
1159 }

◆ setRefitTrainingRevisions()

void gpr::neb::ActiveLearningSession::setRefitTrainingRevisions ( std::uint64_t revisions)
inlinenoexcept

SCG refit cadence: full hyperparameter refits run every this many training-set appends, for every model profile. Default 5 is the Baker-measured value; ActiveGP makes the knob explicit. Zero means refit on every refresh.

Definition at line 1165 of file Session.h.

1166 {
1167 refit_training_revisions_ = revisions;
1168 }

◆ setResolutionDedup()

void gpr::neb::ActiveLearningSession::setResolutionDedup ( bool on)
inlinenoexcept

Admit rows only when they are farther apart than the model can resolve. Off by default: it declines data, and what that costs in acquisitions wants measuring before it is anyone's default.

Definition at line 1636 of file Session.h.

1637 {
1639 }

◆ setSecantHessianConfig()

void gpr::neb::ActiveLearningSession::setSecantHessianConfig ( const optim::SecantHessianConfig & config)
inline

Configure true-gradient secants independently of GP row retention. Changing the method rebuilds the global stream and every per-image stream from the measurements already consumed. Rows retained before any secant existed have no image index, so they enter the global stream only.

Definition at line 253 of file Session.h.

254 {
255 // A BFGS seed carries only positive curvature and could replace the
256 // negative mode required by the session's subsequent saddle search.
257 if (config.seed_curvature &&
258 config.method == optim::SecantHessianMethod::BFGS)
259 throw std::invalid_argument(
260 "saddle secant curvature seed does not support the BFGS "
261 "method");
262 std::vector<SecantReplaySample> replay;
263 replay.swap(secant_replay_);
264 secant_config_ = config;
265 global_secant_ = optim::SecantHessian(config.method);
266 image_secants_.clear();
267 secant_force_samples_.clear();
268 secant_counts_ = {};
269 secant_pairs_checked_ = 0;
270 if (!config.quadratic_prior_mean) gp.clearSecantQuadraticPrior();
271 // Keep the log while the features are off so a later enable can
272 // restore the per-image warm-start seeds.
273 if (!config.enabled()) {
274 secant_replay_.swap(replay);
275 return;
276 }
277 if (!replay.empty()) {
278 for (const SecantReplaySample& sample: replay)
279 observeSecant(sample.image_idx, sample.position,
280 sample.gradient, sample.energy, sample.accounting,
281 sample.training_row);
282 return;
283 }
284 for (Eigen::Index row = 0; row < training_obs.R.rows(); ++row) {
285 if (row >= training_obs.E.rows() || training_obs.E.cols() < 1 ||
286 row >= training_obs.G.rows() ||
287 training_obs.G.cols() != training_obs.R.cols())
288 throw std::logic_error(
289 "secant replay is missing a retained true force");
290 observeSecant(-1, training_obs.R.row(row).transpose(),
291 training_obs.G.row(row).transpose(),
292 training_obs.E(row, 0),
294 }
295 }

◆ sharedParameterState()

SharedParameterState gpr::neb::ActiveLearningSession::sharedParameterState ( ) const
inlinenodiscard

Definition at line 999 of file Session.h.

1000 {
1001 if (!initialised) return {};
1002 return {gp.lengthScaleFitState(),
1003 gp.outputMean(),
1004 gp.outputScale(),
1005 gp.likelihoodNoiseVariance(),
1006 gp.getConstantCovarianceFunction().getConstSigma2(),
1007 gp.outputMeanFrozen(),
1008 gp.getUncertaintyMode(),
1009 integratesHyperparameters(gp) ? training_revision_ : 0,
1010 gp.atomicEnvironmentModelEnabled() ? gp.factorEpoch() : 0};
1011 }
static bool integratesHyperparameters(const gpr::GaussianProcessRegression &model)
Definition Session.h:1013

◆ sharesGlobalHyperparameters()

bool gpr::neb::ActiveLearningSession::sharesGlobalHyperparameters ( const gpr::GaussianProcessRegression & model) const
inlinenodiscard

Definition at line 1021 of file Session.h.

1023 {
1024 return integratesHyperparameters(gp) &&
1026 !gp.getSexpAtCovarianceFunction().usesManifoldChart() &&
1028 }
bool usesManifoldChart() const noexcept
Definition SexpatCF.h:616

◆ surfaceEpoch()

std::uint64_t gpr::neb::ActiveLearningSession::surfaceEpoch ( ) const
inlinenodiscardnoexcept

Monotone surface epoch. Bumps when the factorized posterior changes (refit or materialize). Mix into a consumer cache key so a frozen GprMeanPotential cannot relax on a stale PES.

Definition at line 1177 of file Session.h.

1178 {
1179 return gp.factorEpoch();
1180 }

◆ surrogateFingerprint()

SurrogateFingerprint gpr::neb::ActiveLearningSession::surrogateFingerprint ( int owner) const
inlinenodiscard

Definition at line 1070 of file Session.h.

1071 {
1072 if (!gp.atomicEnvironmentModelEnabled() && owner >= 0 &&
1073 owner < static_cast<int>(image_models.size())) {
1075 owner, imageModelSurrogateRevision(owner));
1076 }
1078 }
static SurrogateFingerprint global(std::uint64_t revision)
Definition Session.h:211
static SurrogateFingerprint image(int image_idx, std::uint64_t revision)
Definition Session.h:216
std::uint64_t imageModelSurrogateRevision(int image_idx) const
Definition Session.h:1030
std::uint64_t globalModelSurrogateRevision() const
Definition Session.h:1048

◆ symmetryRowsAdmitted()

long gpr::neb::ActiveLearningSession::symmetryRowsAdmitted ( ) const
inlinenodiscardnoexcept

Symmetry-image rows admitted, and those refused because a training row already lay within the model's resolution of the image, or within the operation's own (~EndpointSymmetry::resolution~).

Definition at line 1624 of file Session.h.

1625 {
1627 }

◆ symmetryRowsRejected()

long gpr::neb::ActiveLearningSession::symmetryRowsRejected ( ) const
inlinenodiscardnoexcept

Definition at line 1628 of file Session.h.

1629 {
1631 }

◆ syncTrainingMultiplicity()

void gpr::neb::ActiveLearningSession::syncTrainingMultiplicity ( )
inline

Keep ~training_multiplicity~ aligned with ~training_obs~: new rows enter with multiplicity one, suffix truncation drops the tail. Interior removals are handled at their removal site.

Definition at line 1753 of file Session.h.

1754 {
1755 training_multiplicity.resize(static_cast<size_t>(training_obs.R.rows()),
1756 1);
1757 }

◆ syncVirtualNoiseTag()

void gpr::neb::ActiveLearningSession::syncVirtualNoiseTag ( )
inline

Push the current virtual-geometry set and its noise into the likelihood so every subsequent covariance assembly tags the matching rows. Real-only assemblies contain no matching geometry and stay bit-identical.

Definition at line 1913 of file Session.h.

1914 {
1915 gp.getLikGaussian().setVirtualGeometryNoise(virtual_obs.R,
1917 }

◆ trainingRevision()

std::uint64_t gpr::neb::ActiveLearningSession::trainingRevision ( ) const
inlinenodiscardnoexcept

Definition at line 1043 of file Session.h.

1044 {
1045 return training_revision_;
1046 }

◆ updateFrozenEnvironment()

bool gpr::neb::ActiveLearningSession::updateFrozenEnvironment ( const gpr::Coord & band)
inline

Select one frozen environment over every image, retaining physical observations and invalidating models that depend on its pair features.

Definition at line 1335 of file Session.h.

1336 {
1337 if (!initialised) initialise();
1338 if (!initialised || (atoms_config.atoms_froz_active.type.size() == 0 &&
1339 atoms_config.atoms_froz_inactive.type.size() == 0))
1340 return false;
1341 auto selected = atoms_config;
1342 aux::ProblemSetUp setup;
1343 const bool active_set_changed = setup.activateFrozenAtoms(
1344 band, input_parameters.actdist_fro.value, selected);
1345 // Selection also removes inactive clones of moving atoms. That
1346 // bookkeeping change does not alter GP features, but it must persist
1347 // so the clone cannot re-enter a later nearest-neighbour selection.
1348 atoms_config = std::move(selected);
1349 if (!active_set_changed) return false;
1350 parkActiveModelBeforeSwitch(-1);
1351 gp.updateConfiguration(atoms_config);
1352 for (auto& model: image_models)
1353 model.updateConfiguration(atoms_config);
1354 gp_model_ready_ = false;
1355 kernel_requires_refit_ = true;
1356 ++global_surrogate_revision_;
1357 markActiveModel(-1);
1358 return true;
1359 }
bool activateFrozenAtoms(const gpr::Coord &R, const double activation_distance, gpr::AtomsConfiguration &atoms_config)
Update the active frozen-atom set for one or more configurations.
eon_relax_band_t * band

◆ withImageChartFallback()

template<typename Use>
void gpr::neb::ActiveLearningSession::withImageChartFallback ( int i,
Use && use )
inline

Run ~use~ on image ~i~'s model, or on the global model when the image has too few rows of its own. A chart is built from the primitives that are defined along the path when it is attached; a training row or a probe that puts three atoms of a dihedral on a line leaves that primitive undefined, and the chart no longer describes the region the model covers. The image then drops its chart and the call runs again on the Cartesian pair kernel. Only an undefined primitive is recovered; any other error, and any error on an image without a chart, passes on unchanged.

Definition at line 2836 of file Session.h.

2837 {
2839 withImageModel(i, std::forward<Use>(use));
2840 return;
2841 }
2842 auto model = acquireGlobalModel();
2843 use(model.gp());
2844 }
void withImageModel(int i, Use &&use)
Definition Session.h:2849

◆ withImageModel()

template<typename Use>
void gpr::neb::ActiveLearningSession::withImageModel ( int i,
Use && use )
inline

Run ~use~ on image ~i~'s model, dropping a chart that is undefined at a row or probe and running again on the Cartesian pair kernel.

Definition at line 2849 of file Session.h.

2850 {
2851 try {
2852 auto model = acquireImageModel(i);
2853 use(model.gp());
2854 return;
2855 } catch (const gpr::geometry::UndefinedInternalCoordinate&) {
2856 if (!image_models[i].internalCoordinateChart()) throw;
2857 image_models[i].clearInternalCoordinateChart();
2858 }
2859 auto model = acquireImageModel(i);
2860 use(model.gp());
2861 }
ModelLease acquireImageModel(int i)
Definition Session.h:2792

◆ withinTrainingResolution()

bool gpr::neb::ActiveLearningSession::withinTrainingResolution ( const Eigen::VectorXd & positions) const
inlinenodiscard

True when ~appendObservation~ would refuse a row at positions under the resolution gate: a training row already lies closer than the model's own resolution floor, so a measurement there is informationless and the posterior at positions is the data. Certificates that demand "current oracle data" at an image must accept this state as observed, or they wait forever for a row the session will never store.

Definition at line 1648 of file Session.h.

1650 {
1651 if (!resolution_dedup_enabled_ || training_obs.R.rows() == 0) {
1652 return false;
1653 }
1654 const double floor_d = observationResolutionFloor();
1655 return floor_d > 0.0 && nearestTrainingDistance(positions) < floor_d;
1656 }

◆ wouldRefitAtNextRefresh()

bool gpr::neb::ActiveLearningSession::wouldRefitAtNextRefresh ( ) const
inlinenodiscardnoexcept

True when the next ~refreshCovarianceCache~ would run a full hyperparameter refit rather than a fixed-theta rematerialize.

Pruning is only free at such a point. A refit rebuilds the factorization from scratch anyway, so dropping rows costs nothing extra there; dropping them between refits instead turns the next rematerialize from a suffix append into a full O(n^3) rebuild, because the training matrix is no longer an extension of the one the cached factor was built on.

Definition at line 3317 of file Session.h.

3318 {
3319 if (!initialised || training_obs.R.rows() == 0) return false;
3320 if (!hyperparametersNeedRefit()) return false;
3321 if (kernel_requires_refit_) return true;
3322 const bool never_fitted = fitted_training_revision_ ==
3323 std::numeric_limits<std::uint64_t>::max();
3324 if (never_fitted) return true;
3325 const std::uint64_t growth =
3326 training_revision_ - fitted_training_revision_;
3327 return growth >= refit_training_revisions_;
3328 }

Member Data Documentation

◆ atoms_config

gpr::AtomsConfiguration gpr::neb::ActiveLearningSession::atoms_config

Atoms configuration cached from ~gp_setup~. Required by ~setHyperparameters~ and the EMD distance metric.

Definition at line 1129 of file Session.h.

◆ ci_active_at_outer_start

bool gpr::neb::ActiveLearningSession::ci_active_at_outer_start = false

CI already active when the current GP-NEB outer began. OCINEB uses this so force-only Helped after same-outer CI activation restores the pre-burst geometry instead of locking a high false TS.

Definition at line 440 of file Session.h.

◆ ci_stable_outer_count

int gpr::neb::ActiveLearningSession::ci_stable_outer_count = 0

Consecutive outers that began with CI active. Force-only Helped restores unless this is >= 1 (CI already active at outer start) and the converged mode has negative curvature.

Definition at line 444 of file Session.h.

◆ current_chain_certificates

std::vector<IndexedObservation> gpr::neb::ActiveLearningSession::current_chain_certificates

Per-image true-PES evidence at a live chain geometry. Certificates own their exact energy and gradient independently of the GP training transaction, so model rollback cannot erase convergence evidence.

Definition at line 466 of file Session.h.

◆ endpoint_symmetry_

EndpointSymmetry gpr::neb::ActiveLearningSession::endpoint_symmetry_

Definition at line 1665 of file Session.h.

◆ gp

gpr::GaussianProcessRegression gpr::neb::ActiveLearningSession::gp

Global GP instance. Initialised lazily via ~initialise()~ from ~gp_setup~. Owns hyperparameter optimisation and the dense distributed Cholesky used for chain-wide variance probes.

Definition at line 471 of file Session.h.

◆ gp_setup

std::function<void(gpr::InputParameters&, gpr::AtomsConfiguration&)> gpr::neb::ActiveLearningSession::gp_setup

Callback that builds the (parameters, atoms_config) pair the GP needs to ~initialize()~. Same shape as ~GPNEBConfig::gp_setup~. Populated by the caller (typically from a loaded ~.con~ frame).

Definition at line 1141 of file Session.h.

◆ image_models

std::vector<ImageModel> gpr::neb::ActiveLearningSession::image_models

Per-image local GPs. One slot per path image; endpoints are present for index alignment but are only used when explicitly sampled.

Definition at line 997 of file Session.h.

◆ initialised

bool gpr::neb::ActiveLearningSession::initialised = false

True once ~initialise()~ has populated ~gp~ + ~atoms_config~ from ~gp_setup~. Idempotent across calls.

Definition at line 1150 of file Session.h.

◆ input_parameters

gpr::InputParameters gpr::neb::ActiveLearningSession::input_parameters

Input parameters cached from ~gp_setup~. Per-image local GPs are clones of the global setup and do not re-enter the caller's setup callback.

Definition at line 1134 of file Session.h.

◆ last_max_chain_energy_variance

double gpr::neb::ActiveLearningSession::last_max_chain_energy_variance
Initial value:
=
std::numeric_limits<double>::quiet_NaN()

Latest max per-image chain energy variance from the GP-NEB outer loop's acquisition probe. NaN until the first probe. The OCINEB hook compares it against the likelihood noise floor to decide whether the OIE can still supply admissible information.

Definition at line 460 of file Session.h.

◆ min_per_image_n_train

int gpr::neb::ActiveLearningSession::min_per_image_n_train = 3

Fallback threshold: ~predictAtImage(i, ...)~ routes through the global ~gp~ until image i's geometric neighbourhood has this many distinct oracle observations. Once reached, the local GP takes over for image-resolved predictions.

Definition at line 1104 of file Session.h.

◆ path_energy_ceiling

double gpr::neb::ActiveLearningSession::path_energy_ceiling = std::numeric_limits<double>::infinity()

Optional absolute saddle-energy limit supplied by the caller and shared with the OCINEB burst. Infinity disables it. Sampled path energies do not supply an upper bound on the continuous path maximum.

Definition at line 1146 of file Session.h.

◆ per_image_knn

int gpr::neb::ActiveLearningSession::per_image_knn = 10

Neighbourhood size for the per-image local GP: image i's local training set is the ~per_image_knn~ observations of the global ~training_obs~ nearest (EMD) to image i's current position, recomputed every outer iteration. Keying the local set on geometry rather than on the picker index keeps the per-image surrogate tracking the moving chain: an image picks up its chain neighbours' oracle calls, and a converged image is no longer conditioned on the scattered positions it has left.

Definition at line 1114 of file Session.h.

◆ per_image_prior_s2_log

double gpr::neb::ActiveLearningSession::per_image_prior_s2_log = 0.1

Variance of the hierarchical-Bayes prior on the per-image log-kernel-parameters: ~log(theta_i) ~ N(log(theta_global), per_image_prior_s2_log * I)~. Default 0.1 corresponds to roughly ~30% drift around the global MAP per parameter (in linear lengthscale / magnSigma2). Without this prior, per-image SCG on 3-10 rows is unregularised and drifts to noisy local optima; the resulting inflated per-image variance stalls the NEB acquisition picker in Phase 1. Tighter values pull per-image theta_i closer to the global anchor.

Definition at line 1125 of file Session.h.

◆ resolution_dedup_enabled_

bool gpr::neb::ActiveLearningSession::resolution_dedup_enabled_ = false

Definition at line 1663 of file Session.h.

◆ resolution_dedup_rejected_

long gpr::neb::ActiveLearningSession::resolution_dedup_rejected_ = 0

Definition at line 1664 of file Session.h.

◆ stagnation_handoff

bool gpr::neb::ActiveLearningSession::stagnation_handoff = false

The climbing-image walk has stopped improving while its true force is still above the final tolerance: a curvature-cap limit cycle that the band stall ended, or a fixed point whose granted MMF burst the adaptive bar would otherwise refuse. The next OCINEB hook keeps the flag until the dimer lease is taken, or until the certified handoff declines it. A closed information gate does not clear it. A walk that is still descending does not set it, and the 0.1 eV/A handoff bar is unchanged for that walk.

Definition at line 454 of file Session.h.

◆ symmetry_rows_admitted_

long gpr::neb::ActiveLearningSession::symmetry_rows_admitted_ = 0

Definition at line 1666 of file Session.h.

◆ symmetry_rows_rejected_

long gpr::neb::ActiveLearningSession::symmetry_rows_rejected_ = 0

Definition at line 1667 of file Session.h.

◆ training_multiplicity

std::vector<int> gpr::neb::ActiveLearningSession::training_multiplicity

Repeated-observation count per training row (>= 1), aligned with ~training_obs~ rows.

Definition at line 1848 of file Session.h.

◆ training_obs

gpr::Observation gpr::neb::ActiveLearningSession::training_obs

Growing training data. Appended by every oracle call from every phase (NEB explore, NEB CI, Dimer MMF).

Definition at line 246 of file Session.h.

◆ virtual_obs

gpr::Observation gpr::neb::ActiveLearningSession::virtual_obs

Conditioning-only virtual observations (Riihimaki-Vehtari style conjugate constraints). Each row sits at an internal-trust clip point with targets equal to the prior mean there, so the fitted residual is exactly zero: the posterior is pinned toward the prior at geometries the trust certifier has declared unpredictable. Rows enter covariance conditioning and prediction only – hyperparameter optimisation (SCG) and seed derivation see ~training_obs~ alone, so theta is calibrated against real oracle data. A row retires as soon as a real observation lands within its retire radius.

Definition at line 425 of file Session.h.

◆ virtual_obs_noise_sigma2

double gpr::neb::ActiveLearningSession::virtual_obs_noise_sigma2 = 0.04

Extra heteroscedastic noise sigma^2 on virtual rows (energy in eV^2, forces in (eV/A)^2 under the raw-target classic stack). Soft pins: large against the learned data noise (~1e-3) so a pin biases the posterior toward the prior without forcing an interpolation constraint through it; hard pins bend the posterior violently between nearby data and the pin (measured: max_gp_F 27 -> 175 on 17_claisen when pinned at shared noise).

Definition at line 435 of file Session.h.

◆ virtual_retire_radii

std::vector<double> gpr::neb::ActiveLearningSession::virtual_retire_radii

Per-row coordinate-norm retire radii, aligned with ~virtual_obs~.

Definition at line 427 of file Session.h.


The documentation for this struct was generated from the following file: