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

4
#include "main/MultilevelPlotter.hpp"
niklas.baumgarten's avatar
niklas.baumgarten committed
5
#include "EmpiricMeasures.hpp"
niklas.baumgarten's avatar
niklas.baumgarten committed
6
#include "PDESolver.hpp"
niklas.baumgarten's avatar
niklas.baumgarten committed
7
#include "Sample.hpp"
8
9


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

niklas.baumgarten's avatar
niklas.baumgarten committed
15
    virtual void method();
16

niklas.baumgarten's avatar
niklas.baumgarten committed
17
18
    void findSampleSolution(int m, SampleID &id, SampleSolution &solution);

niklas.baumgarten's avatar
niklas.baumgarten committed
19
public:
niklas.baumgarten's avatar
niklas.baumgarten committed
20
21
22
    int level;
    int pLevel;
    bool onlyFine;
niklas.baumgarten's avatar
niklas.baumgarten committed
23
24
25
26
27
28
29
30
31

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

    PDESolver *pdeSolver;
    MatrixGraphs solMGraphs;
32

niklas.baumgarten's avatar
niklas.baumgarten committed
33
34
35
36
37
    SampleID coarseId;
    SampleID fineId;
    SampleSolution coarseSolution;
    SampleSolution fineSolution;

38
39
40
    MonteCarlo(int level, int dM, bool onlyFine, Meshes &meshes, PDESolver *pdeSolver) :
        level(level), onlyFine(onlyFine), pdeSolver(pdeSolver),
        solMGraphs(MatrixGraphs(meshes, *pdeSolver->GetDisc())),
niklas.baumgarten's avatar
niklas.baumgarten committed
41
42
        coarseSolution(SampleSolution(solMGraphs, level - meshes.pLevel() - 1)),
        fineSolution(SampleSolution(solMGraphs, level - meshes.pLevel())) {
43

44
        config.get("MCPlotting", plotting);
45
        config.get("MCVerbose", verbose);
niklas.baumgarten's avatar
niklas.baumgarten committed
46
47
48
49

        ctr.dM = dM;
        fineId.level = level;
        fineId.coarse = false;
niklas.baumgarten's avatar
niklas.baumgarten committed
50
        coarseId.level = level;
niklas.baumgarten's avatar
niklas.baumgarten committed
51
        coarseId.coarse = true;
niklas.baumgarten's avatar
niklas.baumgarten committed
52
    }
53

54
55
    virtual ~MonteCarlo() {};

56
    void Method();
57
58
59
};

#endif //MLMC_MC_HPP