https://mooseframework.inl.gov
SurrogateModel.h
Go to the documentation of this file.
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 
10 #pragma once
11 
12 #include "StochasticToolsApp.h"
13 #include "MooseObject.h"
14 #include "SamplerInterface.h"
17 
18 class SurrogateModel : public MooseObject,
19  public SamplerInterface,
22 {
23 public:
26 
27  static MooseEnum defaultPredictorTypes() { return MooseEnum("real"); }
28  static MooseEnum defaultResponseTypes() { return MooseEnum("real vector_real"); }
29 
33  virtual Real evaluate(const std::vector<Real> & x) const
34  {
35  evaluateError(x, Real());
36  return 0.0;
37  };
38 
40 
43  virtual void evaluate(const std::vector<Real> & x, std::vector<Real> & y) const
44  {
45  evaluateError(x, y);
46  }
48 
50 
53  virtual Real evaluate(const std::vector<Real> & x, Real & std) const
54  {
55  evaluateError(x, std, true);
56  return 0.0;
57  }
58  virtual void
59  evaluate(const std::vector<Real> & x, std::vector<Real> & y, std::vector<Real> & /*std*/) const
60  {
61  evaluateError(x, y, true);
62  }
64 
65 private:
66  template <typename P, typename R>
67  void evaluateError(P x, R y, bool with_std = false) const;
68 };
69 
70 template <typename P, typename R>
71 void
72 SurrogateModel::evaluateError(P /*x*/, R /*y*/, bool with_std) const
73 {
74  std::stringstream ss;
75  ss << "Evaluate method";
76  if (with_std)
77  ss << " (including standard deviation computation)";
78  ss << " with predictor type " << MooseUtils::prettyCppType<P>();
79  ss << " and response type " << MooseUtils::prettyCppType<R>();
80  ss << " has not been implemented.";
81  mooseError(ss.str());
82 }
void evaluateError(P x, R y, bool with_std=false) const
static MooseEnum defaultPredictorTypes()
static MooseEnum defaultResponseTypes()
virtual void evaluate(const std::vector< Real > &x, std::vector< Real > &y) const
Various evaluate methods that can be overriden.
const std::vector< double > y
static InputParameters validParams()
const std::vector< double > x
virtual Real evaluate(const std::vector< Real > &x) const
Evaluate surrogate model given a row of parameters.
static const std::string R
Definition: NS.h:162
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Interface for objects that need to use samplers.
void mooseError(Args &&... args) const
const InputParameters & parameters() const
SurrogateModel(const InputParameters &parameters)
virtual void evaluate(const std::vector< Real > &x, std::vector< Real > &y, std::vector< Real > &) const
virtual Real evaluate(const std::vector< Real > &x, Real &std) const
Evaluate methods that also return predicted standard deviation (see GaussianProcess.h)
An interface class which manages the model data save and load functionalities from moose objects (suc...