25 "The distribution names to be sampled, the number of distributions provided defines the " 26 "number of columns per matrix.");
29 "Standard deviations of the proposal distributions");
32 "initial_values",
"Initial input values to get the importance sampler started");
35 "num_samples_train>0",
36 "Number of samples to learn the importance distribution");
38 "num_importance_sampling_steps",
39 "num_importance_sampling_steps>0",
40 "Number of importance sampling steps (after the importance distribution has been trained)");
42 "std_factor",
"Factor to be multiplied to the standard deviation of the importance samples");
43 params.
addParam<
bool>(
"use_absolute_value",
false,
"Use absolute value of the sub app output");
47 "Initialize a certain number of random seeds. Change from the default only if you have to.");
49 "Flag samples if the surrogate prediction was inadequate.");
56 _proposal_std(getParam<
std::vector<
Real>>(
"proposal_std")),
57 _initial_values(getParam<
std::vector<
Real>>(
"initial_values")),
58 _output_limit(getParam<
Real>(
"output_limit")),
59 _num_samples_train(getParam<
int>(
"num_samples_train")),
60 _num_importance_sampling_steps(getParam<
int>(
"num_importance_sampling_steps")),
61 _std_factor(getParam<
Real>(
"std_factor")),
62 _use_absolute_value(getParam<bool>(
"use_absolute_value")),
63 _num_random_seeds(getParam<unsigned
int>(
"num_random_seeds")),
64 _is_sampling_completed(false),
65 _inputs(getReporterValue<
std::vector<
std::vector<
Real>>>(
"inputs_reporter")),
67 _gp_flag(isParamValid(
"flag_sample") ? &getReporterValue<
std::vector<bool>>(
"flag_sample")
71 for (
const DistributionName &
name :
getParam<std::vector<DistributionName>>(
"distributions"))
114 const bool gp_flag =
_gp_flag ? (*_gp_flag)[0] :
false;
117 mooseError(
"Internal bug: the adaptive sampling is supposed to be completed but another sample " 118 "has been requested.");
128 if (sample && !gp_flag)
132 Real acceptance_ratio = 0.0;
151 else if (sample && !gp_flag)
void setNumberOfRows(dof_id_type n_rows)
int _retraining_steps
Number of retraining performed.
int _check_step
Ensure that the MCMC algorithm proceeds in a sequential fashion.
virtual Real cdf(const Real &x) const override
static InputParameters validParams()
A class used to perform Adaptive Importance Sampling using a Markov Chain Monte Carlo algorithm...
bool _is_sampling_completed
True if the sampling is completed.
std::vector< const Distribution * > _distributions
Storage for distribution objects to be utilized.
virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override
Return the sample for the given row (the sample index) and column (the parameter index) ...
std::vector< std::vector< Real > > _inputs_sto
Storage for previously accepted samples by the decision reporter system.
Real computeMean(const std::vector< Real > &data, const unsigned int &start_index)
compute the mean of a data vector by only considering values from a specific index.
Real getRand(unsigned int index=0)
virtual const std::string & name() const
const std::vector< std::vector< Real > > & _inputs
Storage for the inputs vector obtained from the reporter.
virtual Real pdf(const Real &x) const override
std::vector< Real > _std_sto
Storage for standard deviations of input values for proposing the next sample.
AdaptiveImportanceSampler(const InputParameters ¶meters)
const int & _num_samples_train
Number of samples to train the importance sampler.
const unsigned int & _num_random_seeds
Initialize a certain number of random seeds. Change from the default only if you have to...
const T & getParam(const std::string &name) const
const int & _num_importance_sampling_steps
Number of importance sampling steps (after the importance distribution has been trained) ...
registerMooseObjectAliased("StochasticToolsApp", AdaptiveImportanceSampler, "AdaptiveImportance")
Real computeSTD(const std::vector< Real > &data, const unsigned int &start_index)
compute the standard deviation of a data vector by only considering values from a specific index...
const Real & _std_factor
Factor to be multiplied to the standard deviation of the proposal distribution.
const Distribution & getDistributionByName(const DistributionName &name) const
std::vector< Real > _mean_sto
Storage for means of input values for proposing the next sample.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void setNumberOfCols(dof_id_type n_cols)
const std::vector< bool > *const _gp_flag
Indicate whether GP prediction is good or bad to influence next proposed sample.
void mooseError(Args &&... args) const
const std::vector< Real > & _initial_values
Initial values values vector to start the importance sampler.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const std::vector< Real > & _proposal_std
The proposal distribution standard deviations.
static InputParameters validParams()
virtual Real quantile(const Real &p) const override
void ErrorVector unsigned int
std::vector< Real > _prev_value
For proposing the next sample in the MCMC algorithm.
void setNumberOfRandomSeeds(std::size_t number)