Loading...
Searching...
No Matches
gpr::neb::oie Namespace Reference

Classes

struct  TpePickResult
 Result of a TPE acquisition pick over the interior band. More...
class  AcquisitionPolicy
 OIE acquisition over the currently informative band images. More...

Enumerations

enum class  TpeObjective { ForceAccuracy = 0 , SaddleIdentity }

Functions

double ucbBeta (int outer_iter, int n_candidates)
 GP-UCB exploration schedule sqrt(beta_t), Srinivas et al. 2010.
const char * tpeObjectiveName (TpeObjective objective) noexcept
const char * tpeObjectiveLogName (bool evaluated, TpeObjective objective) noexcept
TpeObjective tpeObjectiveForSaddleState (bool ci_active, bool candidate_confident, bool chain_certificate_met) noexcept
double gaussianExceedanceProbability (double reference_mean, double reference_variance, double challenger_mean, double challenger_variance)
 Probability that a Gaussian challenger equals or exceeds a Gaussian reference under the independent-marginal difference approximation.
bool saddleExists (const std::vector< double > &energies)
 Strict interior maximum above BOTH endpoints (no single-hump assumption: any interior image above max(E0, E_last) qualifies).
bool confidenceMet (const std::vector< double > &energies, const std::vector< double > &posterior_energy_variance, int outer_iter)
 Global-confidence gate without a magic threshold.
std::vector< double > oieUtility (const std::vector< double > &energies, const std::vector< double > &posterior_energy_variance, const std::vector< double > &force_norm, const std::vector< double > &force_variance, int outer_iter, bool confident)
 Per-interior-image standardized OIE utility (the TPE objective).
std::vector< double > saddleIdentityUtility (const std::vector< double > &energies, const std::vector< double > &posterior_energy_variance)
 Per-image value of information for resolving the interior argmax.
int tpePick (const std::vector< double > &interior_utility)
 TPE acquisition over the DISCRETE interior-image index axis.
TpePickResult selectTpeOracleTarget (const std::vector< double > &energies, const std::vector< double > &posterior_energy_variance, const std::vector< double > &force_norm, const std::vector< double > &force_variance, int outer_iter)
 Full OIE target decision with the strict-saddle CI constraint and every interior image eligible.
Eigen::VectorXd drawPosteriorObservationSample (const Eigen::VectorXd &posterior_mean, const Eigen::MatrixXd &posterior_covariance, std::uint64_t seed=0)
 Draw one joint posterior realization for action-level PS-BAX.

Enumeration Type Documentation

◆ TpeObjective

enum class gpr::neb::oie::TpeObjective
strong
Enumerator
ForceAccuracy 
SaddleIdentity 

Definition at line 38 of file AcquisitionPolicy.h.

Function Documentation

◆ confidenceMet()

bool gpr::neb::oie::confidenceMet ( const std::vector< double > & energies,
const std::vector< double > & posterior_energy_variance,
int outer_iter )

Global-confidence gate without a magic threshold.

The band is confident when the worst-case UCB half-width on the energies, beta_t * max interior std, has shrunk below the saddle PROMINENCE (interior max above the higher endpoint): posterior uncertainty no longer reaches across the barrier being resolved. The prominence, not the whole span, is the yardstick – the span includes the reaction energy, which on an exothermic band dwarfs the barrier and fires confidence before the saddle is resolved. beta_t is the GP-UCB schedule; the prominence is data. Confidence implies saddleExists (prominence > 0).

Parameters
energiesWhole-band energies [0 .. n_images-1].
posterior_energy_varianceWhole-band posterior energy variance.
outer_iterOuter iteration t (1-based for the schedule).

Definition at line 271 of file AcquisitionPolicy.cpp.

274{
275 const std::vector<double> ivar = interiorOf(posterior_energy_variance);
276 if (ivar.empty()) return false;
277 double max_std = 0.0;
278 for (double v: ivar)
279 max_std = std::max(max_std, std::sqrt(std::max(v, 0.0)));
280 const double beta = ucbBeta(outer_iter, static_cast<int>(ivar.size()));
281 const std::vector<double> ienergy = interiorOf(energies);
282 if (ienergy.empty()) return false;
283 // Yardstick: the saddle PROMINENCE (interior max above the higher
284 // endpoint), not the whole-band span. The span includes the reaction
285 // energy, so on an exothermic band the GP resolves the downhill shape
286 // long before the barrier top and confidence fires prematurely --
287 // pinning CI exploitation on a noise-level bump. Prominence is the
288 // margin of the exact hypothesis this gate authorizes exploiting
289 // (a resolved interior saddle): beta_t * max_std <= prominence also
290 // implies prominence > 0, i.e. saddleExists.
291 const double imax = *std::max_element(ienergy.begin(), ienergy.end());
292 const double prominence =
293 imax - std::max(energies.front(), energies.back());
294 if (!(prominence > 0.0)) return false;
295 return beta * max_std <= prominence;
296}
double ucbBeta(int outer_iter, int n_candidates)
GP-UCB exploration schedule sqrt(beta_t), Srinivas et al. 2010.

