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

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

#include <AffineInvariantDES.h>

Inheritance diagram for AffineInvariantDES:
[legend]

Public Types

enum  SampleMode
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 AffineInvariantDES (const InputParameters &parameters)
 
virtual int decisionStep () const override
 Return the step after which decision making can begin.
 
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)
 
void computeDifferential (const Real &state1, const Real &state2, const Real &rnd, const Real &scale, Real &diff)
 Compute the differential evolution from the current state.
 
void tuneParams (Real &gamma, Real &b, const Real &scale)
 Tune the internal parameters.
 
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 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.
 
const MooseEnum_tuning_option
 Tuning options for the internal params.
 
std::vector< Real > _scales
 Scales for the parameters.
 
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 differential sampler.

Definition at line 17 of file AffineInvariantDES.h.

Constructor & Destructor Documentation

◆ AffineInvariantDES()

AffineInvariantDES::AffineInvariantDES ( const InputParameters parameters)

Definition at line 40 of file AffineInvariantDES.C.

42 _previous_state(getReporterValue<std::vector<std::vector<Real>>>("previous_state")),
43 _previous_state_var(getReporterValue<std::vector<Real>>("previous_state_var")),
44 _tuning_option(getParam<MooseEnum>("tuning_option"))
45{
48 "num_parallel_proposals",
49 "At least five parallel proposals should be used for the Differential Evolution Sampler.");
50
53 "It is recommended that the parallel proposals be greater than or equal to the "
54 "inferred parameters. This will allow the sampler to not get stuck on a hyper-plane.");
55
56 if (isParamValid("scales"))
57 {
58 _scales = getParam<std::vector<Real>>("scales");
59 if (_scales.size() != _priors.size())
60 paramError("scales",
61 "The number of scales provided should match the number of tunable params.");
62 }
63 else
64 _scales.assign(_priors.size(), 1.0);
65}
const std::vector< Real > & _previous_state_var
Reporter value with the previous state of all the walkers for variance.
std::vector< Real > _scales
Scales for the parameters.
const std::vector< std::vector< Real > > & _previous_state
Reporter value with the previous state of all the walkers.
const MooseEnum & _tuning_option
Tuning options for the internal params.
const InputParameters & parameters() const
void paramError(const std::string &param, Args... args) const
void mooseWarning(Args &&... args) const
bool isParamValid(const std::string &name) 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().

◆ computeDifferential()

void AffineInvariantDES::computeDifferential ( const Real &  state1,
const Real &  state2,
const Real &  rnd,
const Real &  scale,
Real &  diff 
)
protected

Compute the differential evolution from the current state.

Parameters
state1A randomly selected state 1 of the sampler
state2A randomly selected state 2 of the sampler
rndRandom number between 0 and 1
scaleThe scale of the input parameter
diffDifferential between two randomly selected states

Definition at line 68 of file AffineInvariantDES.C.

70{
71 Real gamma;
72 Real b;
73 tuneParams(gamma, b, scale);
74 diff = gamma * (state1 - state2) + Normal::quantile(rnd, 0.0, b);
75}
void tuneParams(Real &gamma, Real &b, const Real &scale)
Tune the internal parameters.
virtual Real quantile(const Real &p) const override
Definition Normal.C:80
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

Referenced by proposeSamples().

◆ 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 AffineInvariantDES::decisionStep ( ) const
inlineoverridevirtual

Return the step after which decision making can begin.

Reimplemented from PMCMCBase.

Definition at line 24 of file AffineInvariantDES.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

◆ 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 AffineInvariantDES::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 88 of file AffineInvariantDES.C.

