Loading...
Searching...
No Matches
gpr::quantum::NativeGPPath< Model > Class Template Reference

#include <gpr/quantum/NativeGPPath.h>

Public Member Functions

 NativeGPPath (Model &model, MassMetric metric, PathPotential native, std::size_t fitSites=24, std::size_t reservedHistorySites=0)
void calibrateSearchCurvature (const V &referencePhysical, const M &nativePhysicalHessian)
PathPotential taylorSurrogatePotential (PotentialEvaluation nativeReferenceValue)
PathPotential potential ()
PathPotential surrogatePotential ()
std::size_t fits () const noexcept
std::size_t searchHessians () const noexcept
std::size_t referenceSearchHessians () const noexcept
bool hasSearchCurvatureReference () const noexcept
double fitSeconds () const noexcept
double nativeCallbackSeconds () const noexcept
double observationSeconds () const noexcept
double searchCurvatureSeconds () const noexcept
double curvaturePreparationSeconds () const noexcept
double curvatureApplicationSeconds () const noexcept

Detailed Description

template<class Model>
class gpr::quantum::NativeGPPath< Model >

Definition at line 20 of file NativeGPPath.h.

Constructor & Destructor Documentation

◆ NativeGPPath()

template<class Model>
gpr::quantum::NativeGPPath< Model >::NativeGPPath ( Model & model,
MassMetric metric,
PathPotential native,
std::size_t fitSites = 24,
std::size_t reservedHistorySites = 0 )
inline

Definition at line 229 of file NativeGPPath.h.

232 : model_(model),
233 metric_(std::move(metric)),
234 native_(std::move(native)),
235 budget_(fitSites),
236 reservedHistorySites_(reservedHistorySites)
237 {
238 if ((!native_.evaluate && !native_.evaluateBatch) || fitSites < 2 ||
241 "Native forces, at least two GP fitting sites and a history "
242 "reserve smaller than the fitting budget required");
243 }

Member Function Documentation

◆ calibrateSearchCurvature()

template<class Model>
void gpr::quantum::NativeGPPath< Model >::calibrateSearchCurvature ( const V & referencePhysical,
const M & nativePhysicalHessian )
inline

Definition at line 247 of file NativeGPPath.h.

249 {
250 const auto d = metric_.dimension();
251 if (referencePhysical.size() != d || !referencePhysical.allFinite() ||
252 nativePhysicalHessian.rows() != d ||
253 nativePhysicalHessian.cols() != d ||
254 !nativePhysicalHessian.allFinite() ||
255 (nativePhysicalHessian - nativePhysicalHessian.transpose()).norm() >
256 1e-12 * std::max(1., nativePhysicalHessian.norm()))
258 "Finite physical reference coordinates and a matching "
259 "symmetric native Hessian required");
260 referencePhysical_ = referencePhysical;
261 referenceHessian_ =
262 .5 * (nativePhysicalHessian + nativePhysicalHessian.transpose());
263 referenceEnabled_ = true;
264 referenceCorrectionValid_ = false;
265 referencePredictionValid_ = false;
266 ++referenceRevision_;
267 }

◆ curvatureApplicationSeconds()

template<class Model>
double gpr::quantum::NativeGPPath< Model >::curvatureApplicationSeconds ( ) const
inlinenoexcept

Definition at line 372 of file NativeGPPath.h.

373 {
374 return curvatureApplicationSeconds_;
375 }

◆ curvaturePreparationSeconds()

template<class Model>
double gpr::quantum::NativeGPPath< Model >::curvaturePreparationSeconds ( ) const
inlinenoexcept

Definition at line 368 of file NativeGPPath.h.

369 {
370 return curvaturePreparationSeconds_;
371 }

◆ fits()

template<class Model>
std::size_t gpr::quantum::NativeGPPath< Model >::fits ( ) const
inlinenoexcept

Definition at line 333 of file NativeGPPath.h.

334 {
335 return fits_;
336 }

◆ fitSeconds()

template<class Model>
double gpr::quantum::NativeGPPath< Model >::fitSeconds ( ) const
inlinenoexcept

Definition at line 349 of file NativeGPPath.h.

350 {
351 return fitSeconds_;
352 }

◆ hasSearchCurvatureReference()

template<class Model>
bool gpr::quantum::NativeGPPath< Model >::hasSearchCurvatureReference ( ) const
inlinenoexcept

