https://mooseframework.inl.gov
MorrisReporter.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 "GeneralReporter.h"
13 #include "VectorCalculators.h"
14 
15 #include "nlohmann/json.h"
16 
18 {
19 public:
22 
23  virtual void initialize() override final;
24 
25  virtual void execute() override final {}
26  virtual void finalize() override final {}
27  virtual void store(nlohmann::json & json) const override;
28 
29 private:
33  template <typename DataType>
34  void declareValueHelper(const ReporterName & r_name);
35 
38 
40  const std::vector<Real> & _ci_levels;
41 
43  const unsigned int & _ci_replicates;
44 
46  const unsigned int & _ci_seed;
47 
50 };
51 
52 template <typename DataType>
53 using MorrisState =
54  std::map<std::string, std::pair<std::vector<DataType>, std::vector<std::vector<DataType>>>>;
55 
56 template <typename DataType>
57 class MorrisReporterContext : public ReporterGeneralContext<MorrisState<DataType>>
58 {
59 public:
61  const MooseObject & producer,
63  Sampler & sampler,
64  const std::vector<DataType> & data);
65 
67  const MooseObject & producer,
69  Sampler & sampler,
70  const std::vector<DataType> & data,
71  const MooseEnum & ci_method,
72  const std::vector<Real> & ci_levels,
73  unsigned int ci_replicates,
74  unsigned int ci_seed);
75 
76  virtual void finalize() override;
77  virtual std::string type() const override
78  {
79  return "MorrisSensitivity<" + MooseUtils::prettyCppType<DataType>() + ">";
80  }
81 
82 private:
87  std::vector<DataType> computeElementaryEffects(const RealEigenMatrix & x,
88  const std::vector<DataType> & y) const;
89 
92 
94  const std::vector<DataType> & _data;
95 
97  std::unique_ptr<StochasticTools::Calculator<std::vector<DataType>, DataType>> _mu_calc;
98  std::unique_ptr<StochasticTools::Calculator<std::vector<DataType>, DataType>> _mustar_calc;
99  std::unique_ptr<StochasticTools::Calculator<std::vector<DataType>, DataType>> _sig_calc;
100 
102  std::unique_ptr<StochasticTools::BootstrapCalculator<std::vector<DataType>, DataType>>
104  std::unique_ptr<StochasticTools::BootstrapCalculator<std::vector<DataType>, DataType>>
106  std::unique_ptr<StochasticTools::BootstrapCalculator<std::vector<DataType>, DataType>>
108 };
virtual void finalize() override
virtual void execute() override final
const ReporterState< MorrisState< DataType > > & state() const
static InputParameters validParams()
const unsigned int & _ci_seed
Random seed for producing CI replicates.
std::unique_ptr< StochasticTools::BootstrapCalculator< std::vector< DataType >, DataType > > _ci_mustar_calc
void declareValueHelper(const ReporterName &r_name)
Helper for adding Morris reporter values.
const std::vector< double > y
const std::vector< Real > & _ci_levels
CI levels to be computed.
std::vector< DataType > computeElementaryEffects(const RealEigenMatrix &x, const std::vector< DataType > &y) const
Function for computing elementary effects for a single set of trajectories This is meant to be specia...
const unsigned int & _ci_replicates
Number of CI replicates to use in Bootstrap methods.
const std::vector< double > x
virtual void initialize() override final
Sampler & _sampler
Morris sampler (don&#39;t need any specific functions, but should be this type)
std::map< std::string, std::pair< std::vector< DataType >, std::vector< std::vector< DataType > >> > MorrisState
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealEigenMatrix
virtual void finalize() override final
MorrisReporterContext(const libMesh::ParallelObject &other, const MooseObject &producer, ReporterState< MorrisState< DataType >> &state, Sampler &sampler, const std::vector< DataType > &data)
virtual std::string type() const override
std::unique_ptr< StochasticTools::Calculator< std::vector< DataType >, DataType > > _mu_calc
Storage for the Calculator object for the desired stat, this is created in constructor.
bool _initialized
Whether or not initialize() has been called for reporter value declaration.
const std::vector< DataType > & _data
Data used for the statistic calculation.
const InputParameters & parameters() const
Sampler & _sampler
Morris sampler (don&#39;t need any specific functions, but should be this type)
std::unique_ptr< StochasticTools::Calculator< std::vector< DataType >, DataType > > _sig_calc
MorrisReporter(const InputParameters &parameters)
virtual void store(nlohmann::json &json) const override
std::unique_ptr< StochasticTools::BootstrapCalculator< std::vector< DataType >, DataType > > _ci_sig_calc
std::unique_ptr< StochasticTools::BootstrapCalculator< std::vector< DataType >, DataType > > _ci_mu_calc
Storage for the BootstrapCalculator for the desired confidence interval calculations (optional) ...
std::unique_ptr< StochasticTools::Calculator< std::vector< DataType >, DataType > > _mustar_calc