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
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
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 AffineInvariantStretchSampler (const InputParameters &parameters)
 
virtual int decisionStep () const override
 Return the step after which decision making can begin.
 
const std::vector< Real > & getAffineStepSize () const
 Return the vector of step size for decision making.
 
dof_id_type getNumberOfConfigValues () const
 Return the number of configuration parameters.
 
dof_id_type getNumberOfConfigParams () const
 Return the number of configuration parameters.
 
dof_id_type getNumParallelProposals () const
 Return the number of parallel proposals.
 
const std::vector< Real > & getRandomNumbers () const
 Return the random numbers to facilitate decision making in reporters.
 
const std::vector< Real > & getVarSamples () const
 Return the proposed variance samples to facilitate decision making in reporters.
 
const std::vector< std::vector< Real > > & getSamples () const
 Return the proposed samples to facilitate decision making in reporters.
 
const std::vector< const Distribution * > getPriors () const
 Return the priors to facilitate decision making in reporters.
 
const DistributiongetVarPrior () const
 Return the prior over variance to facilitate decision making in reporters.
 
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
 
virtual bool isAdaptiveSamplingCompleted () 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
 
bool isImplicit ()
 
Moose::StateArg determineState () 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 proposeSamples () override
 Fill in the _new_samples vector of vectors (happens within sampleSetUp)
 
virtual void executeSetUp () override
 
virtual Real computeSample (dof_id_type row_index, dof_id_type col_index) override
 
Real random ()
 Sample a random number between 0 and 1.
 
unsigned int randomIndex (const unsigned int &upper_bound, const unsigned int &exclude)
 Sample a random index excluding a specified index.
 
std::pair< unsigned int, unsigned intrandomIndexPair (const unsigned int &upper_bound, const unsigned int &exclude)
 Sample two random indices without repitition excluding a specified index.
 
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 Real _step_size
 The step size for the stretch sampler.
 
const std::vector< std::vector< Real > > & _previous_state
 Reporter value with the previous state of all the walkers.
 
const std::vector< Real > & _previous_state_var
 Reporter value with the previous state of all the walkers for variance.
 
std::vector< Real > _affine_step
 Vector of affine step sizes.
 
const unsigned int _num_parallel_proposals
 Number of parallel proposals to be made and subApps to be executed.
 
std::vector< const Distribution * > _priors
 Storage for prior distribution objects to be utilized.
 
const Distribution_var_prior
 Storage for prior distribution object of the variance to be utilized.
 
const std::vector< Real > * _lower_bound
 Lower bounds for making the next proposal.
 
const std::vector< Real > * _upper_bound
 Upper bounds for making the next proposal.
 
const Real & _variance_bound
 Upper bound for variance for making the next proposal.
 
const std::vector< Real > & _initial_values
 Initial values of the input params to get the MCMC scheme started.
 
std::vector< std::vector< Real > > _new_samples
 Vectors of new proposed samples.
 
std::vector< Real > _new_var_samples
 Vector of new proposed variance samples.
 
std::vector< Real > _rnd_vec
 Vector of random numbers for decision making.
 
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
 
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 Member Functions

void combineWithExperimentalConfig ()
 Generates combinations of the new samples with the experimental configurations.
 
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

const unsigned int _num_random_seeds
 Initialize a certain number of random seeds. Change from the default only if you have to.
 
unsigned int _seed_index
 Generator index when requesting random numbers.
 
std::size_t _rand_index
 Running index for the random number generators.
 
std::vector< std::vector< Real > > _confg_values
 Configuration values.
 
std::vector< std::vector< Real > > _new_samples_confg
 Vectors of new proposed samples combined with the experimental configuration values.
 
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
 
const std::string _ti_name
 

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
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 std::vector< std::vector< Real > > & _previous_state
Reporter value with the previous state of all the walkers.
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< Real > _affine_step
Vector of affine step sizes.
const InputParameters & parameters() const
void paramError(const std::string &param, Args... args) const
void mooseWarning(Args &&... args) const
A base class used to perform Parallel Markov Chain Monte Carlo (MCMC) sampling.
Definition PMCMCBase.h:20
std::vector< const Distribution * > _priors
Storage for prior distribution objects to be utilized.
Definition PMCMCBase.h:115
const unsigned int _num_parallel_proposals
Number of parallel proposals to be made and subApps to be executed.
Definition PMCMCBase.h:112
const T & getReporterValue(const std::string &param_name, const std::size_t time_index=0)

Member Function Documentation

◆ combineWithExperimentalConfig()

void PMCMCBase::combineWithExperimentalConfig ( )
privateinherited

Generates combinations of the new samples with the experimental configurations.

Definition at line 167 of file PMCMCBase.C.

