https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
20public:
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
54protected:
55 virtual void executeSetUp() override;
57 virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override;
58
60 std::vector<const Distribution *> _distributions;
61
63 const std::vector<Real> & _proposal_std;
64
66 const std::vector<Real> & _initial_values;
67
69 const Real & _output_limit;
70
72 const int & _num_samples_train;
73
76
78 const Real & _std_factor;
79
81 const bool & _use_absolute_value;
82
84 const unsigned int & _num_random_seeds;
85
88
89private:
91 const std::vector<std::vector<Real>> & _inputs;
92
94 std::vector<Real> _prev_value;
95
97 std::vector<Real> _mean_sto;
98
100 std::vector<Real> _std_sto;
101
103 std::vector<std::vector<Real>> _inputs_sto;
104
107
109 const std::vector<bool> * const _gp_flag;
110};
A class used to perform Adaptive Importance Sampling using a Markov Chain Monte Carlo algorithm.
const bool & getUseAbsoluteValue() const
virtual bool isAdaptiveSamplingCompleted() const override
Returns true if the adaptive sampling is completed.
std::vector< Real > _mean_sto
Storage for means of input values for proposing the next sample.
std::vector< const Distribution * > _distributions
Storage for distribution objects to be utilized.
const std::vector< bool > *const _gp_flag
Indicate whether GP prediction is good or bad to influence next proposed sample.
bool _is_sampling_completed
True if the sampling is completed.
const unsigned int & _num_random_seeds
Initialize a certain number of random seeds. Change from the default only if you have to.
const int & _num_importance_sampling_steps
Number of importance sampling steps (after the importance distribution has been trained)
int _retraining_steps
Number of retraining performed.
const Real & _output_limit
The output limit, exceedance of which indicates failure.
virtual void executeSetUp() override
static InputParameters validParams()
const int & _num_samples_train
Number of samples to train the importance sampler.
const Real & _std_factor
Factor to be multiplied to the standard deviation of the proposal distribution.
std::vector< std::vector< Real > > _inputs_sto
Storage for previously accepted samples by the decision reporter system.
const std::vector< Real > & getImportanceVectorMean() const
std::vector< Real > _std_sto
Storage for standard deviations of input values for proposing the next sample.
const std::vector< Real > & getImportanceVectorStd() const
std::vector< Real > _prev_value
For proposing the next sample in the MCMC algorithm.
const std::vector< Real > & _initial_values
Initial values values vector to start the importance sampler.
const std::vector< std::vector< Real > > & _inputs
Storage for the inputs vector obtained from the reporter.
const std::vector< Real > & _proposal_std
The proposal distribution standard deviations.
const std::vector< Real > & getInitialValues() const
const std::vector< const Distribution * > & getDistributionNames() const
const bool & _use_absolute_value
Absolute value of the model result. Use this when failure is defined as a non-exceedance rather than ...
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)
const InputParameters & parameters() const