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

A class for performing Affine Invariant Ensemble MCMC with stretch sampler. More...

#include <AffineInvariantStretchSampler.h>

Inheritance diagram for AffineInvariantStretchSampler:
[legend]

Public Types

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

Public Member Functions

 AffineInvariantStretchSampler (const InputParameters &parameters)
 
virtual int decisionStep () const override
 Return the step after which decision making can begin. More...
 
const std::vector< Real > & getAffineStepSize () const
 Return the vector of step size for decision making. More...
 
dof_id_type getNumberOfConfigValues () const
 Return the number of configuration parameters. More...
 
dof_id_type getNumberOfConfigParams () const
 Return the number of configuration parameters. More...
 
dof_id_type getNumParallelProposals () const
 Return the number of parallel proposals. More...
 
const std::vector< Real > & getRandomNumbers () const
 Return the random numbers to facilitate decision making in reporters. More...
 
const std::vector< Real > & getVarSamples () const
 Return the proposed variance samples to facilitate decision making in reporters. More...
 
const std::vector< const Distribution * > getPriors () const
 Return the priors to facilitate decision making in reporters. More...
 
const DistributiongetVarPrior () const
 Return the prior over variance to facilitate decision making in reporters. 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
 
virtual bool isAdaptiveSamplingCompleted () 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 void proposeSamples (const unsigned int seed_value) override
 Fill in the _new_samples vector of vectors (happens within sampleSetUp) More...
 
virtual void sampleSetUp (const Sampler::SampleMode mode) override
 
virtual Real computeSample (dof_id_type row_index, dof_id_type col_index) override
 
void randomIndex (const unsigned int &upper_bound, const unsigned int &exclude, const unsigned int &seed, unsigned int &req_index)
 Sample a random index excluding a specified index. More...
 
void randomIndexPair (const unsigned int &upper_bound, const unsigned int &exclude, const unsigned int &seed, unsigned int &req_index1, unsigned int &req_index2)
 Sample two random indices without repitition excluding a specified 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 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 Real _step_size
 The step size for the stretch sampler. More...
 
const std::vector< std::vector< Real > > & _previous_state
 Reporter value with the previous state of all the walkers. More...
 
const std::vector< Real > & _previous_state_var
 Reporter value with the previous state of all the walkers for variance. More...
 
std::vector< Real_affine_step
 Vector of affine step sizes. More...
 
const unsigned int _num_parallel_proposals
 Number of parallel proposals to be made and subApps to be executed. More...
 
std::vector< const Distribution * > _priors
 Storage for prior distribution objects to be utilized. More...
 
const Distribution_var_prior
 Storage for prior distribution object of the variance to be utilized. More...
 
const std::vector< Real > * _lower_bound
 Lower bounds for making the next proposal. More...
 
const std::vector< Real > * _upper_bound
 Upper bounds for making the next proposal. More...
 
int _check_step
 Ensure that the MCMC algorithm proceeds in a sequential fashion. More...
 
const std::vector< Real > & _initial_values
 Initial values of the input params to get the MCMC scheme started. More...
 
std::vector< std::vector< Real > > _new_samples
 Vectors of new proposed samples. More...
 
std::vector< Real_new_var_samples
 Vector of new proposed variance samples. More...
 
std::vector< Real_rnd_vec
 Vector of random numbers for decision making. 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
 

Detailed Description

A class for performing Affine Invariant Ensemble MCMC with stretch sampler.

Definition at line 17 of file AffineInvariantStretchSampler.h.

Constructor & Destructor Documentation

◆ AffineInvariantStretchSampler()

AffineInvariantStretchSampler::AffineInvariantStretchSampler ( const InputParameters parameters)

Definition at line 28 of file AffineInvariantStretchSampler.C.

