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
AdaptiveImportanceSampler Class Reference

A class used to perform Adaptive Importance Sampling using a Markov Chain Monte Carlo algorithm. More...

#include <AdaptiveImportanceSampler.h>

Inheritance diagram for AdaptiveImportanceSampler:
[legend]

Public Types

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

Public Member Functions

 AdaptiveImportanceSampler (const InputParameters &parameters)
 
const std::vector< Real > & getInitialValues () const
 
const intgetNumSamplesTrain () const
 
const bool & getUseAbsoluteValue () const
 
const RealgetOutputLimit () const
 
const std::vector< Real > & getImportanceVectorMean () const
 
const std::vector< Real > & getImportanceVectorStd () const
 
const std::vector< const Distribution * > & getDistributionNames () const
 
const RealgetStdFactor () const
 
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
 
bool isImplicit ()
 
Moose::StateArg determineState () const
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

const ConsoleStream _console
 

Protected Types

enum  CommMethod
 

Protected Member Functions

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) More...
 
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 sampleSetUp (const SampleMode)
 
virtual void sampleSetUp (const SampleMode)
 
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

std::vector< const Distribution * > _distributions
 Storage for distribution objects to be utilized. More...
 
const std::vector< Real > & _proposal_std
 The proposal distribution standard deviations. More...
 
const std::vector< Real > & _initial_values
 Initial values values vector to start the importance sampler. More...
 
const Real_output_limit
 The output limit, exceedance of which indicates failure. More...
 
const int_num_samples_train
 Number of samples to train the importance sampler. More...
 
const int_num_importance_sampling_steps
 Number of importance sampling steps (after the importance distribution has been trained) More...
 
const Real_std_factor
 Factor to be multiplied to the standard deviation of the proposal distribution. 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 unsigned int_num_random_seeds
 Initialize a certain number of random seeds. Change from the default only if you have to. 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
 
const InputParameters_ti_params
 
FEProblemBase_ti_feproblem
 
bool _is_implicit
 
Real_t
 
const Real_t_old
 
int_t_step
 
Real_dt
 
Real_dt_old
 
bool _is_transient
 

Private Attributes

const std::vector< std::vector< Real > > & _inputs
 Storage for the inputs vector obtained from the reporter. More...
 
int _check_step
 Ensure that the MCMC algorithm proceeds in a sequential fashion. More...
 
std::vector< Real_prev_value
 For proposing the next sample in the MCMC algorithm. More...
 
std::vector< Real_mean_sto
 Storage for means of input values for proposing the next sample. More...
 
std::vector< Real_std_sto
 Storage for standard deviations of input values for proposing the next sample. More...
 
std::vector< std::vector< Real > > _inputs_sto
 Storage for previously accepted samples by the decision reporter system. More...
 
int _retraining_steps
 Number of retraining performed. More...
 
const std::vector< bool > *const _gp_flag
 Indicate whether GP prediction is good or bad to influence next proposed sample. More...
 

Detailed Description

A class used to perform Adaptive Importance Sampling using a Markov Chain Monte Carlo algorithm.

Definition at line 18 of file AdaptiveImportanceSampler.h.

Constructor & Destructor Documentation

◆ AdaptiveImportanceSampler()

AdaptiveImportanceSampler::AdaptiveImportanceSampler ( const InputParameters parameters)

Definition at line 53 of file AdaptiveImportanceSampler.C.