168{
169 unsigned int index1;
170 int index2 = -1;
171 std::vector<Real> tmp;
172 for (unsigned int i = 0; i < _num_parallel_proposals * _confg_values[0].size(); ++i)
173 {
174 index1 = i % _num_parallel_proposals;
175 if (index1 == 0)
176 ++index2;
177 tmp = _new_samples[index1];
178 for (unsigned int j = 0; j < _confg_values.size(); ++j)
179 tmp.push_back(_confg_values[j][index2]);
180 _new_samples_confg[i] = tmp;
181 }
182}
std::vector< std::vector< Real > > _new_samples
Vectors of new proposed samples.
Definition PMCMCBase.h:133
std::vector< std::vector< Real > > _confg_values
Configuration values.
Definition PMCMCBase.h:157
std::vector< std::vector< Real > > _new_samples_confg
Vectors of new proposed samples combined with the experimental configuration values.
Definition PMCMCBase.h:160

Referenced by PMCMCBase::computeSample().

◆ computeSample()

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

Implements Sampler.

Definition at line 215 of file PMCMCBase.C.

216{
217 if (_t_step < 1)
218 for (unsigned int i = 0; i < _num_parallel_proposals; ++i)
220
221 // Combine the proposed samples with experimental configurations
223
224 return _new_samples_confg[row_index][col_index];
225}
void combineWithExperimentalConfig()
Generates combinations of the new samples with the experimental configurations.
Definition PMCMCBase.C:167
const std::vector< Real > & _initial_values
Initial values of the input params to get the MCMC scheme started.
Definition PMCMCBase.h:130

◆ 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.

24{ return 2; }

Referenced by proposeSamples().

◆ executeSetUp()

void PMCMCBase::executeSetUp ( )
overrideprotectedvirtualinherited

Reimplemented from Sampler.

Definition at line 128 of file PMCMCBase.C.

129{
131 _rand_index = 0;
132
133 // Filling the new_samples vector of vectors with new proposal samples
135
136 // Draw random numbers to facilitate decision making later on
137 for (unsigned int j = 0; j < _num_parallel_proposals; ++j)
138 _rnd_vec[j] = random();
139}
Real random()
Sample a random number between 0 and 1.
Definition PMCMCBase.C:142
unsigned int _seed_index
Generator index when requesting random numbers.
Definition PMCMCBase.h:151
virtual void proposeSamples()
Fill in the _new_samples vector of vectors (happens within sampleSetUp)
Definition PMCMCBase.C:120
std::size_t _rand_index
Running index for the random number generators.
Definition PMCMCBase.h:154
std::vector< Real > _rnd_vec
Vector of random numbers for decision making.
Definition PMCMCBase.h:139

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

◆ getNumberOfConfigParams()

dof_id_type PMCMCBase::getNumberOfConfigParams ( ) const
inlineinherited

Return the number of configuration parameters.

Definition at line 34 of file PMCMCBase.h.

34{ return _confg_values.size(); }

Referenced by BayesianActiveLearner::BayesianActiveLearner(), and PMCMCDecision::PMCMCDecision().

◆ getNumberOfConfigValues()

dof_id_type PMCMCBase::getNumberOfConfigValues ( ) const
inlineinherited

Return the number of configuration parameters.

Definition at line 29 of file PMCMCBase.h.

29{ return _confg_values[0].size(); }

Referenced by BayesianActiveLearner::BayesianActiveLearner(), and PMCMCDecision::PMCMCDecision().

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

◆ getPriors()

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

Return the priors to facilitate decision making in reporters.

Definition at line 203 of file PMCMCBase.C.

204{
205 return _priors;
206}

◆ getRandomNumbers()

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

Return the random numbers to facilitate decision making in reporters.

Definition at line 185 of file PMCMCBase.C.

186{
187 return _rnd_vec;
188}

◆ getSamples()

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

Return the proposed samples to facilitate decision making in reporters.

In MCMC schemes, there is a decision-making step after evaluating the computational model on whether or not to accept the proposed samples. To facilitate this decision-making, which happens in the Reporter, we have to provide it the proposed samples.

Definition at line 197 of file PMCMCBase.C.

198{
199 return _new_samples;
200}

◆ getVarPrior()

const Distribution * PMCMCBase::getVarPrior ( ) const
inherited

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

Definition at line 209 of file PMCMCBase.C.

210{
211 return _var_prior;
212}
const Distribution * _var_prior
Storage for prior distribution object of the variance to be utilized.
Definition PMCMCBase.h:118

◆ getVarSamples()

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

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

Definition at line 191 of file PMCMCBase.C.

192{
193 return _new_var_samples;
194}
std::vector< Real > _new_var_samples
Vector of new proposed variance samples.
Definition PMCMCBase.h:136

