https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ParallelSubsetSimulation Class Reference

A class used to perform Parallel Subset Simulation Sampling. More...

#include <ParallelSubsetSimulation.h>

Inheritance diagram for ParallelSubsetSimulation:
[legend]

Public Types

enum  SampleMode { SampleMode::GLOBAL, SampleMode::LOCAL }
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 ParallelSubsetSimulation (const InputParameters &parameters)
 
const unsigned intgetNumSamplesSub () const
 Access the number samples per subset. More...
 
const bool & getUseAbsoluteValue () const
 Access use absolute value bool. More...
 
const RealgetSubsetProbability () const
 Access the subset probability. More...
 
virtual bool isAdaptiveSamplingCompleted () const override
 Returns true if the adaptive sampling is completed. More...
 
std::vector< RealgetNextLocalRow ()
 
dof_id_type getNumberOfRows () const
 
dof_id_type getNumberOfCols () const
 
dof_id_type getNumberOfLocalRows () const
 
const LocalRankConfiggetRankConfig (bool batch_mode) const
 
libMesh::Parallel::CommunicatorgetLocalComm ()
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (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
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) 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
 
virtual void initialSetup ()
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void residualSetup ()
 
virtual void subdomainSetup ()
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnumgetExecuteOnEnum () const
 
PerfGraphperfGraph ()
 
T & getSampler (const std::string &name)
 
SamplergetSampler (const std::string &name)
 
T & getSamplerByName (const SamplerName &name)
 
SamplergetSamplerByName (const SamplerName &name)
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name) const
 
const VectorPostprocessorName & getVectorPostprocessorName (const std::string &param_name) const
 
DenseMatrix< RealgetGlobalSamples ()
 
DenseMatrix< RealgetGlobalSamples ()
 
DenseMatrix< RealgetLocalSamples ()
 
DenseMatrix< RealgetLocalSamples ()
 
dof_id_type getLocalRowBegin () const
 
dof_id_type getLocalRowBegin () const
 
dof_id_type getLocalRowEnd () const
 
dof_id_type getLocalRowEnd () const
 
const DistributiongetDistribution (const std::string &name) const
 
const T & getDistribution (const std::string &name) const
 
const DistributiongetDistribution (const std::string &name) const
 