◆ drawPosteriorObservationSample()

Eigen::VectorXd gpr::neb::oie::drawPosteriorObservationSample ( const Eigen::VectorXd & posterior_mean,
const Eigen::MatrixXd & posterior_covariance,
std::uint64_t seed = 0 )

Draw one joint posterior realization for action-level PS-BAX.

The mean and covariance use the same channel ordering. A self-adjoint square root supports positive-semidefinite singular covariances. Invalid shapes, non-finite inputs, or a materially indefinite covariance return an empty vector. The draw is deterministic for a fixed seed.

Definition at line 536 of file AcquisitionPolicy.cpp.

539{
540 const Eigen::Index channels = posterior_mean.size();
541 if (channels <= 0 || posterior_covariance.rows() != channels ||
542 posterior_covariance.cols() != channels ||
543 !posterior_mean.allFinite() || !posterior_covariance.allFinite()) {
544 return {};
545 }
546
547 const Eigen::MatrixXd symmetric_covariance =
548 0.5 * (posterior_covariance + posterior_covariance.transpose());
549 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> solver(symmetric_covariance);
550 if (solver.info() != Eigen::Success || !solver.eigenvalues().allFinite() ||
551 !solver.eigenvectors().allFinite()) {
552 return {};
553 }
554
555 const double spectral_scale =
556 std::max(1.0, solver.eigenvalues().cwiseAbs().maxCoeff());
557 const double psd_roundoff =
558 std::sqrt(std::numeric_limits<double>::epsilon()) * spectral_scale;
559 if (solver.eigenvalues().minCoeff() < -psd_roundoff) return {};
560
561 const Eigen::VectorXd sqrt_eigenvalues =
562 solver.eigenvalues().cwiseMax(0.0).cwiseSqrt();
563 std::mt19937_64 rng(seed);
564 std::normal_distribution<double> gauss(0.0, 1.0);
565 Eigen::VectorXd standard_normal(channels);
566 for (Eigen::Index channel = 0; channel < channels; ++channel) {
567 standard_normal(channel) = gauss(rng);
568 }
569 return posterior_mean +
570 solver.eigenvectors() *
571 (sqrt_eigenvalues.array() * standard_normal.array()).matrix();
572}
constexpr std::array< Real, 4 > gauss

◆ gaussianExceedanceProbability()

double gpr::neb::oie::gaussianExceedanceProbability ( double reference_mean,
double reference_variance,
double challenger_mean,
double challenger_variance )

Probability that a Gaussian challenger equals or exceeds a Gaussian reference under the independent-marginal difference approximation.

Definition at line 239 of file AcquisitionPolicy.cpp.

243{
244 if (!std::isfinite(reference_mean) || !std::isfinite(challenger_mean) ||
245 !std::isfinite(reference_variance) ||
246 !std::isfinite(challenger_variance) || reference_variance < 0.0 ||
247 challenger_variance < 0.0) {
248 return std::numeric_limits<double>::infinity();
249 }
250 const double difference_variance = reference_variance + challenger_variance;
251 if (!(difference_variance > 0.0)) {
252 if (challenger_mean > reference_mean) return 1.0;
253 if (challenger_mean < reference_mean) return 0.0;
254 return 0.5;
255 }
256 const double z =
257 (reference_mean - challenger_mean) / std::sqrt(difference_variance);
258 return 0.5 * std::erfc(z / std::sqrt(2.0));
259}
@ z
Definition Enums.h:28

◆ oieUtility()

std::vector< double > gpr::neb::oie::oieUtility ( const std::vector< double > & energies,
const std::vector< double > & posterior_energy_variance,
const std::vector< double > & force_norm,
const std::vector< double > & force_variance,
int outer_iter,
bool confident )

Per-interior-image standardized OIE utility (the TPE objective).

Standardizes each channel (energy, force magnitude, VarE, VarF) across the interior images, then combines exploit (energy toward the saddle + residual NEB force accuracy via force posterior variance — not mean force magnitude) and explore (energy variance as PE coupling) weighted by the GP-UCB beta_t schedule. When the band is not yet globally confident the energy-exploit term is dropped so variance reduction dominates (explore-then-exploit ordering).

