MonteCarlo.hpp 1.66 KB
Newer Older
1
2
3
#ifndef MLMC_MC_HPP
#define MLMC_MC_HPP

niklas.baumgarten's avatar
niklas.baumgarten committed
4
#include "montecarlo/datastructure/EmpiricMeasures.hpp"
5
6
7
#include "pdesolver/PDESolverCreator.hpp"

#include "mesh/MeshesCreator.hpp"
8
9


10
class MonteCarlo {
niklas.baumgarten's avatar
niklas.baumgarten committed
11
protected:
niklas.baumgarten's avatar
niklas.baumgarten committed
12
    int verbose = 1;
13

niklas.baumgarten's avatar
niklas.baumgarten committed
14
15
    int plotting = 0;

16
17
18
19
20
21
    std::string problemName = "DummyStochasticProblem1D";

    std::string modelName = "DummyPDESolver";

    int degree = 1;

22
    void method();
23

24
    void computeSampleSolution(int m, SampleID &id, SampleSolution &solution);
niklas.baumgarten's avatar
niklas.baumgarten committed
25

26
27
    void readConfigEntries();

niklas.baumgarten's avatar
niklas.baumgarten committed
28
public:
29
    Level level;
niklas.baumgarten's avatar
niklas.baumgarten committed
30
    bool onlyFine;
niklas.baumgarten's avatar
niklas.baumgarten committed
31
32
33
34
35
36
37

    SampleCounter ctr;
    Sums sums;
    Averages avgs;
    Variances vars;
    Kurtosis kurtosis;

38
    Meshes *meshes;
niklas.baumgarten's avatar
niklas.baumgarten committed
39
    PDESolver *pdeSolver;
40
    MatrixGraphs *solMGraphs;
41

42
43
44
45
    MonteCarlo(Level level, int dM, bool onlyFine) :
        level(level), ctr(SampleCounter(dM)), onlyFine(onlyFine) {

        readConfigEntries();
niklas.baumgarten's avatar
niklas.baumgarten committed
46

47
48
49
50
51
        if (problemName.find("1D") != string::npos)
            meshes = MeshesCreator("Interval").
                WithPLevel(level.coarse).
                WithLevel(level.fine).
                Create();
niklas.baumgarten's avatar
niklas.baumgarten committed
52

53
54
55
56
57
        else if (problemName.find("2D") != string::npos)
            meshes = MeshesCreator("Square").
                WithPLevel(level.coarse).
                WithLevel(level.fine).
                Create();
58

59
60
61
62
63
64
65
66
        pdeSolver = PDESolverCreator(*meshes).
            WithProblem(problemName).
            WithModel(modelName).
            WithDegree(degree).
            Create();

        solMGraphs = pdeSolver->CreateSolutionMatrixGraphs(*meshes);
    }
niklas.baumgarten's avatar
niklas.baumgarten committed
67

68
69
70
71
    ~MonteCarlo() {
        delete solMGraphs;
        delete pdeSolver;
        delete meshes;
niklas.baumgarten's avatar
niklas.baumgarten committed
72
    }
73

74
    void Method();
75
76
77
};

#endif //MLMC_MC_HPP