30  _step_size(getParam<Real>("step_size")),
31  _previous_state(getReporterValue<std::vector<std::vector<Real>>>("previous_state")),
32  _previous_state_var(getReporterValue<std::vector<Real>>("previous_state_var"))
33 {
35  paramError("num_parallel_proposals",
36  "At least three parallel proposals should be used for the Stretch Sampler.");
37 
38  if (_num_parallel_proposals < _priors.size())
40  "It is recommended that the parallel proposals be greater than or equal to the "
41  "inferred parameters. This will allow the sampler to not get stuck on a hyper-plane.");
42 
43  // Assign the correct size to the step size vector
45 }
const unsigned int _num_parallel_proposals
Number of parallel proposals to be made and subApps to be executed.
Definition: PMCMCBase.h:106
PMCMCBase(const InputParameters &parameters)
Definition: PMCMCBase.C:46
std::vector< Real > _affine_step
Vector of affine step sizes.
std::vector< const Distribution * > _priors
Storage for prior distribution objects to be utilized.
Definition: PMCMCBase.h:109
void mooseWarning(Args &&... args) const
const std::vector< std::vector< Real > > & _previous_state
Reporter value with the previous state of all the walkers.
const T & getReporterValue(const std::string &param_name, const std::size_t time_index=0)
const Real _step_size
The step size for the stretch sampler.
void paramError(const std::string &param, Args... args) const
const std::vector< Real > & _previous_state_var
Reporter value with the previous state of all the walkers for variance.
const InputParameters & parameters() const

Member Function Documentation

◆ computeSample()

Real PMCMCBase::computeSample ( dof_id_type  row_index,
dof_id_type  col_index 
)
overrideprotectedvirtualinherited

Implements Sampler.

Definition at line 207 of file PMCMCBase.C.

208 {
209  if (_t_step < 1)
210  for (unsigned int i = 0; i < _num_parallel_proposals; ++i)
212 
213  // Combine the proposed samples with experimental configurations
215 
216  return _new_samples_confg[row_index][col_index];
217 }
const unsigned int _num_parallel_proposals
Number of parallel proposals to be made and subApps to be executed.
Definition: PMCMCBase.h:106
const std::vector< Real > & _initial_values
Initial values of the input params to get the MCMC scheme started.
Definition: PMCMCBase.h:124
std::vector< std::vector< Real > > _new_samples_confg
Vectors of new proposed samples combined with the experimental configuration values.
Definition: PMCMCBase.h:148
void combineWithExperimentalConfig()
Generates combinations of the new samples with the experimental configurations.
Definition: PMCMCBase.C:165
std::vector< std::vector< Real > > _new_samples
Vectors of new proposed samples.
Definition: PMCMCBase.h:127

◆ decisionStep()

virtual int AffineInvariantStretchSampler::decisionStep ( ) const
inlineoverridevirtual

Return the step after which decision making can begin.

Reimplemented from PMCMCBase.

Definition at line 24 of file AffineInvariantStretchSampler.h.

Referenced by proposeSamples().

24 { return 2; }

◆ getAffineStepSize()

const std::vector< Real > & AffineInvariantStretchSampler::getAffineStepSize ( ) const

Return the vector of step size for decision making.

Definition at line 87 of file AffineInvariantStretchSampler.C.

88 {
89  return _affine_step;
90 }
std::vector< Real > _affine_step
Vector of affine step sizes.

◆ getNumberOfConfigParams()

dof_id_type PMCMCBase::getNumberOfConfigParams ( ) const
inlineinherited

Return the number of configuration parameters.

Definition at line 34 of file PMCMCBase.h.

Referenced by PMCMCDecision::PMCMCDecision().

34 { return _confg_values.size(); }
std::vector< std::vector< Real > > _confg_values
Configuration values.
Definition: PMCMCBase.h:145

◆ getNumberOfConfigValues()

dof_id_type PMCMCBase::getNumberOfConfigValues ( ) const
inlineinherited

Return the number of configuration parameters.

Definition at line 29 of file PMCMCBase.h.

Referenced by PMCMCDecision::PMCMCDecision().

29 { return _confg_values[0].size(); }
std::vector< std::vector< Real > > _confg_values
Configuration values.
Definition: PMCMCBase.h:145

◆ getNumParallelProposals()

dof_id_type PMCMCBase::getNumParallelProposals ( ) const
inlineinherited

Return the number of parallel proposals.

Definition at line 39 of file PMCMCBase.h.

Referenced by PMCMCDecision::PMCMCDecision().