Definition at line 345 of file NativeGPPath.h.

346 {
347 return referenceEnabled_;
348 }

◆ nativeCallbackSeconds()

template<class Model>
double gpr::quantum::NativeGPPath< Model >::nativeCallbackSeconds ( ) const
inlinenoexcept

Definition at line 353 of file NativeGPPath.h.

354 {
355 return nativeCallbackSeconds_;
356 }

◆ observationSeconds()

template<class Model>
double gpr::quantum::NativeGPPath< Model >::observationSeconds ( ) const
inlinenoexcept

Definition at line 357 of file NativeGPPath.h.

358 {
359 return observationSeconds_;
360 }

◆ potential()

template<class Model>
PathPotential gpr::quantum::NativeGPPath< Model >::potential ( )
inline

Definition at line 300 of file NativeGPPath.h.

301 {
302 auto result = native_;
303 result.evaluate = [this](const V& x) { return observe({x}).at(0); };
304 result.evaluateBatch = [this](const auto& x) { return observe(x); };
305 result.searchHessian = [this](const V& x) { return curvature(x); };
306 return result;
307 }

◆ referenceSearchHessians()

template<class Model>
std::size_t gpr::quantum::NativeGPPath< Model >::referenceSearchHessians ( ) const
inlinenoexcept

Definition at line 341 of file NativeGPPath.h.

342 {
343 return referenceCurvatures_;
344 }

◆ searchCurvatureSeconds()

template<class Model>
double gpr::quantum::NativeGPPath< Model >::searchCurvatureSeconds ( ) const
inlinenoexcept

Definition at line 364 of file NativeGPPath.h.

365 {
366 return curvatureSeconds_;
367 }

◆ searchHessians()

template<class Model>
std::size_t gpr::quantum::NativeGPPath< Model >::searchHessians ( ) const
inlinenoexcept

Definition at line 337 of file NativeGPPath.h.

338 {
339 return curvatures_;
340 }

◆ surrogatePotential()

template<class Model>
PathPotential gpr::quantum::NativeGPPath< Model >::surrogatePotential ( )
inline

Definition at line 308 of file NativeGPPath.h.

309 {
310 auto result = native_;
311 result.evaluate = [this](const V& x) {
312 ensureFitted();
313 auto value = model_.evaluate({metric_.weighted(x)}).at(0);
314 value.gradient = metric_.roots().cwiseProduct(value.gradient);
315 return value;
316 };
317 result.evaluateBatch = [this](const std::vector<V>& x) {
318 if (x.empty()) return std::vector<PotentialEvaluation>{};
319 ensureFitted();
321 q.reserve(x.size());
322 for (const auto& point: x)
323 q.push_back(metric_.weighted(point));
324 auto values = model_.evaluate(q);
325 for (auto& value: values)
326 value.gradient = metric_.roots().cwiseProduct(value.gradient);
327 return values;
328 };
329 result.hessian = {};
330 result.searchHessian = [this](const V& x) { return curvature(x); };
331 return result;
332 }

◆ taylorSurrogatePotential()

template<class Model>
PathPotential gpr::quantum::NativeGPPath< Model >::taylorSurrogatePotential ( PotentialEvaluation nativeReferenceValue)
inline

Definition at line 272 of file NativeGPPath.h.

274 {
275 if (!referenceEnabled_ || !std::isfinite(nativeReferenceValue.energy) ||
276 nativeReferenceValue.gradient.size() != metric_.dimension() ||
277 !nativeReferenceValue.gradient.allFinite())
279 "Calibrated reference and finite matching physical native "
280 "value required");
281 const auto revision = referenceRevision_;
282 auto result = native_;
283 result.evaluate = [this, nativeReferenceValue, revision](const V& x) {
284 return taylorValues({x}, nativeReferenceValue, revision).at(0);
285 };
286 result.evaluateBatch = [this, nativeReferenceValue,
288 return taylorValues(points, nativeReferenceValue, revision);
289 };
290 result.hessian = {};
291 result.searchHessian = [this, revision](const V& x) {
292 if (revision != referenceRevision_)
293 throw std::logic_error(
294 "Taylor potential requires its bound reference "
295 "calibration");
296 return curvature(x);
297 };
298 return result;
299 }

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