Main.hpp 933 Bytes
Newer Older
1
2
3
#ifndef MAIN_HPP
#define MAIN_HPP

4
#include "StochasticCollocation.hpp"
niklas.baumgarten's avatar
niklas.baumgarten committed
5
#include "MultilevelEstimator.hpp"
6
#include "MonteCarlo.hpp"
niklas.baumgarten's avatar
niklas.baumgarten committed
7

niklas.baumgarten's avatar
niklas.baumgarten committed
8
#include "Estimator.hpp"
9

niklas.baumgarten's avatar
niklas.baumgarten committed
10
11

bool PowerOfTwo(int n) {
12
  if (n == 0) return false;
niklas.baumgarten's avatar
niklas.baumgarten committed
13
14
15
  return (ceil(log2(n)) == floor(log2(n)));
}

16
17
class MainProgram {
private:
niklas.baumgarten's avatar
niklas.baumgarten committed
18
  int verbose = 1;
19

20
21
  std::string estimatorName = "MultilevelMonteCarlo";

22
public:
niklas.baumgarten's avatar
niklas.baumgarten committed
23
  std::unique_ptr<Estimator> estimator;
niklas.baumgarten's avatar
niklas.baumgarten committed
24

25
  MainProgram() {
niklas.baumgarten's avatar
niklas.baumgarten committed
26
    config.get("MainVerbose", verbose);
27
28
    config.get("Estimator", estimatorName);

niklas.baumgarten's avatar
niklas.baumgarten committed
29
30
    estimator = EstimatorCreator(estimatorName).
      CreateUnique();
niklas.baumgarten's avatar
niklas.baumgarten committed
31
32
  }

niklas.baumgarten's avatar
niklas.baumgarten committed
33
  int Run() const {
niklas.baumgarten's avatar
niklas.baumgarten committed
34
    config.PrintInfo();
35
    mout.StartBlock(estimator->Name() + " Experiment");
niklas.baumgarten's avatar
logging    
niklas.baumgarten committed
36
    mout << "Start" << endl;
37
    estimator->Method();
niklas.baumgarten's avatar
niklas.baumgarten committed
38
39
40
    mout.EndBlock();
    mout << endl;

41
42
43
    estimator->MultilevelResults();
    estimator->ExponentResults();
    estimator->EstimatorResults();
niklas.baumgarten's avatar
niklas.baumgarten committed
44
45
46

    return 0;
  }
47
48
49
};

#endif //MAIN_HPP