LCOV - code coverage report
Current view: top level - include/reporters - AdaptiveMonteCarloDecision.h (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: f45d79 Lines: 2 2 100.0 %
Date: 2025-07-25 05:00:46 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14