const T & getDistribution (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const T & getDistributionByName (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const T & getDistributionByName (const std::string &name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

const ConsoleStream _console
 

Protected Types

enum  CommMethod
 

Protected Member Functions

virtual void sampleSetUp (const Sampler::SampleMode mode) override
 
virtual Real computeSample (dof_id_type row_index, dof_id_type col_index) override
 
void setNumberOfRandomSeeds (std::size_t number)
 
Real getRand (unsigned int index=0)
 
uint32_t getRandl (unsigned int index, uint32_t lower, uint32_t upper)
 
virtual LocalRankConfig constructRankConfig (bool batch_mode) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 
virtual void addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &) const
 
const ReporterNamegetReporterName (const std::string &param_name) const
 
virtual void addReporterDependencyHelper (const ReporterName &)
 
void setNumberOfRows (dof_id_type n_rows)
 
void setNumberOfRows (dof_id_type n_rows)
 
void setNumberOfCols (dof_id_type n_cols)
 
void setNumberOfCols (dof_id_type n_cols)
 
virtual void sampleTearDown (const SampleMode)
 
virtual void sampleTearDown (const SampleMode)
 
virtual void computeSampleMatrix (DenseMatrix< Real > &matrix)
 
virtual void computeSampleMatrix (DenseMatrix< Real > &matrix)
 
virtual void computeLocalSampleMatrix (DenseMatrix< Real > &matrix)
 
virtual void computeLocalSampleMatrix (DenseMatrix< Real > &matrix)
 
virtual void computeSampleRow (dof_id_type i, std::vector< Real > &data)
 
virtual void computeSampleRow (dof_id_type i, std::vector< Real > &data)
 
virtual void advanceGenerators (const dof_id_type count)
 
virtual void advanceGenerators (const dof_id_type count)
 
virtual void advanceGenerator (const unsigned int seed_index, const dof_id_type count)
 
virtual void advanceGenerator (const unsigned int seed_index, const dof_id_type count)
 
void setAutoAdvanceGenerators (const bool state)
 
void setAutoAdvanceGenerators (const bool state)
 
void shuffle (std::vector< T > &data, const std::size_t seed_index=0, const CommMethod method=CommMethod::LOCAL)
 
void shuffle (std::vector< T > &data, const std::size_t seed_index=0, const CommMethod method=CommMethod::LOCAL)
 
virtual void executeSetUp ()
 
virtual void executeSetUp ()
 
virtual void executeTearDown ()
 
virtual void executeTearDown ()
 
void saveGeneratorState ()
 
void saveGeneratorState ()
 
void restoreGeneratorState ()
 
void restoreGeneratorState ()
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 

Protected Attributes

const unsigned int_num_samplessub
 Number of samples per subset. More...
 
const unsigned int_num_subsets
 Number of subsets. More...
 
const bool & _use_absolute_value
 Absolute value of the model result. Use this when failure is defined as a non-exceedance rather than an exceedance. More...
 
const Real_subset_probability
 The subset conditional failure probability. More...
 
const unsigned int_num_random_seeds
 Initialize a certain number of random seeds. Change from the default only if you have to. More...
 
const std::vector< Real > & _outputs
 Reporter value containing calculated outputs. More...
 
const std::vector< std::vector< Real > > & _inputs
 Reporter value containing input values from decision reporter. More...
 
const int_step
 Track the current step of the main App. More...
 
const unsigned int _count_max
 Maximum length of markov chains based on subset probability. More...
 
int _check_step
 Ensure that the MCMC algorithm proceeds in a sequential fashion. More...
 
unsigned int _subset
 Track the current subset index. More...
 
std::vector< Distribution const * > _distributions
 Storage for distribution objects to be utilized. More...
 
bool _is_sampling_completed
 True if the sampling is completed. More...
 
 NONE
 
 LOCAL
 
 SEMI_LOCAL
 
const dof_id_type _min_procs_per_row
 
const dof_id_type _max_procs_per_row
 
libMesh::Parallel::Communicator _local_comm
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
const ExecFlagEnum_execute_enum
 
const ExecFlagType_current_execute_flag
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
const Parallel::Communicator & _communicator
 

Private Attributes

std::vector< std::vector< Real > > _inputs_sto
 Storage for the previously accepted sample inputs across all the subsets. More...
 
std::vector< Real_outputs_sto
 Storage for previously accepted sample outputs across all the subsets. More...
 
std::vector< std::vector< Real > > _inputs_sorted
 Store the sorted input samples according to their corresponding outputs. More...
 
std::vector< std::vector< Real > > _markov_seed
 Mean input vector for the next proposed sample inputs across several processors. More...
 

Detailed Description

A class used to perform Parallel Subset Simulation Sampling.

Definition at line 18 of file ParallelSubsetSimulation.h.

Constructor & Destructor Documentation

◆ ParallelSubsetSimulation()

ParallelSubsetSimulation::ParallelSubsetSimulation ( const InputParameters parameters)

Definition at line 46 of file ParallelSubsetSimulation.C.

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)),
57  _check_step(0),
58  _subset(0),
60 {
61  // Fixing the number of rows to the number of processors
62  const dof_id_type nchains = isParamValid("num_parallel_chains")
63  ? getParam<unsigned int>("num_parallel_chains")
65  setNumberOfRows(nchains);
66  if ((_num_samplessub / nchains) % _count_max > 0)
67  mooseError("Number of model evaluations per chain per subset (",
68  _num_samplessub / nchains,
69  ") should be a multiple of requested chain length (",
70  _count_max,
71  ").");
72 
73  // Filling the `distributions` vector with the user-provided distributions.
74  for (const DistributionName & name : getParam<std::vector<DistributionName>>("distributions"))
76 
77  // Setting the number of columns in the sampler matrix (equal to the number of distributions).
79 
80  /* `inputs_sto` is a member variable that aids in deciding the next set of samples
81  in the Subset Simulation algorithm by storing the input parameter values*/
82  _inputs_sto.resize(_distributions.size(), std::vector<Real>(_num_samplessub, 0.0));
83  _outputs_sto.resize(_num_samplessub, 0.0);
84 
85  /* `inputs_sorted` is a member variable which also aids in deciding the next set of samples
86  in the Subset Simulation algorithm by storing the sorted input parameter values
87  by their corresponding output values*/
88  _inputs_sorted.resize(_distributions.size());
89 
90  /* `markov_seed` is a member variable to store the seed input values for proposing
91  the next set of Markov chain samples.*/
92  _markov_seed.resize(_distributions.size());
93 
95 }
void setNumberOfRows(dof_id_type n_rows)
const std::vector< std::vector< Real > > & _inputs
Reporter value containing input values from decision reporter.
const std::vector< Real > & _outputs
Reporter value containing calculated outputs.
std::vector< Distribution const * > _distributions
Storage for distribution objects to be utilized.
unsigned int _subset
Track the current subset index.
std::vector< Real > _outputs_sto
Storage for previously accepted sample outputs across all the subsets.
int _check_step
Ensure that the MCMC algorithm proceeds in a sequential fashion.
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.
virtual const std::string & name() const
Sampler(const InputParameters &parameters)
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.
const T & getReporterValue(const std::string &param_name, const std::size_t time_index=0)
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 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
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.
const Distribution & getDistributionByName(const DistributionName &name) const
void setNumberOfCols(dof_id_type n_cols)
const Real & _subset_probability
The subset conditional failure probability.
void mooseError(Args &&... args) const
const InputParameters & parameters() const
const unsigned int & _num_samplessub
Number of samples per subset.
uint8_t dof_id_type
void setNumberOfRandomSeeds(std::size_t number)

