https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
19class PMCMCBase : public Sampler, public TransientInterface
20{
21public:
23
25
29 dof_id_type getNumberOfConfigValues() const { return _confg_values[0].size(); }
30
34 dof_id_type getNumberOfConfigParams() const { return _confg_values.size(); }
35
39 dof_id_type getNumParallelProposals() const { return _num_parallel_proposals; }
40
44 const std::vector<Real> & getRandomNumbers() const;
45
49 const std::vector<Real> & getVarSamples() const;
50
58 const std::vector<std::vector<Real>> & getSamples() const;
59
63 const std::vector<const Distribution *> getPriors() const;
64
68 const Distribution * getVarPrior() const;
69
73 virtual int decisionStep() const { return 1; }
74
75protected:
80 virtual void proposeSamples();
81
82 // See Sampler.h for description
83 virtual void executeSetUp() override;
84
85 // See Sampler.h for description
86 virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override;
87
93 Real random();
94
100 unsigned int randomIndex(const unsigned int & upper_bound, const unsigned int & exclude);
101
108 std::pair<unsigned int, unsigned int> randomIndexPair(const unsigned int & upper_bound,
109 const unsigned int & exclude);
110
112 const unsigned int _num_parallel_proposals;
113
115 std::vector<const Distribution *> _priors;
116
119
121 const std::vector<Real> * _lower_bound;
122
124 const std::vector<Real> * _upper_bound;
125
127 const Real & _variance_bound;
128
130 const std::vector<Real> & _initial_values;
131
133 std::vector<std::vector<Real>> _new_samples;
134
136 std::vector<Real> _new_var_samples;
137
139 std::vector<Real> _rnd_vec;
140
141private:
146
148 const unsigned int _num_random_seeds;
149
151 unsigned int _seed_index;
152
154 std::size_t _rand_index;
155
157 std::vector<std::vector<Real>> _confg_values;
158
160 std::vector<std::vector<Real>> _new_samples_confg;
161};
const InputParameters & parameters() const
A base class used to perform Parallel Markov Chain Monte Carlo (MCMC) sampling.
Definition PMCMCBase.h:20
const std::vector< Real > * _lower_bound
Lower bounds for making the next proposal.
Definition PMCMCBase.h:121
const std::vector< std::vector< Real > > & getSamples() const
Return the proposed samples to facilitate decision making in reporters.
Definition PMCMCBase.C:197
std::vector< const Distribution * > _priors
Storage for prior distribution objects to be utilized.
Definition PMCMCBase.h:115
const std::vector< Real > & getVarSamples() const
Return the proposed variance samples to facilitate decision making in reporters.
Definition PMCMCBase.C:191
void combineWithExperimentalConfig()
Generates combinations of the new samples with the experimental configurations.
Definition PMCMCBase.C:167
const std::vector< const Distribution * > getPriors() const
Return the priors to facilitate decision making in reporters.
Definition PMCMCBase.C:203
static InputParameters validParams()
Definition PMCMCBase.C:18
dof_id_type getNumberOfConfigParams() const
Return the number of configuration parameters.
Definition PMCMCBase.h:34
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
const std::vector< Real > & _initial_values
Initial values of the input params to get the MCMC scheme started.
Definition PMCMCBase.h:130
virtual void executeSetUp() override
Definition PMCMCBase.C:128
virtual int decisionStep() const
Return the step after which decision making can begin.
Definition PMCMCBase.h:73
const Distribution * getVarPrior() const
Return the prior over variance to facilitate decision making in reporters.
Definition PMCMCBase.C:209
virtual void proposeSamples()
Fill in the _new_samples vector of vectors (happens within sampleSetUp)
Definition PMCMCBase.C:120
const Distribution * _var_prior
Storage for prior distribution object of the variance to be utilized.
Definition PMCMCBase.h:118
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 unsigned int _num_random_seeds
Initialize a certain number of random seeds. Change from the default only if you have to.
Definition PMCMCBase.h:148
std::vector< std::vector< Real > > _new_samples
Vectors of new proposed samples.
Definition PMCMCBase.h:133
std::size_t _rand_index
Running index for the random number generators.
Definition PMCMCBase.h:154
const std::vector< Real > & getRandomNumbers() const
Return the random numbers to facilitate decision making in reporters.
Definition PMCMCBase.C:185
std::vector< std::vector< Real > > _confg_values
Configuration values.
Definition PMCMCBase.h:157
std::vector< Real > _new_var_samples
Vector of new proposed variance samples.
Definition PMCMCBase.h:136
dof_id_type getNumberOfConfigValues() const
Return the number of configuration parameters.
Definition PMCMCBase.h:29
std::vector< Real > _rnd_vec
Vector of random numbers for decision making.
Definition PMCMCBase.h:139
virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override
Definition PMCMCBase.C:215
const unsigned int _num_parallel_proposals
Number of parallel proposals to be made and subApps to be executed.
Definition PMCMCBase.h:112
std::vector< std::vector< Real > > _new_samples_confg
Vectors of new proposed samples combined with the experimental configuration values.
Definition PMCMCBase.h:160
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
const std::vector< Real > * _upper_bound
Upper bounds for making the next proposal.
Definition PMCMCBase.h:124
dof_id_type getNumParallelProposals() const
Return the number of parallel proposals.
Definition PMCMCBase.h:39