◆ proposeSamples()

void AffineInvariantStretchSampler::proposeSamples ( )
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) * random() + 1.0) / _step_size;
58 for (unsigned int i = 0; i < _priors.size(); ++i)
59 {
60 _new_samples[j][i] =
61 (_t_step + 1 > decisionStep())
62 ? (_previous_state[index_req][i] +
63 _affine_step[j] * (_previous_state[j][i] - _previous_state[index_req][i]))
64 : _priors[i]->quantile(random());
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 + 1 > decisionStep())
75 ? (_previous_state_var[index_req] +
77 : _var_prior->quantile(random());
79 indicator = 1;
80 }
81 if (!indicator)
82 ++j;
83 }
84}
virtual int decisionStep() const override
Return the step after which decision making can begin.
const std::vector< Real > * _lower_bound
Lower bounds for making the next proposal.
Definition PMCMCBase.h:121
const Real & _variance_bound
Upper bound for variance for making the next proposal.
Definition PMCMCBase.h:127
unsigned int randomIndex(const unsigned int &upper_bound, const unsigned int &exclude)
Sample a random index excluding a specified index.
Definition PMCMCBase.C:148

◆ random()

Real PMCMCBase::random ( )
protectedinherited

Sample a random number between 0 and 1.

Parameters
upper_boundThe upper bound provided
Returns
The required index

Definition at line 142 of file PMCMCBase.C.

143{
145}
Real getRand(std::size_t n, unsigned int index=0) const

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

◆ randomIndex()

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

Sample a random index excluding a specified index.

Parameters
upper_boundThe upper bound provided
Returns
The required index

Definition at line 148 of file PMCMCBase.C.

149{
150 auto req_index = exclude;
151 while (req_index == exclude)
152 req_index = getRandl(_rand_index++, 0, upper_bound, _seed_index);
153 return req_index;
154}
unsigned int getRandl(std::size_t n, unsigned int lower, unsigned int upper, unsigned int index=0) const

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

◆ randomIndexPair()

std::pair< unsigned int, unsigned int > PMCMCBase::randomIndexPair ( const unsigned int upper_bound,
const unsigned int exclude 
)
protectedinherited

Sample two random indices without repitition excluding a specified index.

Parameters
upper_boundThe upper bound provided
excludeThe index to be excluded from sampling
Returns
Pair of required indices

Definition at line 157 of file PMCMCBase.C.

158{
159 auto req_index1 = randomIndex(upper_bound, exclude);
160 auto req_index2 = req_index1;
161 while (req_index1 == req_index2)
162 req_index2 = randomIndex(upper_bound, exclude);
163 return {req_index1, req_index2};
164}

Referenced by AffineInvariantDES::proposeSamples().

◆ 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 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)
static InputParameters validParams()
Definition PMCMCBase.C:18
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

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().

◆ _confg_values

std::vector<std::vector<Real> > PMCMCBase::_confg_values
privateinherited

◆ _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 130 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 121 of file PMCMCBase.h.

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

◆ _new_samples

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

◆ _new_samples_confg

std::vector<std::vector<Real> > PMCMCBase::_new_samples_confg
privateinherited

Vectors of new proposed samples combined with the experimental configuration values.

Definition at line 160 of file PMCMCBase.h.

Referenced by PMCMCBase::combineWithExperimentalConfig(), PMCMCBase::computeSample(), and PMCMCBase::PMCMCBase().

◆ _new_var_samples

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

◆ _num_parallel_proposals

const unsigned int PMCMCBase::_num_parallel_proposals
protectedinherited

◆ _num_random_seeds

const unsigned int PMCMCBase::_num_random_seeds
privateinherited

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

Definition at line 148 of file PMCMCBase.h.

Referenced by PMCMCBase::PMCMCBase().

◆ _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

◆ _rand_index

std::size_t PMCMCBase::_rand_index
privateinherited

Running index for the random number generators.

Definition at line 154 of file PMCMCBase.h.

Referenced by PMCMCBase::executeSetUp(), PMCMCBase::random(), and PMCMCBase::randomIndex().

◆ _rnd_vec

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

Vector of random numbers for decision making.

Definition at line 139 of file PMCMCBase.h.

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

◆ _seed_index

unsigned int PMCMCBase::_seed_index
privateinherited

Generator index when requesting random numbers.

Definition at line 151 of file PMCMCBase.h.

Referenced by PMCMCBase::executeSetUp(), PMCMCBase::random(), and PMCMCBase::randomIndex().

◆ _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 124 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 118 of file PMCMCBase.h.

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

◆ _variance_bound

const Real& PMCMCBase::_variance_bound
protectedinherited

Upper bound for variance for making the next proposal.

Definition at line 127 of file PMCMCBase.h.

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


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