Member Function Documentation

◆ computeSample()

Real ParallelSubsetSimulation::computeSample ( dof_id_type  row_index,
dof_id_type  col_index 
)
overrideprotectedvirtual

Implements Sampler.

Definition at line 182 of file ParallelSubsetSimulation.C.

183 {
184  unsigned int seed_value = _step > 0 ? (_step - 1) * 2 : 0;
185  Real val;
186 
187  if (_subset == 0)
188  val = getRand(seed_value);
189  else
190  {
191  const dof_id_type loc_ind = row_index - getLocalRowBegin();
192  const Real rv = Normal::quantile(getRand(seed_value), _markov_seed[col_index][loc_ind], 1.0);
193  const Real acceptance_ratio = std::log(Normal::pdf(rv, 0, 1)) -
194  std::log(Normal::pdf(_markov_seed[col_index][loc_ind], 0, 1));
195  const Real new_sample = acceptance_ratio > std::log(getRand(seed_value + 1))
196  ? rv
197  : _markov_seed[col_index][loc_ind];
198  val = Normal::cdf(new_sample, 0, 1);
199  }
200 
201  return _distributions[col_index]->quantile(val);
202 }
virtual Real cdf(const Real &x) const override
Definition: Normal.C:74
std::vector< Distribution const * > _distributions
Storage for distribution objects to be utilized.
unsigned int _subset
Track the current subset index.
dof_id_type getLocalRowBegin() const
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 Real pdf(const Real &x) const override
Definition: Normal.C:68
const int & _step
Track the current step of the main App.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real quantile(const Real &p) const override
Definition: Normal.C:80
uint8_t dof_id_type

◆ getNumSamplesSub()

const unsigned int & ParallelSubsetSimulation::getNumSamplesSub ( ) const

Access the number samples per subset.

Definition at line 98 of file ParallelSubsetSimulation.C.

Referenced by AdaptiveMonteCarloDecision::AdaptiveMonteCarloDecision(), and AdaptiveMonteCarloDecision::execute().

99 {
100  return _num_samplessub;
101 }
const unsigned int & _num_samplessub
Number of samples per subset.

◆ getSubsetProbability()

const Real & ParallelSubsetSimulation::getSubsetProbability ( ) const

Access the subset probability.

Definition at line 110 of file ParallelSubsetSimulation.C.

Referenced by AdaptiveMonteCarloDecision::execute().

111 {
112  return _subset_probability;
113 }
const Real & _subset_probability
The subset conditional failure probability.

◆ getUseAbsoluteValue()

const bool & ParallelSubsetSimulation::getUseAbsoluteValue ( ) const

Access use absolute value bool.

Definition at line 104 of file ParallelSubsetSimulation.C.

Referenced by AdaptiveMonteCarloDecision::execute().

105 {
106  return _use_absolute_value;
107 }
const bool & _use_absolute_value
Absolute value of the model result. Use this when failure is defined as a non-exceedance rather than ...

◆ isAdaptiveSamplingCompleted()

virtual bool ParallelSubsetSimulation::isAdaptiveSamplingCompleted ( ) const
inlineoverridevirtual

Returns true if the adaptive sampling is completed.

Reimplemented from Sampler.

Definition at line 37 of file ParallelSubsetSimulation.h.

37 { return _is_sampling_completed; }
bool _is_sampling_completed
True if the sampling is completed.

◆ sampleSetUp()

void ParallelSubsetSimulation::sampleSetUp ( const Sampler::SampleMode  mode)
overrideprotectedvirtual

Reimplemented from Sampler.

Definition at line 116 of file ParallelSubsetSimulation.C.

