https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
PolynomialRegressionSurrogate Class Reference

#include <PolynomialRegressionSurrogate.h>

Inheritance diagram for PolynomialRegressionSurrogate:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 PolynomialRegressionSurrogate (const InputParameters &parameters)
 
virtual Real evaluate (const std::vector< Real > &x) const override
 Evaluate surrogate model given a row of parameters.
 
virtual void evaluate (const std::vector< Real > &x, std::vector< Real > &y) const override
 Various evaluate methods that can be overriden.
 
virtual Real evaluate (const std::vector< Real > &x) const
 Evaluate surrogate model given a row of parameters.
 
virtual void evaluate (const std::vector< Real > &x, std::vector< Real > &y) const
 Various evaluate methods that can be overriden.
 
virtual Real evaluate (const std::vector< Real > &x, Real &std) const
 Evaluate methods that also return predicted standard deviation (see GaussianProcess.h)
 
virtual void evaluate (const std::vector< Real > &x, std::vector< Real > &y, std::vector< Real > &) const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
TgetSampler (const std::string &name)
 
SamplergetSampler (const std::string &name)
 
TgetSamplerByName (const SamplerName &name)
 
SamplergetSamplerByName (const SamplerName &name)
 
template<>
SurrogateModelgetSurrogateModel (const std::string &name) const
 
template<>
SurrogateTrainerBasegetSurrogateTrainer (const std::string &name) const
 
template<>
SurrogateModelgetSurrogateModelByName (const UserObjectName &name) const
 
template<>
SurrogateTrainerBasegetSurrogateTrainerByName (const UserObjectName &name) const
 
const std::string & modelMetaDataName () const
 Accessor for the name of the model meta data.
 
const FileName & getModelDataFileName () const
 Get the associated filename.
 
bool hasModelData () const
 Check if we need to load model data (if the filename parameter is used)
 
template<typename T = SurrogateModel>
TgetSurrogateModel (const std::string &name) const
 Get a SurrogateModel/Trainer with a given name.
 
template<typename T = SurrogateTrainerBase>
TgetSurrogateTrainer (const std::string &name) const
 
template<typename T = SurrogateModel>
TgetSurrogateModelByName (const UserObjectName &name) const
 Get a sampler with a given name.
 
template<typename T = SurrogateTrainerBase>
TgetSurrogateTrainerByName (const UserObjectName &name) const
 
template<typename T , typename... Args>
TdeclareModelData (const std::string &data_name, Args &&... args)
 Declare model data for loading from file as well as restart.
 
template<typename T , typename... Args>
const TgetModelData (const std::string &data_name, Args &&... args) const
 Retrieve model data from the interface.
 

Static Public Member Functions

static InputParameters validParams ()
 
static MooseEnum defaultPredictorTypes ()
 
static MooseEnum defaultResponseTypes ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 

Protected Member Functions

void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 

Protected Attributes

const std::vector< std::vector< Real > > & _coeff
 Coefficients of regression model.
 
const std::vector< std::vector< unsigned int > > & _power_matrix
 The power matrix for the terms in the polynomial expressions.
 
const bool & _enabled
 
MooseApp_app
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
const Parallel::Communicator & _communicator
 

Private Member Functions

template<typename P , typename R >
void evaluateError (P x, R y, bool with_std=false) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

const unsigned int_max_degree
 Maximum polynomial degree, limiting the sum of constituent polynomial degrees.
 
const ParallelParamObject_parent
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 
const InputParameters_si_params
 
FEProblemBase_si_feproblem
 
THREAD_ID _si_tid
 
const InputParameters_smi_params
 Parameters of the object with this interface.
 
FEProblemBase_smi_feproblem
 Reference to FEProblemBase instance.
 
const THREAD_ID _smi_tid
 Thread ID.
 
const MooseObject_model_object
 Reference to the MooseObject that uses this interface.
 
const std::string _model_meta_data_name
 The model meta data name.
 
PublicRestartable _model_restartable
 Member for interfacing with the framework's restartable system.
 

Detailed Description

Definition at line 14 of file PolynomialRegressionSurrogate.h.

Constructor & Destructor Documentation

◆ PolynomialRegressionSurrogate()

PolynomialRegressionSurrogate::PolynomialRegressionSurrogate ( const InputParameters parameters)

Definition at line 23 of file PolynomialRegressionSurrogate.C.

