21 params.
addClassDescription(
"Generic reporter which decides whether or not to accept a proposed " 22 "sample in parallel Markov chain Monte Carlo type of algorithms.");
24 "Value of the model output from the SubApp.");
28 "Modified value of the model output from this reporter class.");
29 params.
addParam<ReporterValueName>(
"inputs",
"inputs",
"Uncertain inputs to the model.");
30 params.
addParam<ReporterValueName>(
"tpm",
"tpm",
"The transition probability matrix.");
31 params.
addParam<ReporterValueName>(
"variance",
"variance",
"Model variance term.");
33 "noise",
"noise",
"Model noise term to pass to Likelihoods object.");
35 params.
addRequiredParam<std::vector<UserObjectName>>(
"likelihoods",
"Names of likelihoods.");
43 _outputs_required(declareValue<
std::vector<
Real>>(
"outputs_required")),
44 _inputs(declareValue<
std::vector<
std::vector<
Real>>>(
"inputs")),
45 _tpm(declareValue<
std::vector<
Real>>(
"tpm")),
46 _variance(declareValue<
std::vector<
Real>>(
"variance")),
47 _noise(declareValue<
Real>(
"noise")),
48 _sampler(getSampler(
"sampler")),
49 _pmcmc(dynamic_cast<const
PMCMCBase *>(&_sampler)),
50 _rnd_vec(_pmcmc->getRandomNumbers()),
51 _new_var_samples(_pmcmc->getVarSamples()),
52 _priors(_pmcmc->getPriors()),
53 _var_prior(_pmcmc->getVarPrior()),
54 _local_comm(_sampler.getLocalComm()),
55 _check_step(
std::numeric_limits<
int>::
max())
58 for (
const UserObjectName &
name :
getParam<std::vector<UserObjectName>>(
"likelihoods"))
63 paramError(
"sampler",
"The selected sampler is not of type MCMC.");
72 for (
unsigned int i = 0; i <
_props; ++i)
84 for (
unsigned int i = 0; i < evidence.size(); ++i)
87 for (
unsigned int j = 0;
j <
_priors.size(); ++
j)
88 evidence[i] += (std::log(
_priors[
j]->pdf(input_matrix(i,
j))) -
114 const std::vector<Real> & )
122 const std::vector<Real> & tv,
123 const unsigned int & parallel_index)
125 if (tv[parallel_index] >=
_rnd_vec[parallel_index])
128 req_inputs[
k] = input_matrix(parallel_index,
k);
136 input_matrix(parallel_index,
k) =
_data_prev(parallel_index,
k);
160 data_in(ss,
j) = data[
j];
167 std::vector<Real> evidence(
_props);
178 for (
unsigned int i = 0; i <
_props; ++i)
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
dof_id_type _num_confg_values
Storage for the number of experimental configuration values.
dof_id_type getNumberOfConfigValues() const
Return the number of configuration parameters.
PMCMCDecision will help making sample accept/reject decisions in MCMC schemes (for e...
virtual Real pdf(const Real &x) const=0
dof_id_type getNumberOfConfigParams() const
Return the number of configuration parameters.
virtual void computeEvidence(std::vector< Real > &evidence, const DenseMatrix< Real > &input_matrix)
Compute the evidence (aka, betterness of the proposed sample vs the previous)
Real & _noise
Model noise term to pass to Likelihoods object.
std::vector< Real > getNextLocalRow()
dof_id_type getLocalRowBegin() const
static InputParameters validParams()
dof_id_type _num_confg_params
Storage for the number of experimental configuration parameters.
virtual void execute() override
dof_id_type getNumberOfLocalRows() const
virtual const std::string & name() const
const std::vector< Real > & _output_value
Model output value from SubApp.
std::vector< Real > & _variance
Model variance term.
auto max(const L &left, const R &right)
int _check_step
Ensure that the MCMC algorithm proceeds in a sequential fashion.
dof_id_type getNumParallelProposals() const
Return the number of parallel proposals.
libMesh::Parallel::Communicator & _local_comm
Communicator that was split based on samples that have rows.
PMCMCDecision(const InputParameters ¶meters)
DenseMatrix< Real > _data_prev
Storage for previous inputs.
std::vector< Real > _var_prev
Storage for previous variances.
const PMCMCBase *const _pmcmc
MCMC sampler base.
const T & getParam(const std::string &name) const
virtual void computeTransitionVector(std::vector< Real > &tv, const std::vector< Real > &evidence)
Compute the transition probability vector (after the computation of evidence)
void paramError(const std::string ¶m, Args... args) const
const ReporterMode REPORTER_MODE_DISTRIBUTED
static InputParameters validParams()
virtual void nextSeeds()
Compute the next set of seeds to facilitate proposals.
dof_id_type getLocalRowEnd() const
const Distribution * _var_prior
Storage for the prior over the variance.
dof_id_type getNumberOfRows() const
const std::vector< const Distribution * > _priors
Storage for the priors.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("StochasticToolsApp", PMCMCDecision)
dof_id_type _props
Storage for the number of parallel proposals.
LikelihoodFunctionBase * getLikelihoodFunctionByName(const UserObjectName &name) const
Lookup a LikelihoodFunction object by name and return pointer.
virtual void nextSamples(std::vector< Real > &req_inputs, DenseMatrix< Real > &input_matrix, const std::vector< Real > &tv, const unsigned int ¶llel_index)
Resample inputs given the transition vector (after transition vector computed)
static InputParameters validParams()
virtual int decisionStep() const
Return the step after which decision making can begin.
std::vector< const LikelihoodFunctionBase * > _likelihoods
Storage for the likelihood objects to be utilized.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< Real > _outputs_prev
Storage for previous outputs.
Sampler & _sampler
The MCMC sampler.
const std::vector< Real > & _new_var_samples
Storage for new proposed variance samples.
const std::vector< Real > & _rnd_vec
Storage for the random numbers for decision making.
std::vector< Real > & _outputs_required
Transfer the right outputs to the file.
std::vector< Real > & _tpm
Transition probability matrix.
static const std::string k
void ErrorVector unsigned int
std::vector< std::vector< Real > > & _inputs
Model input data that is uncertain.
dof_id_type getNumberOfCols() const
A base class used to perform Parallel Markov Chain Monte Carlo (MCMC) sampling.