Loading...
Searching...
No Matches
gpr::capi::FreeEnergySurrogate Class Reference

Owner of a gpr_fes_t. Arrays are row-major, one row per point. More...

#include <gpr/capi/gpridge.hpp>

Classes

struct  Prediction

Public Member Functions

 FreeEnergySurrogate ()=default
 FreeEnergySurrogate (gpr_fes_t h, adopt_t) noexcept
 ~FreeEnergySurrogate ()
 FreeEnergySurrogate (const FreeEnergySurrogate &)=delete
FreeEnergySurrogate & operator= (const FreeEnergySurrogate &)=delete
 FreeEnergySurrogate (FreeEnergySurrogate &&other) noexcept
FreeEnergySurrogate & operator= (FreeEnergySurrogate &&other) noexcept
void reset () noexcept
gpr_fes_t handle () const noexcept
 operator bool () const noexcept
int dimension () const
int n_observations () const
void train (const std::vector< double > &s, const std::vector< double > &F, const std::vector< double > &F_noise_var, const std::vector< double > &grad_F, const std::vector< double > &grad_noise_var, const std::vector< std::uint8_t > &grad_present, int n_obs)
Prediction predict (const std::vector< double > &s_query, int n_queries, bool with_gradient, bool with_variance) const
FesRateReport rate_path (const std::vector< double > &path, int n_path, int reactant_index, int product_index, const std::vector< double > &diffusion, const FesRateConfig &config) const

Static Public Member Functions

static FreeEnergySurrogate create (int dimension, const ModelConfig &model_config=model_config_defaults(), const FesConfig &config=fes_config_defaults(), const std::vector< double > &grad_noise_var={})

Detailed Description

Owner of a gpr_fes_t. Arrays are row-major, one row per point.

Definition at line 859 of file gpridge.hpp.

Constructor & Destructor Documentation

◆ FreeEnergySurrogate() [1/4]

gpr::capi::FreeEnergySurrogate::FreeEnergySurrogate ( )
default

◆ FreeEnergySurrogate() [2/4]

gpr::capi::FreeEnergySurrogate::FreeEnergySurrogate ( gpr_fes_t h,
adopt_t  )
inlinenoexcept

Definition at line 862 of file gpridge.hpp.

862: handle_(h) { }

◆ ~FreeEnergySurrogate()

gpr::capi::FreeEnergySurrogate::~FreeEnergySurrogate ( )
inline

Definition at line 863 of file gpridge.hpp.

864 {
865 reset();
866 }

◆ FreeEnergySurrogate() [3/4]

gpr::capi::FreeEnergySurrogate::FreeEnergySurrogate ( const FreeEnergySurrogate & )
delete

◆ FreeEnergySurrogate() [4/4]

gpr::capi::FreeEnergySurrogate::FreeEnergySurrogate ( FreeEnergySurrogate && other)
inlinenoexcept

Definition at line 870 of file gpridge.hpp.

871 : handle_(other.handle_)
872 {
873 other.handle_ = nullptr;
874 }

Member Function Documentation

◆ create()

FreeEnergySurrogate gpr::capi::FreeEnergySurrogate::create ( int dimension,
const ModelConfig & model_config = model_config_defaults(),
const FesConfig & config = fes_config_defaults(),
const std::vector< double > & grad_noise_var = {} )
inlinestaticnodiscard

Definition at line 885 of file gpridge.hpp.

889 {})
890 {
891 gpr_fes_t h = gpr_fes_create(dimension, &model_config, &config,
892 optional_data(grad_noise_var),
893 grad_noise_var.size());
894 if (!h) throw Error(gpr_last_status(), gpr_last_error_message());
895 return FreeEnergySurrogate(h, adopt);
896 }
int gpr_last_status(void)
Status of the last call on this thread that failed (ABI 1.1), like errno: a constructor that returns ...
const char * gpr_last_error_message(void)
The same string as gpr_last_error (ABI 1.6). Never NULL. Fortran and the other bindings call this nam...
gpr_fes_t gpr_fes_create(int dimension, const gpr_model_config_t *model_config, const gpr_fes_config_t *fes_config, const double *grad_noise_var, size_t grad_noise_var_len)
Create an untrained free-energy surrogate.
struct gpr_fes_s * gpr_fes_t
Definition gpridge_c.h:386
constexpr adopt_t adopt
Definition gpridge.hpp:37

◆ dimension()

int gpr::capi::FreeEnergySurrogate::dimension ( ) const
inlinenodiscard

Definition at line 913 of file gpridge.hpp.

914 {
915 return gpr_fes_dimension(require_handle());
916 }
int gpr_fes_dimension(gpr_fes_t fes)
Collective-variable dimension, or 0 for NULL or a dead handle.

◆ handle()

gpr_fes_t gpr::capi::FreeEnergySurrogate::handle ( ) const
inlinenodiscardnoexcept

Definition at line 904 of file gpridge.hpp.

905 {
906 return handle_;
907 }

◆ n_observations()

int gpr::capi::FreeEnergySurrogate::n_observations ( ) const
inlinenodiscard

Definition at line 917 of file gpridge.hpp.

