ROL
ROL_MonteCarloGenerator.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_MONTECARLOGENERATOR_HPP
11 #define ROL_MONTECARLOGENERATOR_HPP
12 
13 #include "ROL_SampleGenerator.hpp"
14 #include "ROL_Distribution.hpp"
15 
16 namespace ROL {
17 
18 template<typename Real>
19 class MonteCarloGenerator : public SampleGenerator<Real> {
20 private:
21  std::vector<std::vector<Real>> data_;
22  const std::vector<Ptr<Distribution<Real>>> dist_;
23 
24  int nSamp_;
25  const bool use_normal_;
26  const bool use_SA_;
27  const bool adaptive_;
28  const int numNewSamps_;
29  const bool useDist_;
30  const int seed_;
31 
32  Real sum_val_;
33  Real sum_val2_;
34  Real sum_ng_;
35  Real sum_ng2_;
36 
37  Real ierf(Real input) const;
38  Real random(void) const;
39  std::vector<std::vector<Real>> sample(int nSamp, bool store = true, bool refine = false);
40 
41 public:
42  MonteCarloGenerator(int nSamp,
43  const std::vector<Ptr<Distribution<Real>>> &dist,
44  const Ptr<BatchManager<Real>> &bman,
45  bool use_SA = false,
46  bool adaptive = false,
47  int numNewSamps = 0,
48  int seed = 123454321);
49 
50  MonteCarloGenerator(int nSamp,
51  std::vector<std::vector<Real>> &bounds,
52  const Ptr<BatchManager<Real>> &bman,
53  bool use_SA = false,
54  bool adaptive = false,
55  int numNewSamps = 0,
56  int seed = 123454321);
57 
58  MonteCarloGenerator(int nSamp,
59  const std::vector<Real> &mean,
60  const std::vector<Real> &std,
61  const Ptr<BatchManager<Real>> &bman,
62  bool use_SA = false,
63  bool adaptive = false,
64  int numNewSamps = 0,
65  int seed = 123454321);
66 
67  void update( const Vector<Real> &x ) override;
68  Real computeError( std::vector<Real> &vals ) override;
69  Real computeError( std::vector<Ptr<Vector<Real>>> &vals, const Vector<Real> &x ) override;
70  void refine(void) override;
71  int numGlobalSamples(void) const override;
72 
73 };
74 
75 }
76 
78 
79 #endif
MonteCarloGenerator(int nSamp, const std::vector< Ptr< Distribution< Real >>> &dist, const Ptr< BatchManager< Real >> &bman, bool use_SA=false, bool adaptive=false, int numNewSamps=0, int seed=123454321)
int numGlobalSamples(void) const override
Real computeError(std::vector< Real > &vals) override
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
const std::vector< Ptr< Distribution< Real > > > dist_
void update(const Vector< Real > &x) override
std::vector< std::vector< Real > > sample(int nSamp, bool store=true, bool refine=false)
std::vector< std::vector< Real > > data_