https://mooseframework.inl.gov
PMCMCBase.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "Sampler.h"
13 #include "TransientInterface.h"
14 #include "Distribution.h"
15 
19 class PMCMCBase : public Sampler, public TransientInterface
20 {
21 public:
23 
25 
29  dof_id_type getNumberOfConfigValues() const { return _confg_values[0].size(); }
30 
35 
40 
44  const std::vector<Real> & getRandomNumbers() const;
45 
49  const std::vector<Real> & getVarSamples() const;
50 
54  const std::vector<const Distribution *> getPriors() const;
55 
59  const Distribution * getVarPrior() const;
60 
64  virtual int decisionStep() const { return 1; }
65 
66 protected:
71  virtual void proposeSamples(const unsigned int seed_value);
72 
73  // See Sampler.h for description
74  virtual void sampleSetUp(const Sampler::SampleMode mode) override;
75 
76  // See Sampler.h for description
77  virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override;
78 
86  void randomIndex(const unsigned int & upper_bound,
87  const unsigned int & exclude,
88  const unsigned int & seed,
89  unsigned int & req_index);
90 
99  void randomIndexPair(const unsigned int & upper_bound,
100  const unsigned int & exclude,
101  const unsigned int & seed,
102  unsigned int & req_index1,
103  unsigned int & req_index2);
104 
106  const unsigned int _num_parallel_proposals;
107 
109  std::vector<const Distribution *> _priors;
110 
113 
115  const std::vector<Real> * _lower_bound;
116 
118  const std::vector<Real> * _upper_bound;
119 
122 
124  const std::vector<Real> & _initial_values;
125 
127  std::vector<std::vector<Real>> _new_samples;
128 
130  std::vector<Real> _new_var_samples;
131 
133  std::vector<Real> _rnd_vec;
134 
135 private:
140 
142  const unsigned int _num_random_seeds;
143 
145  std::vector<std::vector<Real>> _confg_values;
146 
148  std::vector<std::vector<Real>> _new_samples_confg;
149 };
dof_id_type getNumberOfConfigValues() const
Return the number of configuration parameters.
Definition: PMCMCBase.h:29
const unsigned int _num_random_seeds
Initialize a certain number of random seeds. Change from the default only if you have to...
Definition: PMCMCBase.h:142
const unsigned int _num_parallel_proposals
Number of parallel proposals to be made and subApps to be executed.
Definition: PMCMCBase.h:106
dof_id_type getNumberOfConfigParams() const
Return the number of configuration parameters.
Definition: PMCMCBase.h:34
const std::vector< Real > & _initial_values
Initial values of the input params to get the MCMC scheme started.
Definition: PMCMCBase.h:124
std::vector< std::vector< Real > > _new_samples_confg
Vectors of new proposed samples combined with the experimental configuration values.
Definition: PMCMCBase.h:148
const std::vector< Real > * _lower_bound
Lower bounds for making the next proposal.
Definition: PMCMCBase.h:115
void combineWithExperimentalConfig()
Generates combinations of the new samples with the experimental configurations.
Definition: PMCMCBase.C:165
PMCMCBase(const InputParameters &parameters)
Definition: PMCMCBase.C:46
std::vector< const Distribution * > _priors
Storage for prior distribution objects to be utilized.
Definition: PMCMCBase.h:109
int _check_step
Ensure that the MCMC algorithm proceeds in a sequential fashion.
Definition: PMCMCBase.h:121
const std::vector< const Distribution * > getPriors() const
Return the priors to facilitate decision making in reporters.
Definition: PMCMCBase.C:195
virtual void proposeSamples(const unsigned int seed_value)
Fill in the _new_samples vector of vectors (happens within sampleSetUp)
Definition: PMCMCBase.C:116
const Distribution * getVarPrior() const
Return the prior over variance to facilitate decision making in reporters.
Definition: PMCMCBase.C:201
dof_id_type getNumParallelProposals() const
Return the number of parallel proposals.
Definition: PMCMCBase.h:39
std::vector< Real > _new_var_samples
Vector of new proposed variance samples.
Definition: PMCMCBase.h:130
std::vector< Real > _rnd_vec
Vector of random numbers for decision making.
Definition: PMCMCBase.h:133
const std::vector< Real > * _upper_bound
Upper bounds for making the next proposal.
Definition: PMCMCBase.h:118
void randomIndexPair(const unsigned int &upper_bound, const unsigned int &exclude, const unsigned int &seed, unsigned int &req_index1, unsigned int &req_index2)
Sample two random indices without repitition excluding a specified index.
Definition: PMCMCBase.C:152
const std::vector< Real > & getVarSamples() const
Return the proposed variance samples to facilitate decision making in reporters.
Definition: PMCMCBase.C:189
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< std::vector< Real > > _new_samples
Vectors of new proposed samples.
Definition: PMCMCBase.h:127
virtual void sampleSetUp(const Sampler::SampleMode mode) override
Definition: PMCMCBase.C:124
const Distribution * _var_prior
Storage for prior distribution object of the variance to be utilized.
Definition: PMCMCBase.h:112
const std::vector< Real > & getRandomNumbers() const
Return the random numbers to facilitate decision making in reporters.
Definition: PMCMCBase.C:183
virtual int decisionStep() const
Return the step after which decision making can begin.
Definition: PMCMCBase.h:64
const InputParameters & parameters() const
void randomIndex(const unsigned int &upper_bound, const unsigned int &exclude, const unsigned int &seed, unsigned int &req_index)
Sample a random index excluding a specified index.
Definition: PMCMCBase.C:141
std::vector< std::vector< Real > > _confg_values
Configuration values.
Definition: PMCMCBase.h:145
virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override
Definition: PMCMCBase.C:207
static InputParameters validParams()
Definition: PMCMCBase.C:18
uint8_t dof_id_type
A base class used to perform Parallel Markov Chain Monte Carlo (MCMC) sampling.
Definition: PMCMCBase.h:19