https://mooseframework.inl.gov
CovarianceFunctionBase.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 "CovarianceInterface.h"
15 
20 {
21 public:
24 
31  const RealEigenMatrix & x,
32  const RealEigenMatrix & xp,
33  const bool is_self_covariance) const = 0;
34 
38  void loadHyperParamMap(const std::unordered_map<std::string, Real> & map,
39  const std::unordered_map<std::string, std::vector<Real>> & vec_map);
40 
44  void buildHyperParamMap(std::unordered_map<std::string, Real> & map,
45  std::unordered_map<std::string, std::vector<Real>> & vec_map) const;
46 
54  virtual bool
55  getTuningData(const std::string & name, unsigned int & size, Real & min, Real & max) const;
56 
59  void dependentCovarianceTypes(std::map<UserObjectName, std::string> & name_type_map) const;
60 
62  const std::vector<UserObjectName> & dependentCovarianceNames() const
63  {
65  }
66 
75  virtual bool computedKdhyper(RealEigenMatrix & dKdhp,
76  const RealEigenMatrix & x,
77  const std::string & hyper_param_name,
78  unsigned int ind) const;
79 
82  virtual bool isTunable(const std::string & name) const;
83 
85  unsigned int numOutputs() const { return _num_outputs; }
86 
88  std::unordered_map<std::string, Real> & hyperParamMapReal() { return _hp_map_real; }
89 
91  std::unordered_map<std::string, std::vector<Real>> & hyperParamMapVectorReal()
92  {
93  return _hp_map_vector_real;
94  }
95 
96 protected:
101  const Real &
102  addRealHyperParameter(const std::string & name, const Real value, const bool is_tunable);
103 
108  const std::vector<Real> & addVectorRealHyperParameter(const std::string & name,
109  const std::vector<Real> value,
110  const bool is_tunable);
111 
113  std::unordered_map<std::string, Real> _hp_map_real;
114 
116  std::unordered_map<std::string, std::vector<Real>> _hp_map_vector_real;
117 
119  std::unordered_set<std::string> _tunable_hp;
120 
122  const unsigned int _num_outputs;
123 
125  const std::vector<UserObjectName> _dependent_covariance_names;
126 
128  std::vector<std::string> _dependent_covariance_types;
129 
131  std::vector<CovarianceFunctionBase *> _covariance_functions;
132 };
std::unordered_map< std::string, Real > _hp_map_real
Map of real-valued hyperparameters.
void loadHyperParamMap(const std::unordered_map< std::string, Real > &map, const std::unordered_map< std::string, std::vector< Real >> &vec_map)
Load some hyperparameters into the local maps contained in this object.
std::vector< std::string > _dependent_covariance_types
The types of the dependent covariance functions.
std::unordered_set< std::string > _tunable_hp
list of tunable hyper-parameters
static const std::string K
Definition: NS.h:170
std::vector< CovarianceFunctionBase * > _covariance_functions
Vector of pointers to the dependent covariance functions.
Base class for covariance functions that are used in Gaussian Processes.
static InputParameters validParams()
CovarianceFunctionBase(const InputParameters &parameters)
const std::vector< Real > & addVectorRealHyperParameter(const std::string &name, const std::vector< Real > value, const bool is_tunable)
Register a vector hyperparameter to this covariance function.
virtual const std::string & name() const
auto max(const L &left, const R &right)
const unsigned int _num_outputs
The number of outputs this covariance function is used to describe.
const std::vector< double > x
std::unordered_map< std::string, std::vector< Real > > & hyperParamMapVectorReal()
Get the map of vector parameters.
std::unordered_map< std::string, Real > & hyperParamMapReal()
Get the map of scalar parameters.
const std::vector< UserObjectName > & dependentCovarianceNames() const
Get the names of the dependent covariances.
void buildHyperParamMap(std::unordered_map< std::string, Real > &map, std::unordered_map< std::string, std::vector< Real >> &vec_map) const
Populates the input maps with the owned hyperparameters.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealEigenMatrix
void dependentCovarianceTypes(std::map< UserObjectName, std::string > &name_type_map) const
Populate a map with the names and types of the dependent covariance functions.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void computeCovarianceMatrix(RealEigenMatrix &K, const RealEigenMatrix &x, const RealEigenMatrix &xp, const bool is_self_covariance) const =0
Generates the Covariance Matrix given two sets of points in the parameter space.
std::unordered_map< std::string, std::vector< Real > > _hp_map_vector_real
Map of vector-valued hyperparameters.
const std::vector< UserObjectName > _dependent_covariance_names
The names of the dependent covariance functions.
const InputParameters & parameters() const
unsigned int numOutputs() const
Return the number of outputs assumed for this covariance function.
const Real & addRealHyperParameter(const std::string &name, const Real value, const bool is_tunable)
Register a scalar hyperparameter to this covariance function.
auto min(const L &left, const R &right)
virtual bool computedKdhyper(RealEigenMatrix &dKdhp, const RealEigenMatrix &x, const std::string &hyper_param_name, unsigned int ind) const
Redirect dK/dhp for hyperparameter "hp".
virtual bool getTuningData(const std::string &name, unsigned int &size, Real &min, Real &max) const
Get the default minimum and maximum and size of a hyperparameter.
virtual bool isTunable(const std::string &name) const
Check if a given parameter is tunable.