24 "The distribution names to be sampled, the number of distributions provided defines the " 25 "number of columns per matrix.");
27 "Reporter with results of samples created by the SubApp.");
31 "subset_probability>0 & subset_probability<=1",
32 "Conditional probability of each subset");
33 params.
addRequiredParam<
unsigned int>(
"num_samplessub",
"Number of samples per subset");
34 params.
addRequiredParam<
unsigned int>(
"num_subsets",
"Number of desired subsets");
35 params.
addParam<
unsigned int>(
"num_parallel_chains",
36 "Number of Markov chains to run in parallel, default is based on " 37 "the number of processors used.");
38 params.
addParam<
bool>(
"use_absolute_value",
false,
"Use absolute value of the sub app output");
42 "Initialize a certain number of random seeds. Change from the default only if you have to.");
48 _num_samplessub(getParam<unsigned
int>(
"num_samplessub")),
49 _num_subsets(getParam<unsigned
int>(
"num_subsets")),
50 _use_absolute_value(getParam<bool>(
"use_absolute_value")),
51 _subset_probability(getParam<
Real>(
"subset_probability")),
52 _num_random_seeds(getParam<unsigned
int>(
"num_random_seeds")),
53 _outputs(getReporterValue<
std::vector<
Real>>(
"output_reporter")),
54 _inputs(getReporterValue<
std::vector<
std::vector<
Real>>>(
"inputs_reporter")),
55 _step(getCheckedPointerParam<
FEProblemBase *>(
"_fe_problem_base")->timeStep()),
56 _count_max(
std::floor(1 / _subset_probability)),
59 _is_sampling_completed(false)
63 ? getParam<unsigned int>(
"num_parallel_chains")
67 mooseError(
"Number of model evaluations per chain per subset (",
69 ") should be a multiple of requested chain length (",
74 for (
const DistributionName &
name :
getParam<std::vector<DistributionName>>(
"distributions"))
123 mooseError(
"Internal bug: the adaptive sampling is supposed to be completed but another sample " 124 "has been requested.");
136 std::vector<Real> tmp =
184 unsigned int seed_value =
_step > 0 ? (
_step - 1) * 2 : 0;
195 const Real new_sample = acceptance_ratio > std::log(
getRand(seed_value + 1))
void setNumberOfRows(dof_id_type n_rows)
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
const std::vector< std::vector< Real > > & _inputs
Reporter value containing input values from decision reporter.
virtual Real cdf(const Real &x) const override
const std::vector< Real > & _outputs
Reporter value containing calculated outputs.
static InputParameters validParams()
A class used to perform Parallel Subset Simulation Sampling.
std::vector< Distribution const * > _distributions
Storage for distribution objects to be utilized.
std::vector< Real > computeVectorABS(const std::vector< Real > &data)
return the absolute values in a vector.
registerMooseObject("StochasticToolsApp", ParallelSubsetSimulation)
unsigned int _subset
Track the current subset index.
const bool & getUseAbsoluteValue() const
Access use absolute value bool.
virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override
std::vector< Real > _outputs_sto
Storage for previously accepted sample outputs across all the subsets.
dof_id_type getLocalRowBegin() const
int _check_step
Ensure that the MCMC algorithm proceeds in a sequential fashion.
const Parallel::Communicator & _communicator
const unsigned int & _num_random_seeds
Initialize a certain number of random seeds. Change from the default only if you have to...
std::vector< std::vector< Real > > _markov_seed
Mean input vector for the next proposed sample inputs across several processors.
Real getRand(unsigned int index=0)
virtual const std::string & name() const
virtual Real pdf(const Real &x) const override
std::vector< std::vector< Real > > _inputs_sorted
Store the sorted input samples according to their corresponding outputs.
bool isParamValid(const std::string &name) const
const unsigned int & _num_subsets
Number of subsets.
bool _is_sampling_completed
True if the sampling is completed.
processor_id_type n_processors() const
const int & _step
Track the current step of the main App.
const unsigned int & getNumSamplesSub() const
Access the number samples per subset.
const bool & _use_absolute_value
Absolute value of the model result. Use this when failure is defined as a non-exceedance rather than ...
const T & getParam(const std::string &name) const
ParallelSubsetSimulation(const InputParameters ¶meters)
const Real & getSubsetProbability() const
Access the subset probability.
dof_id_type getLocalRowEnd() const
libMesh::Parallel::Communicator _local_comm
const dof_id_type _min_procs_per_row
const unsigned int _count_max
Maximum length of markov chains based on subset probability.
std::vector< std::vector< Real > > _inputs_sto
Storage for the previously accepted sample inputs across all the subsets.
dof_id_type getNumberOfRows() const
const Distribution & getDistributionByName(const DistributionName &name) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void setNumberOfCols(dof_id_type n_cols)
std::vector< std::vector< Real > > sortInput(const std::vector< std::vector< Real >> &inputs, const std::vector< Real > &outputs, const unsigned int samplessub, const Real subset_prob)
return input values corresponding to the largest po percentile output values.
const Real & _subset_probability
The subset conditional failure probability.
void mooseError(Args &&... args) const
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
static InputParameters validParams()
const unsigned int & _num_samplessub
Number of samples per subset.
virtual Real quantile(const Real &p) const override
void ErrorVector unsigned int
virtual void sampleSetUp(const Sampler::SampleMode mode) override
void setNumberOfRandomSeeds(std::size_t number)