All inputs are whole-band [0 .. n_images-1]; the returned vector has size n_images-2 (interior only).

Definition at line 298 of file AcquisitionPolicy.cpp.

303{
304 const std::vector<double> e_int = interiorOf(energies);
305 const std::vector<double> ev_int = interiorOf(posterior_energy_variance);
306 const std::vector<double> f_int = interiorOf(force_norm);
307 const std::vector<double> fv_int =
308 force_variance.empty() ? std::vector<double>(e_int.size(), 0.0)
309 : interiorOf(force_variance);
310 const std::size_t m = e_int.size();
311 std::vector<double> util(m, 0.0);
312 if (m == 0) return util;
313
314 const double beta = ucbBeta(outer_iter, static_cast<int>(m));
315 const std::vector<double> z_fv = standardize(fv_int);
316 const std::vector<double> z_f = standardize(f_int);
317 // The acquisition objective is FORCE accuracy alone. It decomposes
318 // (scripts/oie_acquisition_accuracy_derivation.py, SymPy:
319 // E[(F_true - F_gp)^2] = bias(x)^2 + force_var(x)) into a BIAS term,
320 // proxied by the predicted force magnitude |F| (an unrelaxed or
321 // extrapolating GP gradient is exactly what the oracle must correct),
322 // and the gradient posterior VARIANCE. Energy variance never enters:
323 // it carries no information about force-direction error, and mixing
324 // it in let over-confident energy channels outvote a drifting force
325 // model. UCB form: exploit the bias proxy, explore the force
326 // variance (beta_t schedules the TPE good/bad density ratio).
327 (void)ev_int;
328 for (std::size_t i = 0; i < m; ++i) {
329 util[i] = z_f[i] + beta * z_fv[i];
330 }
331 if (confident) {
332 // A confident band maximum exists: weight the saddle locus so the
333 // oracle resolves force accuracy WHERE it decides the barrier.
334 const std::vector<double> z_e = standardize(e_int);
335 for (std::size_t i = 0; i < m; ++i) {
336 util[i] = (z_e[i] + z_f[i]) + beta * z_fv[i];
337 }
338 }
339 return util;
340}

◆ saddleExists()

bool gpr::neb::oie::saddleExists ( const std::vector< double > & energies)

Strict interior maximum above BOTH endpoints (no single-hump assumption: any interior image above max(E0, E_last) qualifies).

Parameters
energiesWhole-band energies, indexed [0 .. n_images-1].

Definition at line 261 of file AcquisitionPolicy.cpp.

262{
263 const std::vector<double> interior = interiorOf(energies);
264 if (interior.empty()) return false;
265 const double imax = *std::max_element(interior.begin(), interior.end());
266 const double e0 = energies.front();
267 const double en = energies.back();
268 return imax > std::max(e0, en);
269}

◆ saddleIdentityUtility()

std::vector< double > gpr::neb::oie::saddleIdentityUtility ( const std::vector< double > & energies,
const std::vector< double > & posterior_energy_variance )

Per-image value of information for resolving the interior argmax.

The current posterior-mean maximum and every challenger share the Gaussian probability that the challenger can change the maximum. Multiplying that probability by the queried image's posterior standard deviation directs measurements to the side of each unresolved comparison that can still reduce saddle-identity risk.

Definition at line 342 of file AcquisitionPolicy.cpp.

345{
346 const std::vector<double> e_int = interiorOf(energies);
347 const std::vector<double> ev_int = interiorOf(posterior_energy_variance);
348 const std::size_t m = e_int.size();
349 std::vector<double> utility(m, 0.0);
350 if (m == 0 || ev_int.size() != m) return utility;
351
352 const auto candidate_it = std::max_element(e_int.begin(), e_int.end());
353 const std::size_t candidate =
354 static_cast<std::size_t>(candidate_it - e_int.begin());
355 const double candidate_std = std::sqrt(std::max(0.0, ev_int[candidate]));
356
357 for (std::size_t i = 0; i < m; ++i) {
358 if (i == candidate) continue;
359 const double probability = gaussianExceedanceProbability(
360 e_int[candidate], ev_int[candidate], e_int[i], ev_int[i]);
361 if (!std::isfinite(probability)) continue;
362 utility[candidate] += probability * candidate_std;
363 utility[i] = probability * std::sqrt(std::max(0.0, ev_int[i]));
364 }
365
366 if (energies.size() == posterior_energy_variance.size() &&
367 energies.size() >= 2) {
368 const std::size_t endpoint_indices[2] = {0, energies.size() - 1};
369 for (const std::size_t endpoint: endpoint_indices) {
370 const double probability = gaussianExceedanceProbability(
371 e_int[candidate], ev_int[candidate], energies[endpoint],
372 posterior_energy_variance[endpoint]);
373 if (std::isfinite(probability)) {
374 utility[candidate] += probability * candidate_std;
375 }
376 }
377 }
378 return utility;
379}
double gaussianExceedanceProbability(double reference_mean, double reference_variance, double challenger_mean, double challenger_variance)
Probability that a Gaussian challenger equals or exceeds a Gaussian reference under the independent-m...

