MonteCarlo.hpp 1.56 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"
niklas.baumgarten's avatar
niklas.baumgarten committed
8
#include "assemble/IStochasticAssemble.hpp"
9
10


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

niklas.baumgarten's avatar
niklas.baumgarten committed
15
    int verbose = 0;
16

niklas.baumgarten's avatar
niklas.baumgarten committed
17
    virtual void method();
18

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

niklas.baumgarten's avatar
niklas.baumgarten committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public:
    int level = 0;
    int pLevel = 0;
    bool onlyFine = true;

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

    IStochasticAssemble *assemble;
    PDESolver *pdeSolver;

    MatrixGraphs solMGraphs;
    SampleID coarseId;
    SampleID fineId;
    SampleSolution coarseSolution;
    SampleSolution fineSolution;

    MonteCarlo(int level,
               int dM,
               bool onlyFine,
               Meshes &meshes,
               IStochasticAssemble *assemble,
               PDESolver *pdeSolver) :
        level(level), onlyFine(onlyFine),
        assemble(assemble), pdeSolver(pdeSolver),
        solMGraphs(MatrixGraphs(meshes, *assemble->GetDiscretization())),
niklas.baumgarten's avatar
niklas.baumgarten committed
50
51
        coarseSolution(SampleSolution(solMGraphs, level - meshes.pLevel() - 1)),
        fineSolution(SampleSolution(solMGraphs, level - meshes.pLevel())) {
52

53
        config.get("MCPlotting", plotting);
54
        config.get("MCVerbose", verbose);
niklas.baumgarten's avatar
niklas.baumgarten committed
55
56
57
58

        ctr.dM = dM;
        fineId.level = level;
        fineId.coarse = false;
niklas.baumgarten's avatar
niklas.baumgarten committed
59
        coarseId.level = level;
niklas.baumgarten's avatar
niklas.baumgarten committed
60
        coarseId.coarse = true;
niklas.baumgarten's avatar
niklas.baumgarten committed
61
    }
62

63
64
    virtual ~MonteCarlo() {};

65
    void Method();
66
67
68
};

#endif //MLMC_MC_HPP