55  TransientInterface(this),
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")),
65  _inputs(getReporterValue<std::vector<std::vector<Real>>>("inputs_reporter")),
67  _gp_flag(isParamValid("flag_sample") ? &getReporterValue<std::vector<bool>>("flag_sample")
68  : nullptr)
69 {
70  // Filling the `distributions` vector with the user-provided distributions.
71  for (const DistributionName & name : getParam<std::vector<DistributionName>>("distributions"))
73 
74  /* Adaptive Importance Sampling (AdaptiveImportanceSampler) relies on a Markov Chain Monte Carlo
75  (MCMC) algorithm. As such, in MOOSE, any use of MCMC algorithms requires that the `num_steps`
76  parameter in the main App's executioner would control the total number of samples. Therefore,
77  the `num_rows` parameter typically used by exisiting non-MCMC samplers to set the total number
78  of samples has no use here and is fixed to 1.*/
79  setNumberOfRows(1);
80 
81  // Setting the number of columns in the sampler matrix (equal to the number of distributions).
83 
84  /* `inputs_sto` is a member variable that aids in forming the importance distribution.
85  One dimension of this variable is equal to the number of distributions. The other dimension
86  of the variable, at the last step, is equal to the number of samples the user desires.*/
87  _inputs_sto.resize(_distributions.size());
88 
89  // Mapping all the input distributions to a standard normal space
90  for (unsigned int i = 0; i < _distributions.size(); ++i)
91  _inputs_sto[i].push_back(Normal::quantile(_distributions[i]->cdf(_initial_values[i]), 0, 1));
92 
93  /* `prev_value` is a member variable for tracking the previously accepted samples in the
94  MCMC algorithm and proposing the next sample.*/
95  _prev_value.resize(_distributions.size());
96 
97  // `check_step` is a member variable for ensuring that the MCMC algorithm proceeds in a sequential
98  // fashion.
99  _check_step = 0;
100 
101  // Storage for means of input values for proposing the next sample
102  _mean_sto.resize(_distributions.size());
103 
104  // Storage for standard deviations of input values for proposing the next sample
105  _std_sto.resize(_distributions.size());
106 
108 }
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.
bool _is_sampling_completed
True if the sampling is completed.
std::vector< const Distribution * > _distributions
Storage for distribution objects to be utilized.
std::vector< std::vector< Real > > _inputs_sto
Storage for previously accepted samples by the decision reporter system.
virtual const std::string & name() const
const std::vector< std::vector< Real > > & _inputs
Storage for the inputs vector obtained from the reporter.
Sampler(const InputParameters &parameters)
bool isParamValid(const std::string &name) const
const T & getReporterValue(const std::string &param_name, const std::size_t time_index=0)
std::vector< Real > _std_sto
Storage for standard deviations of input values for proposing the next sample.
TransientInterface(const MooseObject *moose_object)
const Real & _output_limit
The output limit, exceedance of which indicates failure.
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 bool & _use_absolute_value
Absolute value of the model result. Use this when failure is defined as a non-exceedance rather than ...
const int & _num_importance_sampling_steps
Number of importance sampling steps (after the importance distribution has been trained) ...
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.
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.
const InputParameters & parameters() const
const std::vector< Real > & _initial_values
Initial values values vector to start the importance sampler.
const std::vector< Real > & _proposal_std
The proposal distribution standard deviations.
virtual Real quantile(const Real &p) const override
Definition: Normal.C:80
std::vector< Real > _prev_value
For proposing the next sample in the MCMC algorithm.
void setNumberOfRandomSeeds(std::size_t number)

Member Function Documentation

◆ computeSample()

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

Return the sample for the given row (the sample index) and column (the parameter index)

Implements Sampler.

Definition at line 111 of file AdaptiveImportanceSampler.C.

112 {
113  const bool sample = _t_step > 1 && col_index == 0 && _check_step != _t_step;
114  const bool gp_flag = _gp_flag ? (*_gp_flag)[0] : false;
115 
116  if (sample && _is_sampling_completed)
117  mooseError("Internal bug: the adaptive sampling is supposed to be completed but another sample "
118  "has been requested.");
119 
121  {
122  /* This is the importance distribution training step. Markov Chains are set up
123  to sample from the importance region or the failure region using the Metropolis
124  algorithm. Given that the previous sample resulted in a model failure, the next
125  sample is proposed such that it is very likely to result in a model failure as well.
126  The `initial_values` and `proposal_std` parameters provided by the user affects the
127  formation of the importance distribution. */
128  if (sample && !gp_flag)
129  {
130  for (dof_id_type j = 0; j < _distributions.size(); ++j)
131  _prev_value[j] = Normal::quantile(_distributions[j]->cdf(_inputs[j][0]), 0.0, 1.0);
132  Real acceptance_ratio = 0.0;
133  for (dof_id_type i = 0; i < _distributions.size(); ++i)
134  acceptance_ratio += std::log(Normal::pdf(_prev_value[i], 0.0, 1.0)) -
135  std::log(Normal::pdf(_inputs_sto[i].back(), 0.0, 1.0));
136  if (acceptance_ratio > std::log(getRand(_t_step)))
137  {
138  for (dof_id_type i = 0; i < _distributions.size(); ++i)
139  _inputs_sto[i].push_back(_prev_value[i]);
140  }
141  else
142  {
143  for (dof_id_type i = 0; i < _distributions.size(); ++i)
144  _inputs_sto[i].push_back(_inputs_sto[i].back());
145  }
146  for (dof_id_type i = 0; i < _distributions.size(); ++i)
147  _prev_value[i] =
149  }
150  }
151  else if (sample && !gp_flag)
152  {
153  /* This is the importance sampling step using the importance distribution created
154  in the previous step. Once the importance distribution is known, sampling from
155  it is similar to a regular Monte Carlo sampling. */
156  for (dof_id_type i = 0; i < _distributions.size(); ++i)
157  {
158  if (_t_step == _num_samples_train + 1)
159  {
162  }
163  _prev_value[i] =
165  }
166 
167  // check if we have performed all the importance sampling steps
169  _is_sampling_completed = true;
170  }
171 
172  // When the GP fails, the current time step is 'wasted' and the retraining step doesn't
173  // happen until the next time step. Therefore, keep track of the number of retraining steps
174  // to increase the total number of steps taken.
175  if (sample && gp_flag && _t_step > _num_samples_train)
177 
179  return _distributions[col_index]->quantile(Normal::cdf(_prev_value[col_index], 0.0, 1.0));
180 }
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
Definition: Normal.C:74
bool _is_sampling_completed
True if the sampling is completed.
std::vector< const Distribution * > _distributions
Storage for distribution objects to be utilized.
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)
const std::vector< std::vector< Real > > & _inputs
Storage for the inputs vector obtained from the reporter.
virtual Real pdf(const Real &x) const override
Definition: Normal.C:68
std::vector< Real > _std_sto
Storage for standard deviations of input values for proposing the next sample.
const int & _num_samples_train
Number of samples to train the importance sampler.
const int & _num_importance_sampling_steps
Number of importance sampling steps (after the importance distribution has been trained) ...
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.
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
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
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.
virtual Real quantile(const Real &p) const override
Definition: Normal.C:80
uint8_t dof_id_type
std::vector< Real > _prev_value
For proposing the next sample in the MCMC algorithm.

