23 "distributions",
"Names of the distributions samples were taken from.");
24 MooseEnum rtype(
"integration ols auto",
"auto");
28 "The type of regression to perform for finding polynomial coefficents.");
29 params.
addParam<
Real>(
"penalty", 0.0,
"Ridge regularization penalty factor for OLS regression.");
37 _predictor_row(getPredictorData()),
38 _order(declareModelData<unsigned
int>(
"_order", getParam<unsigned
int>(
"order"))),
39 _ndim(declareModelData<unsigned
int>(
"_ndim", _sampler.getNumberOfCols())),
40 _tuple(declareModelData<
std::vector<
std::vector<unsigned
int>>>(
41 "_tuple",
StochasticTools::MultiDimPolynomialGenerator::generateTuple(_ndim, _order))),
42 _ncoeff(declareModelData<
std::size_t>(
"_ncoeff", _tuple.size())),
43 _coeff(declareModelData<
std::vector<
Real>>(
"_coeff")),
46 _ridge_penalty(getParam<
Real>(
"penalty")),
52 "Sampler number of columns does not match number of inputted distributions.");
54 auto rtype_enum = getParam<MooseEnum>(
"regression_type");
55 if (rtype_enum ==
"auto")
58 _rtype = rtype_enum ==
"integration" ? 0 : 1;
63 "QuadratureSampler must use all Sampler columns for training, and cannot be" 64 " used with other Reporters - otherwise, quadrature integration does not work.");
67 "Ridge regularization penalty is only relevant if 'regression_type = ols'.");
70 for (
const auto & nm :
getParam<std::vector<DistributionName>>(
"distributions"))
95 "Number of data points (",
97 ") must be greater than the number of terms in the polynomial (",
103 calc->initializeCalculator();
113 for (
unsigned int d = 0;
d <
_ndim; ++
d)
114 for (
unsigned int i = 0; i <
_order; ++i)
118 std::vector<Real> basis(
_ncoeff, 1.0);
121 basis[i] *= poly_val(
d,
_tuple[i][
d]);
128 _coeff[i] += fact * basis[i];
139 _rhs(i) += basis[i] * (*_rval);
141 for (
unsigned int c = i * 3;
c < (i + 1) * 3; ++
c)
159 for (std::size_t i = 0; i <
_ncoeff; ++i)
167 calc->finalizeCalculator(
true);
171 std::vector<Real> sig(
_ncoeff);
172 std::vector<Real> sum_pf(
_ncoeff);
176 sig[i] = i > 0 ?
_calculators[3 * i + 1]->getValue() : 1.0;
193 DenseVector<Real> sol;
195 _coeff = sol.get_values();
197 for (
unsigned int i = 1; i <
_ncoeff; ++i)
A class used to produce samples based on quadrature for Polynomial Chaos.
unsigned int getCurrentSampleSize() const
unsigned int _rtype
The method in which to perform the regression (0=integration, 1=OLS)
std::size_t & _ncoeff
Total number of coefficient (defined by size of _tuple)
const Real & _ridge_penalty
The penalty parameter for Ridge regularization.
std::vector< std::vector< unsigned int > > & _tuple
A _ndim-by-_ncoeff matrix containing the appropriate one-dimensional polynomial order.
std::unique_ptr< const Polynomial > makePolynomial(const Distribution *dist)
virtual void train() override
std::vector< unsigned int > _pcols
Columns from sampler for predictors.
std::vector< const Real * > _pvals
Predictor values from reporters.
const unsigned int & _order
Maximum polynomial order. The sum of 1D polynomial orders does not go above this value.
static InputParameters validParams()
std::vector< std::unique_ptr< const PolynomialQuadrature::Polynomial > > & _poly
The distributions used for sampling.
dof_id_type _row
During training loop, this is the row index of the data.
static const std::string mu
QuadratureSampler * _quad_sampler
QuadratureSampler pointer, necessary for applying quadrature weights.
const T & getParam(const std::string &name) const
Real getQuadratureWeight(dof_id_type row_index) const
const std::vector< Real > & _predictor_row
Predictor values.
void paramError(const std::string ¶m, Args... args) const
std::vector< Real > & get_values()
const Distribution & getDistributionByName(const DistributionName &name) const
virtual void postTrain() override
void lu_solve(const DenseVector< Real > &b, DenseVector< Real > &x)
registerMooseObject("StochasticToolsApp", PolynomialChaosTrainer)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This is the main trainer base class.
Polynomials and quadratures based on defined distributions for Polynomial Chaos.
std::vector< Real > & _coeff
These are the coefficients we are after in the PC expansion.
void resize(const unsigned int new_m, const unsigned int new_n)
IntRange< T > make_range(T beg, T end)
DenseMatrix< Real > _matrix
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
unsigned int & _ndim
Total number of parameters/dimensions.
static InputParameters validParams()
std::vector< std::unique_ptr< RealCalculator > > _calculators
Calculators used for standardization in linear regression.
PolynomialChaosTrainer(const InputParameters ¶meters)
void ErrorVector unsigned int
dof_id_type getNumberOfCols() const
virtual void preTrain() override