https://mooseframework.inl.gov
AdaptiveImportanceSampler.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 
19 {
20 public:
22 
24 
25  // Access the initial values vector
26  const std::vector<Real> & getInitialValues() const { return _initial_values; }
27 
28  // Access the number of training samples
29  const int & getNumSamplesTrain() const { return _num_samples_train; }
30 
31  // Access use absolute value bool
32  const bool & getUseAbsoluteValue() const { return _use_absolute_value; }
33 
34  // Access the output limit
35  const Real & getOutputLimit() const { return _output_limit; }
36 
37  // Access the mean vector of the importance distribution
38  const std::vector<Real> & getImportanceVectorMean() const { return _mean_sto; }
39 
40  // Access the std vector of the importance distribution
41  const std::vector<Real> & getImportanceVectorStd() const { return _std_sto; }
42 
43  // Access the std vector of the importance distribution
44  const std::vector<const Distribution *> & getDistributionNames() const { return _distributions; }
45 
46  // Access the output limit
47  const Real & getStdFactor() const { return _std_factor; }
48 
52  virtual bool isAdaptiveSamplingCompleted() const override { return _is_sampling_completed; }
53 
54 protected:
56  virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override;
57 
59  std::vector<const Distribution *> _distributions;
60 
62  const std::vector<Real> & _proposal_std;
63 
65  const std::vector<Real> & _initial_values;
66 
69 
71  const int & _num_samples_train;
72 
75 
77  const Real & _std_factor;
78 
80  const bool & _use_absolute_value;
81 
83  const unsigned int & _num_random_seeds;
84 
87 
88 private:
90  const std::vector<std::vector<Real>> & _inputs;
91 
94 
96  std::vector<Real> _prev_value;
97 
99  std::vector<Real> _mean_sto;
100 
102  std::vector<Real> _std_sto;
103 
105  std::vector<std::vector<Real>> _inputs_sto;
106 
109 
111  const std::vector<bool> * const _gp_flag;
112 };
virtual bool isAdaptiveSamplingCompleted() const override
Returns true if the adaptive sampling is completed.
int _retraining_steps
Number of retraining performed.
int _check_step
Ensure that the MCMC algorithm proceeds in a sequential fashion.
A class used to perform Adaptive Importance Sampling using a Markov Chain Monte Carlo algorithm...
bool _is_sampling_completed
True if the sampling is completed.
std::vector< const Distribution * > _distributions
Storage for distribution objects to be utilized.
virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override
Return the sample for the given row (the sample index) and column (the parameter index) ...
std::vector< std::vector< Real > > _inputs_sto
Storage for previously accepted samples by the decision reporter system.
const std::vector< const Distribution * > & getDistributionNames() const
const std::vector< Real > & getImportanceVectorMean() const
const std::vector< std::vector< Real > > & _inputs
Storage for the inputs vector obtained from the reporter.
const std::vector< Real > & getImportanceVectorStd() const
std::vector< Real > _std_sto
Storage for standard deviations of input values for proposing the next sample.
AdaptiveImportanceSampler(const InputParameters &parameters)
const Real & _output_limit
The output limit, exceedance of which indicates failure.
const int & _num_samples_train
Number of samples to train the importance sampler.
const unsigned int & _num_random_seeds
Initialize a certain number of random seeds. Change from the default only if you have to...
const bool & _use_absolute_value
Absolute value of the model result. Use this when failure is defined as a non-exceedance rather than ...
const int & _num_importance_sampling_steps
Number of importance sampling steps (after the importance distribution has been trained) ...
const Real & _std_factor
Factor to be multiplied to the standard deviation of the proposal distribution.
const int & getNumSamplesTrain() const
const bool & getUseAbsoluteValue() const
std::vector< Real > _mean_sto
Storage for means of input values for proposing the next sample.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::vector< bool > *const _gp_flag
Indicate whether GP prediction is good or bad to influence next proposed sample.
const InputParameters & parameters() const
const std::vector< Real > & _initial_values
Initial values values vector to start the importance sampler.
const std::vector< Real > & _proposal_std
The proposal distribution standard deviations.
static InputParameters validParams()
const std::vector< Real > & getInitialValues() const
uint8_t dof_id_type
std::vector< Real > _prev_value
For proposing the next sample in the MCMC algorithm.