◆ getDistributionNames()

const std::vector<const Distribution *>& AdaptiveImportanceSampler::getDistributionNames ( ) const
inline

Definition at line 44 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceStats::AdaptiveImportanceStats().

44 { return _distributions; }
std::vector< const Distribution * > _distributions
Storage for distribution objects to be utilized.

◆ getImportanceVectorMean()

const std::vector<Real>& AdaptiveImportanceSampler::getImportanceVectorMean ( ) const
inline

Definition at line 38 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceStats::execute().

38 { return _mean_sto; }
std::vector< Real > _mean_sto
Storage for means of input values for proposing the next sample.

◆ getImportanceVectorStd()

const std::vector<Real>& AdaptiveImportanceSampler::getImportanceVectorStd ( ) const
inline

Definition at line 41 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceStats::execute().

41 { return _std_sto; }
std::vector< Real > _std_sto
Storage for standard deviations of input values for proposing the next sample.

◆ getInitialValues()

const std::vector<Real>& AdaptiveImportanceSampler::getInitialValues ( ) const
inline

Definition at line 26 of file AdaptiveImportanceSampler.h.

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

26 { return _initial_values; }
const std::vector< Real > & _initial_values
Initial values values vector to start the importance sampler.

◆ getNumSamplesTrain()

const int& AdaptiveImportanceSampler::getNumSamplesTrain ( ) const
inline

Definition at line 29 of file AdaptiveImportanceSampler.h.

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

29 { return _num_samples_train; }
const int & _num_samples_train
Number of samples to train the importance sampler.

◆ getOutputLimit()

const Real& AdaptiveImportanceSampler::getOutputLimit ( ) const
inline

Definition at line 35 of file AdaptiveImportanceSampler.h.

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

35 { return _output_limit; }
const Real & _output_limit
The output limit, exceedance of which indicates failure.

◆ getStdFactor()

const Real& AdaptiveImportanceSampler::getStdFactor ( ) const
inline

Definition at line 47 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceStats::AdaptiveImportanceStats().

47 { return _std_factor; }
const Real & _std_factor
Factor to be multiplied to the standard deviation of the proposal distribution.

◆ getUseAbsoluteValue()

const bool& AdaptiveImportanceSampler::getUseAbsoluteValue ( ) const
inline

Definition at line 32 of file AdaptiveImportanceSampler.h.

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

32 { return _use_absolute_value; }
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 AdaptiveImportanceSampler::isAdaptiveSamplingCompleted ( ) const
inlineoverridevirtual

Returns true if the adaptive sampling is completed.

Reimplemented from Sampler.

Definition at line 52 of file AdaptiveImportanceSampler.h.

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

◆ validParams()

InputParameters AdaptiveImportanceSampler::validParams ( )
static

Definition at line 19 of file AdaptiveImportanceSampler.C.

Referenced by AISActiveLearning::validParams().

20 {
22  params.addClassDescription("Adaptive Importance Sampler.");
23  params.addRequiredParam<std::vector<DistributionName>>(
24  "distributions",
25  "The distribution names to be sampled, the number of distributions provided defines the "
26  "number of columns per matrix.");
27  params.addRequiredParam<ReporterName>("inputs_reporter", "Reporter with input parameters.");
28  params.addRequiredParam<std::vector<Real>>("proposal_std",
29  "Standard deviations of the proposal distributions");
30  params.addRequiredParam<Real>("output_limit", "Limiting values of the VPPs");
31  params.addRequiredParam<std::vector<Real>>(
32  "initial_values", "Initial input values to get the importance sampler started");
33  params.addRequiredRangeCheckedParam<int>(
34  "num_samples_train",
35  "num_samples_train>0",
36  "Number of samples to learn the importance distribution");
37  params.addRequiredRangeCheckedParam<int>(
38  "num_importance_sampling_steps",
39  "num_importance_sampling_steps>0",
40  "Number of importance sampling steps (after the importance distribution has been trained)");
41  params.addRequiredParam<Real>(
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");
44  params.addParam<unsigned int>(
45  "num_random_seeds",
46  100000,
47  "Initialize a certain number of random seeds. Change from the default only if you have to.");
48  params.addParam<ReporterName>("flag_sample",
49  "Flag samples if the surrogate prediction was inadequate.");
50  return params;
51 }
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
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)