117 {
118  if (_step <= 1 || _check_step == _step)
119  return;
120  _check_step = _step;
121 
123  mooseError("Internal bug: the adaptive sampling is supposed to be completed but another sample "
124  "has been requested.");
125 
127  const unsigned int sub_ind = (_step - 1) - (_num_samplessub / getNumberOfRows()) * _subset;
128  const unsigned int offset = sub_ind * getNumberOfRows();
129 
130  // Get and store the accepted samples input across all the procs from the previous step
131  for (dof_id_type j = 0; j < _distributions.size(); ++j)
132  for (dof_id_type ss = 0; ss < getNumberOfRows(); ++ss)
133  _inputs_sto[j][ss + offset] = Normal::quantile(_distributions[j]->cdf(_inputs[j][ss]), 0, 1);
134 
135  // Get the accepted sample outputs across all the procs from the previous step
136  std::vector<Real> tmp =
138  if (mode == Sampler::SampleMode::GLOBAL)
140  else
141  _local_comm.allgather(tmp);
142  for (dof_id_type ss = 0; ss < getNumberOfRows(); ++ss)
143  _outputs_sto[ss + offset] = tmp[ss];
144 
145  // These are the subsequent subsets which use Markov Chain Monte Carlo sampling scheme
146  if (_subset > 0)
147  {
148  // Check whether the subset index has changed
149  if (sub_ind == 0)
150  {
151  // _inputs_sorted contains the input values corresponding to the largest po percentile
152  // output values
155  }
156 
157  // Reinitialize the starting inputs values for the next set of Markov chains
158  if (sub_ind % _count_max == 0)
159  {
160  const unsigned int soffset = (sub_ind / _count_max) * getNumberOfRows();
161  for (dof_id_type j = 0; j < _distributions.size(); ++j)
162  _markov_seed[j].assign(_inputs_sorted[j].begin() + soffset + getLocalRowBegin(),
163  _inputs_sorted[j].begin() + soffset + getLocalRowEnd());
164  }
165  // Otherwise, use the previously accepted input values to propose the next set of input
166  // values
167  else
168  {
169  for (dof_id_type j = 0; j < _distributions.size(); ++j)
170  _markov_seed[j].assign(_inputs_sto[j].begin() + offset + getLocalRowBegin(),
171  _inputs_sto[j].begin() + offset + getLocalRowEnd());
172  }
173  }
174 
175  // check if we have completed the last sample (sub_ind == _num_samplessub /getNumberOfRows() - 1)
176  // of the last subset (_subset == _num_subsets - 1)
177  if (_subset == _num_subsets - 1 && sub_ind == _num_samplessub / getNumberOfRows() - 1)
178  _is_sampling_completed = true;
179 }
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.
const std::vector< Real > & _outputs
Reporter value containing calculated outputs.
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.
unsigned int _subset
Track the current subset index.
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
std::vector< std::vector< Real > > _markov_seed
Mean input vector for the next proposed sample inputs across several processors.
std::vector< std::vector< Real > > _inputs_sorted
Store the sorted input samples according to their corresponding outputs.
const unsigned int & _num_subsets
Number of subsets.
bool _is_sampling_completed
True if the sampling is completed.
const int & _step
Track the current step of the main App.
const bool & _use_absolute_value
Absolute value of the model result. Use this when failure is defined as a non-exceedance rather than ...
dof_id_type getLocalRowEnd() const
libMesh::Parallel::Communicator _local_comm
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
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")
const unsigned int & _num_samplessub
Number of samples per subset.
virtual Real quantile(const Real &p) const override
Definition: Normal.C:80
uint8_t dof_id_type

◆ validParams()

InputParameters ParallelSubsetSimulation::validParams ( )
static

Definition at line 18 of file ParallelSubsetSimulation.C.

19 {
21  params.addClassDescription("Parallel Subset Simulation sampler.");
22  params.addRequiredParam<std::vector<DistributionName>>(
23  "distributions",
24  "The distribution names to be sampled, the number of distributions provided defines the "
25  "number of columns per matrix.");
26  params.addRequiredParam<ReporterName>("output_reporter",
27  "Reporter with results of samples created by the SubApp.");
28  params.addRequiredParam<ReporterName>("inputs_reporter", "Reporter with input parameters.");
29  params.addRangeCheckedParam<Real>("subset_probability",
30  0.1,
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");
39  params.addParam<unsigned int>(
40  "num_random_seeds",
41  100000,
42  "Initialize a certain number of random seeds. Change from the default only if you have to.");
43  return params;
44 }
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)

Member Data Documentation

◆ _check_step

int ParallelSubsetSimulation::_check_step
protected

Ensure that the MCMC algorithm proceeds in a sequential fashion.