39 { return _num_parallel_proposals; }
const unsigned int _num_parallel_proposals
Number of parallel proposals to be made and subApps to be executed.
Definition: PMCMCBase.h:106

◆ getPriors()

const std::vector< const Distribution * > PMCMCBase::getPriors ( ) const
inherited

Return the priors to facilitate decision making in reporters.

Definition at line 195 of file PMCMCBase.C.

196 {
197  return _priors;
198 }
std::vector< const Distribution * > _priors
Storage for prior distribution objects to be utilized.
Definition: PMCMCBase.h:109

◆ getRandomNumbers()

const std::vector< Real > & PMCMCBase::getRandomNumbers ( ) const
inherited

Return the random numbers to facilitate decision making in reporters.

Definition at line 183 of file PMCMCBase.C.

184 {
185  return _rnd_vec;
186 }
std::vector< Real > _rnd_vec
Vector of random numbers for decision making.
Definition: PMCMCBase.h:133

◆ getVarPrior()

const Distribution * PMCMCBase::getVarPrior ( ) const
inherited

Return the prior over variance to facilitate decision making in reporters.

Definition at line 201 of file PMCMCBase.C.

202 {
203  return _var_prior;
204 }
const Distribution * _var_prior
Storage for prior distribution object of the variance to be utilized.
Definition: PMCMCBase.h:112

◆ getVarSamples()

const std::vector< Real > & PMCMCBase::getVarSamples ( ) const
inherited

Return the proposed variance samples to facilitate decision making in reporters.

Definition at line 189 of file PMCMCBase.C.

190 {
191  return _new_var_samples;
192 }
std::vector< Real > _new_var_samples
Vector of new proposed variance samples.
Definition: PMCMCBase.h:130

◆ proposeSamples()

void AffineInvariantStretchSampler::proposeSamples ( const unsigned int  seed_value)
overrideprotectedvirtual

Fill in the _new_samples vector of vectors (happens within sampleSetUp)

Parameters
seed_valueThe seed for the random number generator

Reimplemented from PMCMCBase.

Definition at line 48 of file AffineInvariantStretchSampler.C.

