Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : #ifdef MOOSE_LIBTORCH_ENABLED 10 : 11 : #pragma once 12 : 13 : #include "SurrogateModel.h" 14 : #include "Standardizer.h" 15 : #include "CovarianceInterface.h" 16 : #include "GaussianProcess.h" 17 : 18 : #include "LibtorchUtils.h" 19 : 20 : class GaussianProcessSurrogate : public SurrogateModel, public CovarianceInterface 21 : { 22 : public: 23 : static InputParameters validParams(); 24 : GaussianProcessSurrogate(const InputParameters & parameters); 25 : using SurrogateModel::evaluate; 26 : virtual Real evaluate(const std::vector<Real> & x) const; 27 : virtual void evaluate(const std::vector<Real> & x, std::vector<Real> & y) const; 28 : virtual Real evaluate(const std::vector<Real> & x, Real & std) const; 29 : virtual void 30 : evaluate(const std::vector<Real> & x, std::vector<Real> & y, std::vector<Real> & std) const; 31 : 32 : /** 33 : * This function is called by LoadCovarianceDataAction when the surrogate is 34 : * loading training data from a file. The action must recreate the covariance 35 : * object before this surrogate can set the correct pointer. 36 : */ 37 : virtual void setupCovariance(UserObjectName _covar_name); 38 : 39 : StochasticTools::GaussianProcess & gp() { return _gp; } 40 128 : const StochasticTools::GaussianProcess & getGP() const { return _gp; } 41 : 42 : private: 43 : StochasticTools::GaussianProcess & _gp; 44 : 45 : /// Paramaters (x) used for training 46 : const torch::Tensor & _training_params; 47 : }; 48 : 49 : #endif