Member Data Documentation

◆ _check_step

int AdaptiveImportanceSampler::_check_step
private

Ensure that the MCMC algorithm proceeds in a sequential fashion.

Definition at line 93 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceSampler(), and computeSample().

◆ _distributions

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

Storage for distribution objects to be utilized.

Definition at line 59 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceSampler(), computeSample(), and getDistributionNames().

◆ _gp_flag

const std::vector<bool>* const AdaptiveImportanceSampler::_gp_flag
private

Indicate whether GP prediction is good or bad to influence next proposed sample.

Definition at line 111 of file AdaptiveImportanceSampler.h.

Referenced by computeSample().

◆ _initial_values

const std::vector<Real>& AdaptiveImportanceSampler::_initial_values
protected

Initial values values vector to start the importance sampler.

Definition at line 65 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceSampler(), and getInitialValues().

◆ _inputs

const std::vector<std::vector<Real> >& AdaptiveImportanceSampler::_inputs
private

Storage for the inputs vector obtained from the reporter.

Definition at line 90 of file AdaptiveImportanceSampler.h.

Referenced by computeSample().

◆ _inputs_sto

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

Storage for previously accepted samples by the decision reporter system.

Definition at line 105 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceSampler(), and computeSample().

◆ _is_sampling_completed

bool AdaptiveImportanceSampler::_is_sampling_completed
protected

True if the sampling is completed.

Definition at line 86 of file AdaptiveImportanceSampler.h.

Referenced by computeSample(), and isAdaptiveSamplingCompleted().

◆ _mean_sto

std::vector<Real> AdaptiveImportanceSampler::_mean_sto
private

Storage for means of input values for proposing the next sample.

Definition at line 99 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceSampler(), computeSample(), and getImportanceVectorMean().

◆ _num_importance_sampling_steps

const int& AdaptiveImportanceSampler::_num_importance_sampling_steps
protected

Number of importance sampling steps (after the importance distribution has been trained)

Definition at line 74 of file AdaptiveImportanceSampler.h.

Referenced by computeSample().

◆ _num_random_seeds

const unsigned int& AdaptiveImportanceSampler::_num_random_seeds
protected

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

Definition at line 83 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceSampler().

◆ _num_samples_train

const int& AdaptiveImportanceSampler::_num_samples_train
protected

Number of samples to train the importance sampler.

Definition at line 71 of file AdaptiveImportanceSampler.h.

Referenced by computeSample(), and getNumSamplesTrain().

◆ _output_limit

const Real& AdaptiveImportanceSampler::_output_limit
protected

The output limit, exceedance of which indicates failure.

Definition at line 68 of file AdaptiveImportanceSampler.h.

Referenced by getOutputLimit().

◆ _prev_value

std::vector<Real> AdaptiveImportanceSampler::_prev_value
private

For proposing the next sample in the MCMC algorithm.

Definition at line 96 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceSampler(), and computeSample().

◆ _proposal_std

const std::vector<Real>& AdaptiveImportanceSampler::_proposal_std
protected

The proposal distribution standard deviations.

Definition at line 62 of file AdaptiveImportanceSampler.h.

Referenced by computeSample().

◆ _retraining_steps

int AdaptiveImportanceSampler::_retraining_steps
private

Number of retraining performed.

Definition at line 108 of file AdaptiveImportanceSampler.h.

Referenced by computeSample().

◆ _std_factor

const Real& AdaptiveImportanceSampler::_std_factor
protected

Factor to be multiplied to the standard deviation of the proposal distribution.

Definition at line 77 of file AdaptiveImportanceSampler.h.

Referenced by computeSample(), and getStdFactor().

◆ _std_sto

std::vector<Real> AdaptiveImportanceSampler::_std_sto
private

Storage for standard deviations of input values for proposing the next sample.

Definition at line 102 of file AdaptiveImportanceSampler.h.

Referenced by AdaptiveImportanceSampler(), computeSample(), and getImportanceVectorStd().

◆ _use_absolute_value

const bool& AdaptiveImportanceSampler::_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 80 of file AdaptiveImportanceSampler.h.

Referenced by getUseAbsoluteValue().


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