49 {
50  unsigned int j = 0;
51  bool indicator;
52  unsigned int index_req = 0;
53  while (j < _num_parallel_proposals)
54  {
55  indicator = 0;
56  _affine_step[j] = Utility::pow<2>((_step_size - 1.0) * getRand(seed_value) + 1.0) / _step_size;
57  randomIndex(_num_parallel_proposals, j, seed_value, index_req);
58  for (unsigned int i = 0; i < _priors.size(); ++i)
59  {
60  _new_samples[j][i] =
61  (_t_step > decisionStep())
62  ? (_previous_state[index_req][i] +
63  _affine_step[j] * (_previous_state[j][i] - _previous_state[index_req][i]))
64  : _priors[i]->quantile(getRand(seed_value));
65  if (_lower_bound)
66  indicator =
67  (_new_samples[j][i] < (*_lower_bound)[i] || _new_samples[j][i] > (*_upper_bound)[i])
68  ? 1
69  : indicator;
70  }
71  if (_var_prior)
72  {
74  (_t_step > decisionStep())
75  ? (_previous_state_var[index_req] +
77  : _var_prior->quantile(getRand(seed_value));
78  if (_new_var_samples[j] < 0.0)
79  indicator = 1;
80  }
81  if (!indicator)
82  ++j;
83  }
84 }
const unsigned int _num_parallel_proposals
Number of parallel proposals to be made and subApps to be executed.
Definition: PMCMCBase.h:106
const std::vector< Real > * _lower_bound
Lower bounds for making the next proposal.
Definition: PMCMCBase.h:115
virtual int decisionStep() const override
Return the step after which decision making can begin.
std::vector< Real > _affine_step
Vector of affine step sizes.
std::vector< const Distribution * > _priors
Storage for prior distribution objects to be utilized.
Definition: PMCMCBase.h:109
Real getRand(unsigned int index=0)
const std::vector< std::vector< Real > > & _previous_state
Reporter value with the previous state of all the walkers.
std::vector< Real > _new_var_samples
Vector of new proposed variance samples.
Definition: PMCMCBase.h:130
const Real _step_size
The step size for the stretch sampler.
const std::vector< Real > & _previous_state_var
Reporter value with the previous state of all the walkers for variance.
std::vector< std::vector< Real > > _new_samples
Vectors of new proposed samples.
Definition: PMCMCBase.h:127
const Distribution * _var_prior
Storage for prior distribution object of the variance to be utilized.
Definition: PMCMCBase.h:112
void randomIndex(const unsigned int &upper_bound, const unsigned int &exclude, const unsigned int &seed, unsigned int &req_index)
Sample a random index excluding a specified index.
Definition: PMCMCBase.C:141
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
virtual Real quantile(const Real &y) const=0

◆ randomIndex()

void PMCMCBase::randomIndex ( const unsigned int upper_bound,
const unsigned int exclude,
const unsigned int seed,
unsigned int req_index 
)
protectedinherited

Sample a random index excluding a specified index.

Parameters
upper_boundThe upper bound provided
excludeThe index to be excluded from sampling
seedThe seed of the random number generator
req_indexThe required index to be filled

Definition at line 141 of file PMCMCBase.C.

Referenced by proposeSamples(), and PMCMCBase::randomIndexPair().

145 {
146  req_index = exclude;
147  while (req_index == exclude)
148  req_index = getRandl(seed, 0, upper_bound);
149 }
uint32_t getRandl(unsigned int index, uint32_t lower, uint32_t upper)

◆ randomIndexPair()

void PMCMCBase::randomIndexPair ( const unsigned int upper_bound,
const unsigned int exclude,
const unsigned int seed,
unsigned int req_index1,
unsigned int req_index2 
)
protectedinherited

Sample two random indices without repitition excluding a specified index.

Parameters
upper_boundThe upper bound provided
excludeThe index to be excluded from sampling
seedThe seed of the random number generator
req_index1The required index 1 to be filled
req_index2The required index 2 to be filled

Definition at line 152 of file PMCMCBase.C.

Referenced by AffineInvariantDES::proposeSamples().

157 {
158  randomIndex(upper_bound, exclude, seed, req_index1);
159  req_index2 = req_index1;
160  while (req_index1 == req_index2)
161  randomIndex(upper_bound, exclude, seed, req_index2);
162 }
void randomIndex(const unsigned int &upper_bound, const unsigned int &exclude, const unsigned int &seed, unsigned int &req_index)
Sample a random index excluding a specified index.
Definition: PMCMCBase.C:141

◆ sampleSetUp()

void PMCMCBase::sampleSetUp ( const Sampler::SampleMode  mode)
overrideprotectedvirtualinherited

Reimplemented from Sampler.

Definition at line 124 of file PMCMCBase.C.

125 {
126  if (_t_step < 1 || _check_step == _t_step)
127  return;
129 
130  unsigned int seed_value = _t_step > 0 ? (_t_step - 1) : 0;
131 
132  // Filling the new_samples vector of vectors with new proposal samples
133  proposeSamples(seed_value);
134 
135  // Draw random numbers to facilitate decision making later on
136  for (unsigned int j = 0; j < _num_parallel_proposals; ++j)
137  _rnd_vec[j] = getRand(seed_value);
138 }
const unsigned int _num_parallel_proposals
Number of parallel proposals to be made and subApps to be executed.
Definition: PMCMCBase.h:106
int _check_step
Ensure that the MCMC algorithm proceeds in a sequential fashion.
Definition: PMCMCBase.h:121
Real getRand(unsigned int index=0)
virtual void proposeSamples(const unsigned int seed_value)
Fill in the _new_samples vector of vectors (happens within sampleSetUp)
Definition: PMCMCBase.C:116
std::vector< Real > _rnd_vec
Vector of random numbers for decision making.
Definition: PMCMCBase.h:133
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")

◆ validParams()

InputParameters AffineInvariantStretchSampler::validParams ( )
static

Definition at line 15 of file AffineInvariantStretchSampler.C.

16 {
18  params.addClassDescription("Perform Affine Invariant Ensemble MCMC with stretch sampler.");
20  "previous_state", "Reporter value with the previous state of all the walkers.");
22  "previous_state_var",
23  "Reporter value with the previous state of all the walkers for variance.");
24  params.addParam<Real>("step_size", 2.0, "Step size for each of the walkers.");
25  return params;
26 }
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)
static InputParameters validParams()
Definition: PMCMCBase.C:18

