https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | 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
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 ParallelSubsetSimulation (const InputParameters &parameters)
 
const unsigned intgetNumSamplesSub () const
 Access the number samples per subset.
 
const bool & getUseAbsoluteValue () const
 Access use absolute value bool.
 
const Real & getSubsetProbability () const
 Access the subset probability.
 
virtual bool isAdaptiveSamplingCompleted () const override
 Returns true if the adaptive sampling is completed.
 
std::vector< Real > getNextLocalRow ()
 
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
 
bool isKokkosObject () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (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
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) 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 ()
 
TgetSampler (const std::string &name)
 
SamplergetSampler (const std::string &name)
 
TgetSamplerByName (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< Real > getGlobalSamples ()
 
DenseMatrix< Real > getGlobalSamples ()
 
DenseMatrix< Real > getLocalSamples ()
 
DenseMatrix< Real > getLocalSamples ()
 
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 TgetDistribution (const std::string &name) const
 
const DistributiongetDistribution (const std::string &name) const
 
const TgetDistribution (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const TgetDistributionByName (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const TgetDistributionByName (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 ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 

Protected Member Functions

virtual void executeSetUp () override
 
virtual Real computeSample (dof_id_type row_index, dof_id_type col_index) override
 
void setNumberOfRandomSeeds (std::size_t number)
 
Real getRand (std::size_t n, unsigned int index=0) const
 
unsigned int getRandl (std::size_t n, unsigned int lower, unsigned int upper, unsigned int index=0) const
 
virtual LocalRankConfig constructRankConfig (bool batch_mode) const
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) 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 ReporterContextBasegetReporterContextBaseByName (const ReporterName &reporter_name) 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 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)
 
virtual void executeTearDown ()
 
virtual void executeTearDown ()
 
const TgetReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const TgetReporterValueByName (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.
 
const unsigned int_num_subsets
 Number of subsets.
 
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.
 
const Real & _subset_probability
 The subset conditional failure probability.
 
const unsigned int_num_random_seeds
 Initialize a certain number of random seeds. Change from the default only if you have to.
 
const std::vector< Real > & _outputs
 Reporter value containing calculated outputs.
 
const std::vector< std::vector< Real > > & _inputs
 Reporter value containing input values from decision reporter.
 
const int_step
 Track the current step of the main App.
 
const unsigned int _count_max
 Maximum length of markov chains based on subset probability.
 
unsigned int _subset
 Track the current subset index.
 
std::vector< Distribution const * > _distributions
 Storage for distribution objects to be utilized.
 
bool _is_sampling_completed
 True if the sampling is completed.
 
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
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
const ExecFlagEnum_execute_enum
 
const ExecFlagType_current_execute_flag
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
const Parallel::Communicator & _communicator
 

Private Member Functions

void execute ()
 
void checkReinitStatus () const
 
void advanceGeneratorsInternal (const dof_id_type count)
 
const VectorPostprocessorValuegetVectorPostprocessorByNameHelper (const VectorPostprocessorName &name, const std::string &vector_name, bool broadcast, std::size_t t_index) const
 
const VectorPostprocessorContext< VectorPostprocessorValue > & getVectorPostprocessorContextByNameHelper (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool vectorPostprocessorsAdded () const
 
bool reportersAdded () const
 
void possiblyCheckHasReporter (const ReporterName &reporter_name, const std::string &param_name="") const
 
void init ()
 
void init ()
 
void reinit ()
 
void reinit ()
 
void possiblyCheckHasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

std::vector< std::vector< Real > > _inputs_sto
 Storage for the previously accepted sample inputs across all the subsets.
 
std::vector< Real > _outputs_sto
 Storage for previously accepted sample outputs across all the subsets.
 
std::vector< std::vector< Real > > _inputs_sorted
 Store the sorted input samples according to their corresponding outputs.
 
std::vector< std::vector< Real > > _markov_seed
 Mean input vector for the next proposed sample inputs across several processors.
 
std::vector< std::unique_ptr< MooseRandomStateless > > _generators
 
dof_id_type _n_local_rows
 
dof_id_type _local_row_begin
 
dof_id_type _local_row_end
 
dof_id_type _n_rows
 
dof_id_type _n_cols
 
std::size_t _n_seeds
 
dof_id_type _next_local_row
 
bool _next_local_row_requires_state_restore
 
bool _initialized
 
bool _needs_reinit
 
bool _has_executed
 
const dof_id_type _limit_get_global_samples
 
const dof_id_type _limit_get_local_samples
 
const dof_id_type _limit_get_next_local_row
 
std::pair< LocalRankConfig, LocalRankConfig_rank_config
 
bool _auto_advance_generators
 
const ParallelParamObject_parent
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 
ExecFlagEnum _empty_execute_enum
 
const InputParameters_dni_params
 
FEProblemBase_dni_feproblem
 
const MooseObject *const _dni_moose_object_ptr
 
const InputParameters_si_params
 
FEProblemBase_si_feproblem
 
THREAD_ID _si_tid
 
const bool _broadcast_by_default
 
const MooseObject_vpi_moose_object
 
const FEProblemBase_vpi_feproblem
 
const THREAD_ID _vpi_tid
 
const InputParameters_ri_params
 
FEProblemBase_ri_fe_problem_base
 
const ReporterData_ri_reporter_data
 
const MooseObject_ri_moose_object
 

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 _subset(0),
59{
60 // Fixing the number of rows to the number of processors
61 const dof_id_type nchains = isParamValid("num_parallel_chains")
62 ? getParam<unsigned int>("num_parallel_chains")
64 setNumberOfRows(nchains);
65 if ((_num_samplessub / nchains) % _count_max > 0)
66 mooseError("Number of model evaluations per chain per subset (",
67 _num_samplessub / nchains,
68 ") should be a multiple of requested chain length (",
70 ").");
71
72 // Filling the `distributions` vector with the user-provided distributions.
73 for (const DistributionName & name : getParam<std::vector<DistributionName>>("distributions"))
75
76 // Setting the number of columns in the sampler matrix (equal to the number of distributions).
78
79 /* `inputs_sto` is a member variable that aids in deciding the next set of samples
80 in the Subset Simulation algorithm by storing the input parameter values*/
81 _inputs_sto.resize(_distributions.size(), std::vector<Real>(_num_samplessub, 0.0));
82 _outputs_sto.resize(_num_samplessub, 0.0);
83
84 /* `inputs_sorted` is a member variable which also aids in deciding the next set of samples
85 in the Subset Simulation algorithm by storing the sorted input parameter values
86 by their corresponding output values*/
87 _inputs_sorted.resize(_distributions.size());
88
89 /* `markov_seed` is a member variable to store the seed input values for proposing
90 the next set of Markov chain samples.*/
91 _markov_seed.resize(_distributions.size());
92
95}
const Distribution & getDistributionByName(const DistributionName &name) const
const InputParameters & parameters() const
const std::string & name() const
void mooseError(Args &&... args) const
const T & getParam(const std::string &name) const
bool isParamValid(const std::string &name) const
const bool & _use_absolute_value
Absolute value of the model result. Use this when failure is defined as a non-exceedance rather than ...
const std::vector< Real > & _outputs
Reporter value containing calculated outputs.
const unsigned int & _num_random_seeds
Initialize a certain number of random seeds. Change from the default only if you have to.
bool _is_sampling_completed
True if the sampling is completed.
const int & _step
Track the current step of the main App.
const std::vector< std::vector< Real > > & _inputs
Reporter value containing input values from decision reporter.
const unsigned int & _num_samplessub
Number of samples per subset.
const unsigned int _count_max
Maximum length of markov chains based on subset probability.
const Real & _subset_probability
The subset conditional failure probability.
std::vector< Distribution const * > _distributions
Storage for distribution objects to be utilized.
std::vector< std::vector< Real > > _markov_seed
Mean input vector for the next proposed sample inputs across several processors.
std::vector< Real > _outputs_sto
Storage for previously accepted sample outputs across all the subsets.
const unsigned int & _num_subsets
Number of subsets.
std::vector< std::vector< Real > > _inputs_sto
Storage for the previously accepted sample inputs across all the subsets.
std::vector< std::vector< Real > > _inputs_sorted
Store the sorted input samples according to their corresponding outputs.
unsigned int _subset
Track the current subset index.
const T & getReporterValue(const std::string &param_name, const std::size_t time_index=0)
void setNumberOfCols(dof_id_type n_cols)
void setAutoAdvanceGenerators(const bool state)
void setNumberOfRows(dof_id_type n_rows)
const dof_id_type _min_procs_per_row
void setNumberOfRandomSeeds(std::size_t number)
processor_id_type n_processors() const
uint8_t dof_id_type

Member Function Documentation

◆ computeSample()

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

Implements Sampler.

Definition at line 179 of file ParallelSubsetSimulation.C.

180{
181 unsigned int seed_value = _step > 0 ? (_step - 1) * 2 : 0;
182 const dof_id_type n = row_index * getNumberOfCols() + col_index;
183 Real val;
184
185 if (_subset == 0)
186 val = getRand(n, seed_value);
187 else
188 {
189 const Real rv =
190 Normal::quantile(getRand(n, seed_value), _markov_seed[col_index][row_index], 1.0);
191 const Real acceptance_ratio = std::log(Normal::pdf(rv, 0, 1)) -
192 std::log(Normal::pdf(_markov_seed[col_index][row_index], 0, 1));
193 const Real new_sample = acceptance_ratio > std::log(getRand(n, seed_value + 1))
194 ? rv
195 : _markov_seed[col_index][row_index];
196 val = Normal::cdf(new_sample, 0, 1);
197 }
198
199 return _distributions[col_index]->quantile(val);
200}
virtual Real cdf(const Real &x) const override
Definition Normal.C:74
virtual Real pdf(const Real &x) const override
Definition Normal.C:68
virtual Real quantile(const Real &p) const override
Definition Normal.C:80
Real getRand(std::size_t n, unsigned int index=0) const
dof_id_type getNumberOfCols() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ executeSetUp()

void ParallelSubsetSimulation::executeSetUp ( )
overrideprotectedvirtual

Reimplemented from Sampler.

Definition at line 116 of file ParallelSubsetSimulation.C.

117{
119 mooseError("Internal bug: the adaptive sampling is supposed to be completed but another sample "
120 "has been requested.");
121
123 const unsigned int sub_ind = _step - (_num_samplessub / getNumberOfRows()) * _subset;
124 const unsigned int offset = sub_ind * getNumberOfRows();
125
126 // check if we have completed the last sample
127 if (_subset >= _num_subsets)
128 {
130 return;
131 }
132
133 // Get and store the accepted samples input across all the procs from the previous step
134 for (dof_id_type j = 0; j < _distributions.size(); ++j)
135 for (dof_id_type ss = 0; ss < getNumberOfRows(); ++ss)
136 _inputs_sto[j][ss + offset] = Normal::quantile(_distributions[j]->cdf(_inputs[j][ss]), 0, 1);
137
138 // Get the accepted sample outputs across all the procs from the previous step
139 std::vector<Real> tmp =
142 if (tmp.empty())
143 tmp.resize(getNumberOfRows(), 0.0);
144 for (dof_id_type ss = 0; ss < getNumberOfRows(); ++ss)
145 _outputs_sto[ss + offset] = tmp[ss];
146
147 // These are the subsequent subsets which use Markov Chain Monte Carlo sampling scheme
148 if (_subset > 0)
149 {
150 // Check whether the subset index has changed
151 if (sub_ind == 0)
152 {
153 // _inputs_sorted contains the input values corresponding to the largest po percentile
154 // output values
157 }
158
159 // Reinitialize the starting inputs values for the next set of Markov chains
160 if (sub_ind % _count_max == 0)
161 {
162 const unsigned int soffset = (sub_ind / _count_max) * getNumberOfRows();
163 for (dof_id_type j = 0; j < _distributions.size(); ++j)
164 _markov_seed[j].assign(_inputs_sorted[j].begin() + soffset,
165 _inputs_sorted[j].begin() + soffset + getNumberOfRows());
166 }
167 // Otherwise, use the previously accepted input values to propose the next set of input
168 // values
169 else
170 {
171 for (dof_id_type j = 0; j < _distributions.size(); ++j)
172 _markov_seed[j].assign(_inputs_sto[j].begin() + offset,
173 _inputs_sto[j].begin() + offset + getNumberOfRows());
174 }
175 }
176}
dof_id_type getNumberOfRows() const
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
const Parallel::Communicator & _communicator
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.
std::vector< Real > computeVectorABS(const std::vector< Real > &data)
return the absolute values in a vector.

◆ getNumSamplesSub()

const unsigned int & ParallelSubsetSimulation::getNumSamplesSub ( ) const

Access the number samples per subset.

Definition at line 98 of file ParallelSubsetSimulation.C.

99{
100 return _num_samplessub;
101}

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

◆ getSubsetProbability()

const Real & ParallelSubsetSimulation::getSubsetProbability ( ) const

Access the subset probability.

Definition at line 110 of file ParallelSubsetSimulation.C.

111{
112 return _subset_probability;
113}

Referenced by AdaptiveMonteCarloDecision::execute().

◆ getUseAbsoluteValue()

const bool & ParallelSubsetSimulation::getUseAbsoluteValue ( ) const

Access use absolute value bool.

Definition at line 104 of file ParallelSubsetSimulation.C.

105{
106 return _use_absolute_value;
107}

Referenced by AdaptiveMonteCarloDecision::execute().

◆ 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; }

◆ 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}
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
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)
static InputParameters validParams()

Member Data Documentation

◆ _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 executeSetUp(), and ParallelSubsetSimulation().

◆ _distributions

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

Storage for distribution objects to be utilized.

Definition at line 74 of file ParallelSubsetSimulation.h.

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

◆ _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 executeSetUp().

◆ _inputs_sorted

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

Store the sorted input samples according to their corresponding outputs.

Definition at line 87 of file ParallelSubsetSimulation.h.

Referenced by executeSetUp(), and ParallelSubsetSimulation().

◆ _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 81 of file ParallelSubsetSimulation.h.

Referenced by executeSetUp(), and ParallelSubsetSimulation().

◆ _is_sampling_completed

bool ParallelSubsetSimulation::_is_sampling_completed
protected

True if the sampling is completed.

Definition at line 77 of file ParallelSubsetSimulation.h.

Referenced by executeSetUp(), and isAdaptiveSamplingCompleted().

◆ _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 90 of file ParallelSubsetSimulation.h.

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

◆ _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 executeSetUp(), getNumSamplesSub(), and ParallelSubsetSimulation().

◆ _num_subsets

const unsigned int& ParallelSubsetSimulation::_num_subsets
protected

Number of subsets.

Definition at line 47 of file ParallelSubsetSimulation.h.

Referenced by executeSetUp().

◆ _outputs

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

Reporter value containing calculated outputs.

Definition at line 59 of file ParallelSubsetSimulation.h.

Referenced by executeSetUp().

◆ _outputs_sto

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

Storage for previously accepted sample outputs across all the subsets.

Definition at line 84 of file ParallelSubsetSimulation.h.

Referenced by executeSetUp(), and ParallelSubsetSimulation().

◆ _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 executeSetUp().

◆ _subset

unsigned int ParallelSubsetSimulation::_subset
protected

Track the current subset index.

Definition at line 71 of file ParallelSubsetSimulation.h.

Referenced by computeSample(), and executeSetUp().

◆ _subset_probability

const Real& ParallelSubsetSimulation::_subset_probability
protected

The subset conditional failure probability.

Definition at line 53 of file ParallelSubsetSimulation.h.

Referenced by executeSetUp(), and getSubsetProbability().

◆ _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 executeSetUp(), and getUseAbsoluteValue().


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