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

Fast Bayesian inference with the parallel active learning (partly inspired from El Gammal et al. More...

#include <BayesianActiveLearningSampler.h>

Inheritance diagram for BayesianActiveLearningSampler:
[legend]

Public Types

enum  SampleMode
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 BayesianActiveLearningSampler (const InputParameters &parameters)
 
const std::vector< std::vector< Real > > & getSampleTries () const
 Return the random samples for the GP to try in the reporter class.
 
const std::vector< Real > & getVarSampleTries () const
 Return the random variance samples for the GP to try in the reporter class.
 
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 Distribution * getVarPrior () const
 Return the prior over variance to facilitate decision making in reporters.
 
virtual int decisionStep () const
 Return the step after which decision making can begin.
 
std::vector< Real > getSampleRow (dof_id_type row_index) const
 
Real getSample (dof_id_type row_index, dof_id_type col_index) const
 
dof_id_type getNumberOfRows () const
 
dof_id_type getNumberOfCols () const
 
dof_id_type getNumberOfLocalRows () const
 
const LocalRankConfig & getRankConfig (bool batch_mode) const
 
virtual bool isAdaptiveSamplingCompleted () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObject > getSharedPtr ()
 
std::shared_ptr< const MooseObject > getSharedPtr () const
 
bool isKokkosObject () const
 
MooseApp & getMooseApp () 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 InputParameters & parameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () 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
 
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 ExecFlagEnum & getExecuteOnEnum () const
 
PerfGraph & perfGraph ()
 
T & getSampler (const std::string &name)
 
Sampler & getSampler (const std::string &name)
 
T & getSamplerByName (const SamplerName &name)
 
Sampler & getSamplerByName (const SamplerName &name)
 
const VectorPostprocessorValue & getVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValue & getVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const ScatterVectorPostprocessorValue & getScatterVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValue & getScatterVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValue & getScatterVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValue & getScatterVectorPostprocessorValueOldByName (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 Distribution & getDistribution (const std::string &name) const
 
const T & getDistribution (const std::string &name) const
 
const Distribution & getDistribution (const std::string &name) const
 
const T & getDistribution (const std::string &name) const
 
const Distribution & getDistributionByName (const DistributionName &name) const
 
const T & getDistributionByName (const std::string &name) const
 
const Distribution & getDistributionByName (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 ()
 
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) const 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 int > randomIndexPair (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 void computeSampleRow (dof_id_type i, std::vector< Real > &data) const
 
virtual void advanceGenerators (const dof_id_type count)
 
virtual void advanceGenerator (const unsigned int seed_index, const dof_id_type count)
 
void setAutoAdvanceGenerators (const bool state)
 
virtual void executeTearDown ()
 
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 ReporterContextBase & getReporterContextBaseByName (const ReporterName &reporter_name) const
 
const ReporterName & getReporterName (const std::string &param_name) const
 
virtual void addReporterDependencyHelper (const ReporterName &)
 
T & declareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const T & getRestartableData (const std::string &data_name) const
 
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
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)
 
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 std::vector< unsigned int > & _sorted_indices
 The selected sample indices to evaluate the subApp.
 
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
 
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
 
MooseApp & _restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
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 VectorPostprocessorValue & getVectorPostprocessorByNameHelper (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
 
RestartableDataValue & registerRestartableDataOnApp (std::unique_ptr< RestartableDataValue > data, THREAD_ID tid) const
 
void registerRestartableNameWithFilterOnApp (const std::string &name, Moose::RESTARTABLE_FILTER filter)
 
RestartableData< T > & declareRestartableDataHelper (const std::string &data_name, void *context, Args &&... args) 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_tries
 Number of samples to propose in each iteration (not all are sent for subApp evals)
 
std::vector< std::vector< Real > > & _inputs_test
 Storage for all the proposed samples.
 
std::vector< Real > _var_test
 Storage for all the proposed variances.
 
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
 
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_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 RestartableDataMapName _metaname
 
std::string _restartable_name
 
const std::string _ti_name
 

Detailed Description

Fast Bayesian inference with the parallel active learning (partly inspired from El Gammal et al.

2023)

Definition at line 19 of file BayesianActiveLearningSampler.h.

Constructor & Destructor Documentation

◆ BayesianActiveLearningSampler()

BayesianActiveLearningSampler::BayesianActiveLearningSampler ( const InputParameters &  parameters)

Definition at line 31 of file BayesianActiveLearningSampler.C.

33 _sorted_indices(getReporterValue<std::vector<unsigned int>>("sorted_indices")),
34 _num_tries(getParam<unsigned int>("num_tries")),
35 _inputs_test(declareRecoverableData<std::vector<std::vector<Real>>>("inputs_test")),
37{
38 _inputs_test.resize(_num_tries, std::vector<Real>(_priors.size()));
39}
const std::vector< unsigned int > & _sorted_indices
The selected sample indices to evaluate the subApp.
const unsigned int & _num_tries
Number of samples to propose in each iteration (not all are sent for subApp evals)
std::vector< Real > _var_test
Storage for all the proposed variances.
std::vector< std::vector< Real > > & _inputs_test
Storage for all the proposed samples.
const InputParameters & parameters() 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 T & getReporterValue(const std::string &param_name, const std::size_t time_index=0)
T & declareRecoverableData(const std::string &data_name, Args &&... args)

Member Function Documentation

◆ combineWithExperimentalConfig()

void PMCMCBase::combineWithExperimentalConfig ( )
privateinherited

Generates combinations of the new samples with the experimental configurations.

Definition at line 178 of file PMCMCBase.C.

179{
180 unsigned int index1;
181 int index2 = -1;
182 std::vector<Real> tmp;
183 for (unsigned int i = 0; i < _num_parallel_proposals * _confg_values[0].size(); ++i)
184 {
185 index1 = i % _num_parallel_proposals;
186 if (index1 == 0)
187 ++index2;
188 tmp = _new_samples[index1];
189 for (unsigned int j = 0; j < _confg_values.size(); ++j)
190 tmp.push_back(_confg_values[j][index2]);
191 _new_samples_confg[i] = tmp;
192 }
193}
std::vector< std::vector< Real > > & _new_samples_confg
Vectors of new proposed samples combined with the experimental configuration values.
Definition PMCMCBase.h:160
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
const unsigned int _num_parallel_proposals
Number of parallel proposals to be made and subApps to be executed.
Definition PMCMCBase.h:112

Referenced by PMCMCBase::executeSetUp().

◆ computeSample()

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

Implements Sampler.

Definition at line 226 of file PMCMCBase.C.

227{
228 return _new_samples_confg[row_index][col_index];
229}

◆ decisionStep()

virtual int PMCMCBase::decisionStep ( ) const
inlinevirtualinherited

Return the step after which decision making can begin.

Reimplemented in AffineInvariantDES, AffineInvariantStretchSampler, and IndependentGaussianMH.

Definition at line 73 of file PMCMCBase.h.

73{ return 1; }

Referenced by PMCMCDecision::execute().

◆ executeSetUp()

void PMCMCBase::executeSetUp ( )
overrideprotectedvirtualinherited

Reimplemented from Sampler.

Definition at line 131 of file PMCMCBase.C.

132{
134 _rand_index = 0;
135
136 // Filling the new_samples vector of vectors with new proposal samples
138
139 // At the first step, override with user-provided initial values
140 if (_t_step < 1)
141 for (unsigned int i = 0; i < _num_parallel_proposals; ++i)
143
144 // Draw random numbers to facilitate decision making later on
145 for (unsigned int j = 0; j < _num_parallel_proposals; ++j)
146 _rnd_vec[j] = random();
147
148 // Combine the proposed samples with experimental configurations
150}
std::vector< Real > & _rnd_vec
Vector of random numbers for decision making.
Definition PMCMCBase.h:139
void combineWithExperimentalConfig()
Generates combinations of the new samples with the experimental configurations.
Definition PMCMCBase.C:178
Real random()
Sample a random number between 0 and 1.
Definition PMCMCBase.C:153
unsigned int _seed_index
Generator index when requesting random numbers.
Definition PMCMCBase.h:151
const std::vector< Real > & _initial_values
Initial values of the input params to get the MCMC scheme started.
Definition PMCMCBase.h:130
virtual void proposeSamples()
Fill in the _new_samples vector of vectors (happens within sampleSetUp)
Definition PMCMCBase.C:123
std::size_t _rand_index
Running index for the random number generators.
Definition PMCMCBase.h:154

◆ 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 214 of file PMCMCBase.C.

215{
216 return _priors;
217}

◆ getRandomNumbers()

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

Return the random numbers to facilitate decision making in reporters.

Definition at line 196 of file PMCMCBase.C.

197{
198 return _rnd_vec;
199}

◆ 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 208 of file PMCMCBase.C.

209{
210 return _new_samples;
211}

◆ getSampleTries()

const std::vector< std::vector< Real > > & BayesianActiveLearningSampler::getSampleTries ( ) const

Return the random samples for the GP to try in the reporter class.

Definition at line 42 of file BayesianActiveLearningSampler.C.

43{
44 return _inputs_test;
45}

◆ getVarPrior()

const Distribution * PMCMCBase::getVarPrior ( ) const
inherited

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

Definition at line 220 of file PMCMCBase.C.

221{
222 return _var_prior;
223}
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 202 of file PMCMCBase.C.

203{
204 return _new_var_samples;
205}
std::vector< Real > & _new_var_samples
Vector of new proposed variance samples.
Definition PMCMCBase.h:136

◆ getVarSampleTries()

const std::vector< Real > & BayesianActiveLearningSampler::getVarSampleTries ( ) const

Return the random variance samples for the GP to try in the reporter class.

Definition at line 48 of file BayesianActiveLearningSampler.C.

49{
50 return _var_test;
51}

◆ proposeSamples()

void BayesianActiveLearningSampler::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 54 of file BayesianActiveLearningSampler.C.

55{
56 auto fill_vector = [&](std::vector<Real> & vector)
57 {
58 for (unsigned int i = 0; i < _priors.size(); ++i)
59 vector[i] = _priors[i]->quantile(random());
60 };
61
62 /* If step is 1, randomly generate the samples.
63 Else, generate the samples informed by the GP from the reporter "sorted_indices" */
64 for (dof_id_type i = 0; i < _num_parallel_proposals; ++i)
65 {
66 if (_t_step < 1)
67 {
68 fill_vector(_new_samples[i]);
69 if (_var_prior)
71 }
72 else
73 {
75 if (_var_prior)
77 }
78 }
79
80 /* Finally, generate several new samples randomly for the GP to try and pass it to the
81 reporter */
82 for (dof_id_type i = 0; i < _num_tries; ++i)
83 {
84 fill_vector(_inputs_test[i]);
85 if (_var_prior)
87 }
88}
virtual Real quantile(const Real &y) const=0

◆ 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 153 of file PMCMCBase.C.

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

Referenced by PMCMCBase::executeSetUp(), PMCMCBase::proposeSamples(), AffineInvariantDES::proposeSamples(), AffineInvariantStretchSampler::proposeSamples(), 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 159 of file PMCMCBase.C.

160{
161 auto req_index = exclude;
162 while (req_index == exclude)
163 req_index = getRandl(_rand_index++, 0, upper_bound, _seed_index);
164 return req_index;
165}
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 168 of file PMCMCBase.C.

169{
170 auto req_index1 = randomIndex(upper_bound, exclude);
171 auto req_index2 = req_index1;
172 while (req_index1 == req_index2)
173 req_index2 = randomIndex(upper_bound, exclude);
174 return {req_index1, req_index2};
175}
unsigned int randomIndex(const unsigned int &upper_bound, const unsigned int &exclude)
Sample a random index excluding a specified index.
Definition PMCMCBase.C:159

Referenced by AffineInvariantDES::proposeSamples().

◆ validParams()

InputParameters BayesianActiveLearningSampler::validParams ( )
static

Definition at line 17 of file BayesianActiveLearningSampler.C.

18{
20 params.addClassDescription("Fast Bayesian inference with the parallel active learning (partly "
21 "inspired from El Gammal et al. 2023).");
23 "sorted_indices", "The sorted sample indices in order of importance to evaluate the subApp.");
24 params.addRequiredRangeCheckedParam<unsigned int>(
25 "num_tries",
26 "num_tries>0",
27 "Number of samples to propose in each iteration (not all are sent for subApp evals).");
28 return params;
29}
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
void addRequiredParam(const std::string &name, 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::executeSetUp(), PMCMCBase::PMCMCBase(), and IndependentGaussianMH::proposeSamples().

◆ _inputs_test

std::vector<std::vector<Real> >& BayesianActiveLearningSampler::_inputs_test
private

Storage for all the proposed samples.

Definition at line 47 of file BayesianActiveLearningSampler.h.

Referenced by BayesianActiveLearningSampler(), getSampleTries(), and proposeSamples().

◆ _lower_bound

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

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

◆ _num_tries

const unsigned int& BayesianActiveLearningSampler::_num_tries
private

Number of samples to propose in each iteration (not all are sent for subApp evals)

Definition at line 44 of file BayesianActiveLearningSampler.h.

Referenced by BayesianActiveLearningSampler(), and 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().

◆ _sorted_indices

const std::vector<unsigned int>& BayesianActiveLearningSampler::_sorted_indices
protected

The selected sample indices to evaluate the subApp.

Definition at line 40 of file BayesianActiveLearningSampler.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(), AffineInvariantStretchSampler::proposeSamples(), and proposeSamples().

◆ _var_test

std::vector<Real> BayesianActiveLearningSampler::_var_test
private

Storage for all the proposed variances.

Definition at line 50 of file BayesianActiveLearningSampler.h.

Referenced by getVarSampleTries(), and 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 AffineInvariantStretchSampler::proposeSamples().


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