◆ selectTpeOracleTarget()

TpePickResult gpr::neb::oie::selectTpeOracleTarget ( const std::vector< double > & energies,
const std::vector< double > & posterior_energy_variance,
const std::vector< double > & force_norm,
const std::vector< double > & force_variance,
int outer_iter )

Full OIE target decision with the strict-saddle CI constraint and every interior image eligible.

Implements the control flow of the design doc: confident + saddle_exists -> the true interior energy maximum (CI candidate); otherwise the TPE density pick (explore-only utility when not confident, full utility when confident but no saddle).

Inputs are whole-band [0 .. n_images-1]; force_variance may be empty (the explore arm then uses energy variance only).

Definition at line 525 of file AcquisitionPolicy.cpp.

530{
532 energies, posterior_energy_variance, force_norm, force_variance,
533 outer_iter);
534}
OIE acquisition over the currently informative band images.
TpePickResult selectTpeOracleTarget(const std::vector< double > &energies, const std::vector< double > &posterior_energy_variance, const std::vector< double > &force_norm, const std::vector< double > &force_variance, int outer_iter) const

◆ tpeObjectiveForSaddleState()

TpeObjective gpr::neb::oie::tpeObjectiveForSaddleState ( bool ci_active,
bool candidate_confident,
bool chain_certificate_met )
nodiscardnoexcept

Definition at line 230 of file AcquisitionPolicy.cpp.

233{
234 return ci_active && !candidate_confident && chain_certificate_met
237}

◆ tpeObjectiveLogName()

const char * gpr::neb::oie::tpeObjectiveLogName ( bool evaluated,
TpeObjective objective )
nodiscardnoexcept

Definition at line 225 of file AcquisitionPolicy.cpp.

226{
227 return evaluated ? tpeObjectiveName(objective) : "inactive";
228}
const char * tpeObjectiveName(TpeObjective objective) noexcept

◆ tpeObjectiveName()

const char * gpr::neb::oie::tpeObjectiveName ( TpeObjective objective)
nodiscardnoexcept

Definition at line 214 of file AcquisitionPolicy.cpp.

215{
216 switch (objective) {
218 return "force";
220 return "saddle_identity";
221 }
222 return "unknown";
223}

◆ tpePick()

int gpr::neb::oie::tpePick ( const std::vector< double > & interior_utility)

TPE acquisition over the DISCRETE interior-image index axis.

Splits interior indices into "good" (top gamma by utility) and "bad", fits Parzen l(x) on good and g(x) on bad, and returns argmax_x [log l(x) - log g(x)] over the exhaustive interior candidate set (Optuna's _compare specialized to the finite discrete space). Returns the interior index in [0 .. M-1]; map to a full-band index by adding 1.

Definition at line 455 of file AcquisitionPolicy.cpp.

456{
457 return tpePickEligible(interior_utility, {});
458}

◆ ucbBeta()

double gpr::neb::oie::ucbBeta ( int outer_iter,
int n_candidates )

GP-UCB exploration schedule sqrt(beta_t), Srinivas et al. 2010.

beta_t = 2 log(cardinality(D) t^2 pi^2 / (6 delta)), delta = 1/t, for a finite decision set D at outer iteration t. Returns sqrt(beta_t). Self-scaling: grows with iteration and band size, no hand-set kappa.

Definition at line 203 of file AcquisitionPolicy.cpp.

204{
205 const int t = std::max(outer_iter, 1);
206 const double delta = 1.0 / static_cast<double>(t);
207 const double nd = static_cast<double>(std::max(n_candidates, 1));
208 const double td = static_cast<double>(t);
209 const double beta =
210 2.0 * std::log(nd * td * td * kPi * kPi / (6.0 * delta));
211 return std::sqrt(std::max(beta, 0.0));
212}