Member Data Documentation

◆ _affine_step

std::vector<Real> AffineInvariantStretchSampler::_affine_step
protected

Vector of affine step sizes.

Definition at line 44 of file AffineInvariantStretchSampler.h.

Referenced by AffineInvariantStretchSampler(), getAffineStepSize(), and proposeSamples().

◆ _check_step

int PMCMCBase::_check_step
protectedinherited

Ensure that the MCMC algorithm proceeds in a sequential fashion.

Definition at line 121 of file PMCMCBase.h.

Referenced by PMCMCBase::PMCMCBase(), and PMCMCBase::sampleSetUp().

◆ _initial_values

const std::vector<Real>& PMCMCBase::_initial_values
protectedinherited

Initial values of the input params to get the MCMC scheme started.

Definition at line 124 of file PMCMCBase.h.

Referenced by PMCMCBase::computeSample(), PMCMCBase::PMCMCBase(), and IndependentGaussianMH::proposeSamples().

◆ _lower_bound

const std::vector<Real>* PMCMCBase::_lower_bound
protectedinherited

Lower bounds for making the next proposal.

Definition at line 115 of file PMCMCBase.h.

Referenced by PMCMCBase::PMCMCBase(), AffineInvariantDES::proposeSamples(), IndependentGaussianMH::proposeSamples(), and proposeSamples().

◆ _new_samples

std::vector<std::vector<Real> > PMCMCBase::_new_samples
protectedinherited

◆ _new_var_samples

std::vector<Real> PMCMCBase::_new_var_samples
protectedinherited

Vector of new proposed variance samples.

Definition at line 130 of file PMCMCBase.h.

Referenced by PMCMCBase::getVarSamples(), PMCMCBase::PMCMCBase(), AffineInvariantDES::proposeSamples(), and proposeSamples().

◆ _num_parallel_proposals

const unsigned int PMCMCBase::_num_parallel_proposals
protectedinherited

◆ _previous_state

const std::vector<std::vector<Real> >& AffineInvariantStretchSampler::_previous_state
protected

Reporter value with the previous state of all the walkers.

Definition at line 38 of file AffineInvariantStretchSampler.h.

Referenced by proposeSamples().

◆ _previous_state_var

const std::vector<Real>& AffineInvariantStretchSampler::_previous_state_var
protected

Reporter value with the previous state of all the walkers for variance.

Definition at line 41 of file AffineInvariantStretchSampler.h.

Referenced by proposeSamples().

◆ _priors

std::vector<const Distribution *> PMCMCBase::_priors
protectedinherited

◆ _rnd_vec

std::vector<Real> PMCMCBase::_rnd_vec
protectedinherited

Vector of random numbers for decision making.

Definition at line 133 of file PMCMCBase.h.

Referenced by PMCMCBase::getRandomNumbers(), PMCMCBase::PMCMCBase(), and PMCMCBase::sampleSetUp().

◆ _step_size

const Real AffineInvariantStretchSampler::_step_size
protected

The step size for the stretch sampler.

Definition at line 35 of file AffineInvariantStretchSampler.h.

Referenced by proposeSamples().

◆ _upper_bound

const std::vector<Real>* PMCMCBase::_upper_bound
protectedinherited

Upper bounds for making the next proposal.

Definition at line 118 of file PMCMCBase.h.

Referenced by PMCMCBase::PMCMCBase(), and IndependentGaussianMH::proposeSamples().

◆ _var_prior

const Distribution* PMCMCBase::_var_prior
protectedinherited

Storage for prior distribution object of the variance to be utilized.

Definition at line 112 of file PMCMCBase.h.

Referenced by PMCMCBase::getVarPrior(), PMCMCBase::PMCMCBase(), AffineInvariantDES::proposeSamples(), and proposeSamples().


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