918 {
919 return gpr_fes_n_observations(require_handle());
920 }
int gpr_fes_n_observations(gpr_fes_t fes)
Number of training points, or 0 before training, for NULL or for a dead handle.

◆ operator bool()

gpr::capi::FreeEnergySurrogate::operator bool ( ) const
inlineexplicitnodiscardnoexcept

Definition at line 908 of file gpridge.hpp.

909 {
910 return handle_ != nullptr;
911 }

◆ operator=() [1/2]

FreeEnergySurrogate & gpr::capi::FreeEnergySurrogate::operator= ( const FreeEnergySurrogate & )
delete

◆ operator=() [2/2]

FreeEnergySurrogate & gpr::capi::FreeEnergySurrogate::operator= ( FreeEnergySurrogate && other)
inlinenoexcept

Definition at line 875 of file gpridge.hpp.

876 {
877 if (this != &other) {
878 reset();
879 handle_ = other.handle_;
880 other.handle_ = nullptr;
881 }
882 return *this;
883 }

◆ predict()

Prediction gpr::capi::FreeEnergySurrogate::predict ( const std::vector< double > & s_query,
int n_queries,
bool with_gradient,
bool with_variance ) const
inlinenodiscard

Definition at line 945 of file gpridge.hpp.

948 {
949 const int d = dimension();
951 out.F.resize(static_cast<std::size_t>(n_queries));
952 if (with_gradient) {
953 out.grad_F.resize(static_cast<std::size_t>(n_queries) *
954 static_cast<std::size_t>(d));
955 }
956 if (with_variance) out.var_F.resize(out.F.size());
958 require_handle(), s_query.data(), s_query.size(), out.F.data(),
959 out.F.size(), with_gradient ? out.grad_F.data() : nullptr,
960 out.grad_F.size(), with_variance ? out.var_F.data() : nullptr,
961 out.var_F.size(), n_queries, d));
962 return out;
963 }
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
int gpr_fes_predict_batch_checked(gpr_fes_t fes, const double *s_query, size_t s_query_len, double *F_out, size_t F_len, double *grad_F_out, size_t grad_F_len, double *var_F_out, size_t var_F_len, int n_queries, int dimension)
Posterior mean of F at each query point, with its gradient and the latent posterior variance of F whe...
void check(int status)
Definition gpridge.hpp:323

◆ rate_path()

FesRateReport gpr::capi::FreeEnergySurrogate::rate_path ( const std::vector< double > & path,
int n_path,
int reactant_index,
int product_index,
const std::vector< double > & diffusion,
const FesRateConfig & config ) const
inlinenodiscard

Definition at line 965 of file gpridge.hpp.

970 {
971 FesRateReport report{};
972 report.struct_size = sizeof(report);
974 require_handle(), path.data(), path.size(), n_path, dimension(),
975 reactant_index, product_index, diffusion.data(), diffusion.size(),
976 &config, &report));
977 return report;
978 }
int gpr_fes_rate_path_checked(gpr_fes_t fes, const double *path, size_t path_len, int n_path, int dimension, int reactant_index, int product_index, const double *diffusion, size_t diffusion_len, const gpr_fes_rate_config_t *config, gpr_fes_rate_report_t *report)
Overdamped Kramers-Langer rate from path point reactant_index to product_index, with its uncertainty ...
gpr_fes_rate_report_t FesRateReport
Definition gpridge.hpp:253

◆ reset()

void gpr::capi::FreeEnergySurrogate::reset ( )
inlinenoexcept

Definition at line 898 of file gpridge.hpp.

899 {
900 if (handle_) gpr_fes_destroy(handle_);
901 handle_ = nullptr;
902 }
void gpr_fes_destroy(gpr_fes_t fes)
Destroy a handle from gpr_fes_create. Destroying NULL or a live handle clears gpr_last_status(); a de...

◆ train()

void gpr::capi::FreeEnergySurrogate::train ( const std::vector< double > & s,
const std::vector< double > & F,
const std::vector< double > & F_noise_var,
const std::vector< double > & grad_F,
const std::vector< double > & grad_noise_var,
const std::vector< std::uint8_t > & grad_present,
int n_obs )
inline

Values only when grad_F is empty; otherwise grad_F, grad_noise_var and grad_present are all given.

Definition at line 924 of file gpridge.hpp.

929 {
931 require_handle(), s.data(), s.size(), F.data(), F.size(),
932 optional_data(F_noise_var), F_noise_var.size(),
933 optional_data(grad_F), grad_F.size(), optional_data(grad_noise_var),
934 grad_noise_var.size(),
935 grad_present.empty() ? nullptr : grad_present.data(),
936 grad_present.size(), n_obs, dimension()));
937 }
int gpr_fes_train_checked(gpr_fes_t fes, const double *s, size_t s_len, const double *F, size_t F_len, const double *F_noise_var, size_t F_noise_var_len, const double *grad_F, size_t grad_F_len, const double *grad_noise_var, size_t grad_noise_var_len, const uint8_t *grad_present, size_t grad_present_len, int n_obs, int dimension)
Replace the training data and fit the hyperparameters.

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