89{
90 unsigned int j = 0;
91 bool indicator;
92 std::pair<unsigned int, unsigned int> index_req;
93 Real diff;
94 while (j < _num_parallel_proposals)
95 {
96 indicator = 0;
98 for (unsigned int i = 0; i < _priors.size(); ++i)
99 {
100 computeDifferential(_previous_state[index_req.first][i],
101 _previous_state[index_req.second][i],
102 random(),
103 _scales[i],
104 diff);
105 _new_samples[j][i] = (_t_step + 1 > decisionStep()) ? (_previous_state[j][i] + diff)
106 : _priors[i]->quantile(random());
107 if (_lower_bound)
108 indicator =
109 (_new_samples[j][i] < (*_lower_bound)[i] || _new_samples[j][i] > (*_upper_bound)[i])
110 ? 1
111 : indicator;
112 }
113 if (_var_prior)
114 {
116 _previous_state_var[index_req.second],
117 random(),
118 1.0,
119 diff);
120 _new_var_samples[j] = (_t_step + 1 > decisionStep()) ? (_previous_state_var[j] + diff)
123 indicator = 1;
124 }
125 if (!indicator)
126 ++j;
127 }
128}
void computeDifferential(const Real &state1, const Real &state2, const Real &rnd, const Real &scale, Real &diff)
Compute the differential evolution from the current state.
virtual int decisionStep() const override
Return the step after which decision making can begin.
virtual Real quantile(const Real &y) const=0
const std::vector< Real > * _lower_bound
Lower bounds for making the next proposal.
Definition PMCMCBase.h:121
std::pair< unsigned int, unsigned int > randomIndexPair(const unsigned int &upper_bound, const unsigned int &exclude)
Sample two random indices without repitition excluding a specified index.
Definition PMCMCBase.C:157
const Real & _variance_bound
Upper bound for variance for making the next proposal.
Definition PMCMCBase.h:127

◆ 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(), proposeSamples(), AffineInvariantStretchSampler::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 AffineInvariantStretchSampler::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}
unsigned int randomIndex(const unsigned int &upper_bound, const unsigned int &exclude)
Sample a random index excluding a specified index.
Definition PMCMCBase.C:148

Referenced by proposeSamples().

◆ tuneParams()

void AffineInvariantDES::tuneParams ( Real &  gamma,
Real &  b,
const Real &  scale 
)
protected

Tune the internal parameters.

Parameters
gammaAn internal parameter
bAn internal parameter
scaleThe scale of the input parameter

Definition at line 78 of file AffineInvariantDES.C.

79{
80 if (_tuning_option == "Braak2006_static")
81 {
82 gamma = 2.38 / std::sqrt(2 * _priors.size());
83 b = 1e-6 * scale;
84 }
85}
Real scale

Referenced by computeDifferential().

◆ validParams()

InputParameters AffineInvariantDES::validParams ( )
static

Definition at line 24 of file AffineInvariantDES.C.

25{
27 params.addClassDescription("Perform Affine Invariant Ensemble MCMC with differential sampler.");
29 "previous_state", "Reporter value with the previous state of all the walkers.");
31 "previous_state_var",
32 "Reporter value with the previous state of all the walkers for variance.");
33 MooseEnum tuning_option("Braak2006_static", "Braak2006_static");
34 params.addParam<MooseEnum>(
35 "tuning_option", tuning_option, "The tuning option for internal parameters.");
36 params.addParam<std::vector<Real>>("scales", "Scales for the parameters.");
37 return params;
38}
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

Member Data Documentation

◆ _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(), proposeSamples(), AffineInvariantStretchSampler::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> >& AffineInvariantDES::_previous_state
protected

Reporter value with the previous state of all the walkers.

Definition at line 49 of file AffineInvariantDES.h.

Referenced by proposeSamples().

◆ _previous_state_var

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

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

Definition at line 52 of file AffineInvariantDES.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().

◆ _scales

std::vector<Real> AffineInvariantDES::_scales
protected

Scales for the parameters.

Definition at line 58 of file AffineInvariantDES.h.

Referenced by AffineInvariantDES(), and proposeSamples().

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

◆ _tuning_option

const MooseEnum& AffineInvariantDES::_tuning_option
protected

Tuning options for the internal params.

Definition at line 55 of file AffineInvariantDES.h.

Referenced by tuneParams().

◆ _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(), proposeSamples(), AffineInvariantStretchSampler::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 proposeSamples(), and AffineInvariantStretchSampler::proposeSamples().


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