Definition at line 71 of file ParallelSubsetSimulation.h.

Referenced by sampleSetUp().

◆ _count_max

const unsigned int ParallelSubsetSimulation::_count_max
protected

Maximum length of markov chains based on subset probability.

Definition at line 68 of file ParallelSubsetSimulation.h.

Referenced by ParallelSubsetSimulation(), and sampleSetUp().

◆ _distributions

std::vector<Distribution const *> ParallelSubsetSimulation::_distributions
protected

Storage for distribution objects to be utilized.

Definition at line 77 of file ParallelSubsetSimulation.h.

Referenced by computeSample(), ParallelSubsetSimulation(), and sampleSetUp().

◆ _inputs

const std::vector<std::vector<Real> >& ParallelSubsetSimulation::_inputs
protected

Reporter value containing input values from decision reporter.

Definition at line 62 of file ParallelSubsetSimulation.h.

Referenced by sampleSetUp().

◆ _inputs_sorted

std::vector<std::vector<Real> > ParallelSubsetSimulation::_inputs_sorted
private

Store the sorted input samples according to their corresponding outputs.

Definition at line 90 of file ParallelSubsetSimulation.h.

Referenced by ParallelSubsetSimulation(), and sampleSetUp().

◆ _inputs_sto

std::vector<std::vector<Real> > ParallelSubsetSimulation::_inputs_sto
private

Storage for the previously accepted sample inputs across all the subsets.

Definition at line 84 of file ParallelSubsetSimulation.h.

Referenced by ParallelSubsetSimulation(), and sampleSetUp().

◆ _is_sampling_completed

bool ParallelSubsetSimulation::_is_sampling_completed
protected

True if the sampling is completed.

Definition at line 80 of file ParallelSubsetSimulation.h.

Referenced by isAdaptiveSamplingCompleted(), and sampleSetUp().

◆ _markov_seed

std::vector<std::vector<Real> > ParallelSubsetSimulation::_markov_seed
private

Mean input vector for the next proposed sample inputs across several processors.

Definition at line 93 of file ParallelSubsetSimulation.h.

Referenced by computeSample(), ParallelSubsetSimulation(), and sampleSetUp().

◆ _num_random_seeds

const unsigned int& ParallelSubsetSimulation::_num_random_seeds
protected

Initialize a certain number of random seeds. Change from the default only if you have to.

Definition at line 56 of file ParallelSubsetSimulation.h.

Referenced by ParallelSubsetSimulation().

◆ _num_samplessub

const unsigned int& ParallelSubsetSimulation::_num_samplessub
protected

Number of samples per subset.

Definition at line 44 of file ParallelSubsetSimulation.h.

Referenced by getNumSamplesSub(), ParallelSubsetSimulation(), and sampleSetUp().

◆ _num_subsets

const unsigned int& ParallelSubsetSimulation::_num_subsets
protected

Number of subsets.

Definition at line 47 of file ParallelSubsetSimulation.h.

Referenced by sampleSetUp().

◆ _outputs

const std::vector<Real>& ParallelSubsetSimulation::_outputs
protected

Reporter value containing calculated outputs.

Definition at line 59 of file ParallelSubsetSimulation.h.

Referenced by sampleSetUp().

◆ _outputs_sto

std::vector<Real> ParallelSubsetSimulation::_outputs_sto
private

Storage for previously accepted sample outputs across all the subsets.

Definition at line 87 of file ParallelSubsetSimulation.h.

Referenced by ParallelSubsetSimulation(), and sampleSetUp().

◆ _step

const int& ParallelSubsetSimulation::_step
protected

Track the current step of the main App.

Definition at line 65 of file ParallelSubsetSimulation.h.

Referenced by computeSample(), and sampleSetUp().

◆ _subset

unsigned int ParallelSubsetSimulation::_subset
protected

Track the current subset index.

Definition at line 74 of file ParallelSubsetSimulation.h.

Referenced by computeSample(), and sampleSetUp().

◆ _subset_probability

const Real& ParallelSubsetSimulation::_subset_probability
protected

The subset conditional failure probability.

Definition at line 53 of file ParallelSubsetSimulation.h.

Referenced by getSubsetProbability(), and sampleSetUp().

◆ _use_absolute_value

const bool& ParallelSubsetSimulation::_use_absolute_value
protected

Absolute value of the model result. Use this when failure is defined as a non-exceedance rather than an exceedance.

Definition at line 50 of file ParallelSubsetSimulation.h.

Referenced by getUseAbsoluteValue(), and sampleSetUp().


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