25 _coeff(getModelData<std::vector<std::vector<Real>>>("_coeff")),
26 _power_matrix(getModelData<std::vector<std::vector<unsigned int>>>("_power_matrix")),
27 _max_degree(getModelData<unsigned int>("_max_degree"))
28{
29}
const InputParameters & parameters() const
const unsigned int & _max_degree
Maximum polynomial degree, limiting the sum of constituent polynomial degrees.
const std::vector< std::vector< unsigned int > > & _power_matrix
The power matrix for the terms in the polynomial expressions.
const std::vector< std::vector< Real > > & _coeff
Coefficients of regression model.
const T & getModelData(const std::string &data_name, Args &&... args) const
Retrieve model data from the interface.

Member Function Documentation

◆ declareModelData()

template<typename T , typename... Args>
T & RestartableModelInterface::declareModelData ( const std::string &  data_name,
Args &&...  args 
)
inherited

Declare model data for loading from file as well as restart.

Definition at line 73 of file RestartableModelInterface.h.

74{
75 return _model_restartable.declareRestartableData<T>(data_name, std::forward<Args>(args)...);
76}
const double T
T & declareRestartableData(const std::string &data_name, Args &&... args)
Declare a piece of data as "restartable" and initialize it.
PublicRestartable _model_restartable
Member for interfacing with the framework's restartable system.

◆ defaultPredictorTypes()

static MooseEnum SurrogateModel::defaultPredictorTypes ( )
inlinestaticinherited

Definition at line 27 of file SurrogateModel.h.

27{ return MooseEnum("real"); }

◆ defaultResponseTypes()

static MooseEnum SurrogateModel::defaultResponseTypes ( )
inlinestaticinherited

Definition at line 28 of file SurrogateModel.h.

28{ return MooseEnum("real vector_real"); }

Referenced by EvaluateSurrogate::validParams().

◆ evaluate() [1/6]

virtual Real SurrogateModel::evaluate ( const std::vector< Real > &  x) const
inlinevirtual

Evaluate surrogate model given a row of parameters.

Reimplemented from SurrogateModel.

Definition at line 33 of file SurrogateModel.h.

34 {
36 return 0.0;
37 };
const std::vector< double > x
void evaluateError(P x, R y, bool with_std=false) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ evaluate() [2/6]

Real PolynomialRegressionSurrogate::evaluate ( const std::vector< Real > &  x) const
overridevirtual

Evaluate surrogate model given a row of parameters.

Reimplemented from SurrogateModel.

Definition at line 32 of file PolynomialRegressionSurrogate.C.

33{
34 // Check whether input point has same dimensionality as training data
35 mooseAssert(_power_matrix[0].size() == x.size(),
36 "Input point does not match dimensionality of training data.");
37
38 Real val(0.0);
39 for (unsigned int i = 0; i < _power_matrix.size(); ++i)
40 {
41 Real tmp_val(1.0);
42 for (unsigned int j = 0; j < _power_matrix[i].size(); ++j)
43 tmp_val *= MathUtils::pow(x[j], _power_matrix[i][j]);
44 val += _coeff[0][i] * tmp_val;
45 }
46
47 return val;
48}
T pow(T x, int e)

◆ evaluate() [3/6]

virtual Real SurrogateModel::evaluate ( const std::vector< Real > &  x,
Real &  std 
) const
inlinevirtual

Evaluate methods that also return predicted standard deviation (see GaussianProcess.h)

Reimplemented from SurrogateModel.

Definition at line 53 of file SurrogateModel.h.

54 {
55 evaluateError(x, std, true);
56 return 0.0;
57 }

◆ evaluate() [4/6]

virtual void SurrogateModel::evaluate ( const std::vector< Real > &  x,
std::vector< Real > &  y 
) const
inlinevirtual

Various evaluate methods that can be overriden.

Reimplemented from SurrogateModel.

Definition at line 43 of file SurrogateModel.h.

44 {
46 }
const std::vector< double > y

◆ evaluate() [5/6]

void PolynomialRegressionSurrogate::evaluate ( const std::vector< Real > &  x,
std::vector< Real > &  y 
) const
overridevirtual

Various evaluate methods that can be overriden.

Reimplemented from SurrogateModel.

Definition at line 51 of file PolynomialRegressionSurrogate.C.

52{
53 // Check whether input point has same dimensionality as training data
54 mooseAssert(_power_matrix[0].size() == x.size(),
55 "Input point does not match dimensionality of training data.");
56
57 y.assign(_coeff.size(), 0.0);
58 for (unsigned int i = 0; i < _power_matrix.size(); ++i)
59 {
60 Real tmp_val(1.0);
61 for (unsigned int j = 0; j < _power_matrix[i].size(); ++j)
62 tmp_val *= MathUtils::pow(x[j], _power_matrix[i][j]);
63 for (unsigned int r = 0; r < _coeff.size(); ++r)
64 y[r] += _coeff[r][i] * tmp_val;
65 }
66}

