Line data Source code
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 : #pragma once 10 : 11 : #include "GeneralReporter.h" 12 : #include "AdaptiveImportanceSampler.h" 13 : #include "ParallelSubsetSimulation.h" 14 : 15 : /** 16 : * AdaptiveMonteCarloDecision will help make sample accept/reject decisions in adaptive Monte Carlo 17 : * schemes. 18 : */ 19 : class AdaptiveMonteCarloDecision : public GeneralReporter 20 : { 21 : public: 22 : static InputParameters validParams(); 23 : AdaptiveMonteCarloDecision(const InputParameters & parameters); 24 672 : virtual void initialize() override {} 25 672 : virtual void finalize() override {} 26 : virtual void execute() override; 27 : 28 : protected: 29 : /// Model output value from SubApp 30 : const std::vector<Real> & _output_value; 31 : 32 : /// Modified value of model output by this reporter class 33 : std::vector<Real> & _output_required; 34 : 35 : /// Model input data that is uncertain 36 : std::vector<std::vector<Real>> & _inputs; 37 : 38 : private: 39 : /** 40 : * This reinitializes the Markov chain to the starting value 41 : * until the Gaussian process training is completed. 42 : */ 43 : void reinitChain(); 44 : 45 : /// The adaptive Monte Carlo sampler 46 : Sampler & _sampler; 47 : 48 : /// Adaptive Importance Sampler 49 : const AdaptiveImportanceSampler * const _ais; 50 : 51 : /// Parallel Subset Simulation sampler 52 : const ParallelSubsetSimulation * const _pss; 53 : 54 : /// Ensure that the MCMC algorithm proceeds in a sequential fashion 55 : int _check_step; 56 : 57 : /// Communicator that was split based on samples that have rows 58 : libMesh::Parallel::Communicator & _local_comm; 59 : 60 : /// Storage for previously accepted input values. This helps in making decision on the next proposed inputs. 61 : std::vector<std::vector<Real>> _prev_val; 62 : 63 : /// Storage for previously accepted output value. 64 : std::vector<Real> _prev_val_out; 65 : 66 : /// Storage for the previously accepted sample inputs across all the subsets 67 : std::vector<std::vector<Real>> _inputs_sto; 68 : 69 : /// Store the sorted input samples according to their corresponding outputs 70 : std::vector<std::vector<Real>> _inputs_sorted; 71 : 72 : /// Storage for previously accepted sample outputs across all the subsets 73 : std::vector<Real> _outputs_sto; 74 : 75 : /// Store the sorted output sample values 76 : std::vector<Real> _output_sorted; 77 : 78 : /// Store the intermediate ouput failure thresholds 79 : Real _output_limit; 80 : 81 : /// Check if a GP is used 82 : const bool _gp_used; 83 : 84 : /// Store the GP training samples 85 : const int * const _gp_training_samples; 86 : };