https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
19 public SamplerInterface,
22{
23public:
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 {
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
65private:
66 template <typename P, typename R>
67 void evaluateError(P x, R y, bool with_std = false) const;
68};
69
70template <typename P, typename R>
71void
72SurrogateModel::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}
const std::vector< double > y
const std::vector< double > x
const double R
const InputParameters & parameters() const
void mooseError(Args &&... args) const
An interface class which manages the model data save and load functionalities from moose objects (suc...
Interface for objects that need to use samplers.
virtual Real evaluate(const std::vector< Real > &x, Real &std) const
Evaluate methods that also return predicted standard deviation (see GaussianProcess....
static InputParameters validParams()
void evaluateError(P x, R y, bool with_std=false) const
virtual void evaluate(const std::vector< Real > &x, std::vector< Real > &y, std::vector< Real > &) const
virtual void evaluate(const std::vector< Real > &x, std::vector< Real > &y) const
Various evaluate methods that can be overriden.
static MooseEnum defaultPredictorTypes()
static MooseEnum defaultResponseTypes()
virtual Real evaluate(const std::vector< Real > &x) const
Evaluate surrogate model given a row of parameters.