◆ evaluate() [6/6]

virtual void SurrogateModel::evaluate ( const std::vector< Real > &  x,
std::vector< Real > &  y,
std::vector< Real > &   
) const
inlinevirtual

Reimplemented from SurrogateModel.

Definition at line 59 of file SurrogateModel.h.

60 {
61 evaluateError(x, y, true);
62 }

◆ evaluateError()

template<typename P , typename R >
void SurrogateModel::evaluateError ( P  x,
R  y,
bool  with_std = false 
) const
privateinherited

Definition at line 72 of file SurrogateModel.h.

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 mooseError(Args &&... args) const

Referenced by SurrogateModel::evaluate(), SurrogateModel::evaluate(), SurrogateModel::evaluate(), and SurrogateModel::evaluate().

◆ getModelData()

template<typename T , typename... Args>
const T & RestartableModelInterface::getModelData ( const std::string &  data_name,
Args &&...  args 
) const
inherited

Retrieve model data from the interface.

Definition at line 80 of file RestartableModelInterface.h.

81{
82 return _model_restartable.getRestartableData<T>(data_name, std::forward<Args>(args)...);
83}
const T & getRestartableData(const std::string &data_name) const
Declare a piece of data as "restartable" and initialize it Similar to declareRestartableData but retu...

◆ getModelDataFileName()

const FileName & RestartableModelInterface::getModelDataFileName ( ) const
inherited

Get the associated filename.

Definition at line 33 of file RestartableModelInterface.C.

34{
35 return _model_object.getParam<FileName>("filename");
36}
const T & getParam(const std::string &name) const
const MooseObject & _model_object
Reference to the MooseObject that uses this interface.

◆ getSurrogateModel() [1/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateModel ( const std::string &  name) const
inherited

Get a SurrogateModel/Trainer with a given name.

Parameters
nameThe name of the parameter key of the sampler to retrieve
Returns
The sampler with name associated with the parameter 'name'

Definition at line 81 of file SurrogateModelInterface.h.

82{
83 return getSurrogateModelByName<T>(_smi_params.get<UserObjectName>(name));
84}
const std::string name
Definition Setup.h:21
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
const InputParameters & _smi_params
Parameters of the object with this interface.

Referenced by SurrogateTrainer::initialize().

◆ getSurrogateModel() [2/2]

template<>
SurrogateModel & SurrogateModelInterface::getSurrogateModel ( const std::string &  name) const
inherited

Definition at line 46 of file SurrogateModelInterface.C.

47{
48 return getSurrogateModelByName<SurrogateModel>(_smi_params.get<UserObjectName>(name));
49}

◆ getSurrogateModelByName() [1/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateModelByName ( const UserObjectName &  name) const
inherited

Get a sampler with a given name.

Parameters
nameThe name of the sampler to retrieve
Returns
The sampler with name 'name'

Definition at line 88 of file SurrogateModelInterface.h.

89{
90 std::vector<T *> models;
92 .query()
93 .condition<AttribName>(name)
94 .condition<AttribSystem>("SurrogateModel")
95 .queryInto(models);
96 if (models.empty())
97 mooseError("Unable to find a SurrogateModel object of type " + std::string(typeid(T).name()) +
98 " with the name '" + name + "'");
99 return *(models[0]);
100}
void mooseError(Args &&... args)
TheWarehouse & theWarehouse() const
FEProblemBase & _smi_feproblem
Reference to FEProblemBase instance.
Query query()

Referenced by CrossValidationScores::CrossValidationScores(), EvaluateSurrogate::EvaluateSurrogate(), and InverseMapping::initialSetup().

◆ getSurrogateModelByName() [2/2]

template<>
SurrogateModel & SurrogateModelInterface::getSurrogateModelByName ( const UserObjectName &  name) const
inherited

Definition at line 31 of file SurrogateModelInterface.C.

32{
33 std::vector<SurrogateModel *> models;
35 .query()
36 .condition<AttribName>(name)
37 .condition<AttribSystem>("SurrogateModel")
38 .queryInto(models);
39 if (models.empty())
40 mooseError("Unable to find a SurrogateModel object with the name '" + name + "'");
41 return *(models[0]);
42}

◆ getSurrogateTrainer() [1/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateTrainer ( const std::string &  name) const
inherited

Definition at line 104 of file SurrogateModelInterface.h.

105{
106 return getSurrogateTrainerByName<T>(_smi_params.get<UserObjectName>(name));
107}

◆ getSurrogateTrainer() [2/2]

template<>
SurrogateTrainerBase & SurrogateModelInterface::getSurrogateTrainer ( const std::string &  name) const
inherited

Definition at line 60 of file SurrogateModelInterface.C.

61{
62 return getSurrogateTrainerByName<SurrogateTrainerBase>(_smi_params.get<UserObjectName>(name));
63}

◆ getSurrogateTrainerByName() [1/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateTrainerByName ( const UserObjectName &  name) const
inherited

Definition at line 111 of file SurrogateModelInterface.h.

112{
113 SurrogateTrainerBase * base_ptr =
115 T * obj_ptr = dynamic_cast<T *>(base_ptr);
116 if (!obj_ptr)
117 mooseError("Failed to find a SurrogateTrainer object of type " + std::string(typeid(T).name()) +
118 " with the name '",
119 name,
120 "' for the desired type.");
121 return *obj_ptr;
122}
T & getUserObject(const std::string &name, unsigned int tid=0) const
const THREAD_ID _smi_tid
Thread ID.
This is the base trainer class whose main functionality is the API for declaring model data.

Referenced by SurrogateTrainerOutput::output().

◆ getSurrogateTrainerByName() [2/2]

template<>
SurrogateTrainerBase & SurrogateModelInterface::getSurrogateTrainerByName ( const UserObjectName &  name) const
inherited

Definition at line 53 of file SurrogateModelInterface.C.

◆ hasModelData()

bool RestartableModelInterface::hasModelData ( ) const
inherited

Check if we need to load model data (if the filename parameter is used)

Definition at line 39 of file RestartableModelInterface.C.

40{
41 return _model_object.isParamValid("filename");
42}
bool isParamValid(const std::string &name) const

◆ modelMetaDataName()

const std::string & RestartableModelInterface::modelMetaDataName ( ) const
inlineinherited

Accessor for the name of the model meta data.

Definition at line 47 of file RestartableModelInterface.h.

47{ return _model_meta_data_name; }
const std::string _model_meta_data_name
The model meta data name.

Referenced by MappingOutput::output(), and SurrogateTrainerOutput::output().

◆ validParams()

InputParameters PolynomialRegressionSurrogate::validParams ( )
static

Definition at line 15 of file PolynomialRegressionSurrogate.C.

16{
18 params.addClassDescription("Evaluates polynomial regression model with coefficients computed "
19 "from PolynomialRegressionTrainer.");
20 return params;
21}
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()

Member Data Documentation

◆ _coeff

const std::vector<std::vector<Real> >& PolynomialRegressionSurrogate::_coeff
protected

Coefficients of regression model.

Definition at line 27 of file PolynomialRegressionSurrogate.h.

Referenced by evaluate(), and evaluate().

◆ _max_degree

const unsigned int& PolynomialRegressionSurrogate::_max_degree
private

Maximum polynomial degree, limiting the sum of constituent polynomial degrees.

Definition at line 34 of file PolynomialRegressionSurrogate.h.

◆ _model_meta_data_name

const std::string RestartableModelInterface::_model_meta_data_name
privateinherited

The model meta data name.

This is used to store the restartable data within the RestartableDataMap.

Definition at line 61 of file RestartableModelInterface.h.

Referenced by RestartableModelInterface::modelMetaDataName(), and RestartableModelInterface::RestartableModelInterface().

◆ _model_object

const MooseObject& RestartableModelInterface::_model_object
privateinherited

◆ _model_restartable

PublicRestartable RestartableModelInterface::_model_restartable
privateinherited

Member for interfacing with the framework's restartable system.

We need this because we would like to have the capability to handle the model data separately from the other data members used for checkpointing.

Definition at line 68 of file RestartableModelInterface.h.

Referenced by RestartableModelInterface::declareModelData(), and RestartableModelInterface::getModelData().

◆ _power_matrix

const std::vector<std::vector<unsigned int> >& PolynomialRegressionSurrogate::_power_matrix
protected

The power matrix for the terms in the polynomial expressions.

Definition at line 30 of file PolynomialRegressionSurrogate.h.

Referenced by evaluate(), and evaluate().

◆ _smi_feproblem

FEProblemBase& SurrogateModelInterface::_smi_feproblem
privateinherited

◆ _smi_params

const InputParameters& SurrogateModelInterface::_smi_params
privateinherited

Parameters of the object with this interface.

Definition at line 70 of file SurrogateModelInterface.h.

Referenced by SurrogateModelInterface::getSurrogateModel(), and SurrogateModelInterface::getSurrogateTrainer().

◆ _smi_tid

const THREAD_ID SurrogateModelInterface::_smi_tid
privateinherited

Thread ID.

Definition at line 76 of file SurrogateModelInterface.h.

Referenced by SurrogateModelInterface::getSurrogateTrainerByName().


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