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

4
#include "main/MultilevelPlotter.hpp"
5
6


7
8
class MonteCarlo {
public:
niklas.baumgarten's avatar
niklas.baumgarten committed
9
    int plotting = 0;
10
    int verbose = 0;
11

niklas.baumgarten's avatar
niklas.baumgarten committed
12
13
    int l = 0;
    int pLevel = 0;
14
    bool onlyFineLevel = true;
15
16
    string functional = "L2";

niklas.baumgarten's avatar
niklas.baumgarten committed
17
    Meshes *meshes = nullptr;
18
19
20

    int M = 0, dM = 0;

21
    double sumCost = 0.0, avgCost = 0.0;
22
    double sumY1 = 0.0, avgY = 0.0;
23
24
25
    double sumY2 = 0.0, avgY2 = 0.0, varY = 0.0;
    double sumY3 = 0.0, avgY3 = 0.0;
    double sumY4 = 0.0, avgY4 = 0.0;
26
    double sumQ1 = 0.0, avgQ = 0.0;
27
    double sumQ2 = 0.0, avgQ2 = 0.0, varQ = 0.0;
28
29
    double kurtosis = 0.0;

30
31
32
    double fineQ = 0.0, coarseQ = 0.0;
    double fineCost = 0.0, coarseCost = 0.0;

33
    MonteCarlo(int l, int dM, bool onlyFineLevel, Meshes *meshes) :
34
        l(l), dM(dM), onlyFineLevel(onlyFineLevel),
35
        meshes(meshes), pLevel(meshes->pLevel()) {
36

37
        config.get("MCPlotting", plotting);
38
        config.get("MCVerbose", verbose);
niklas.baumgarten's avatar
niklas.baumgarten committed
39
        config.get("Functional", functional);
niklas.baumgarten's avatar
niklas.baumgarten committed
40
    }
41

42
43
    virtual ~MonteCarlo() {};

44
    void Method();
45

46
    void SolvePDE(SampleID id, double &valueQ, double &cost, Vector &solution);
niklas.baumgarten's avatar
niklas.baumgarten committed
47

niklas.baumgarten's avatar
niklas.baumgarten committed
48
    virtual void Initialize() = 0;
niklas.baumgarten's avatar
niklas.baumgarten committed
49

niklas.baumgarten's avatar
niklas.baumgarten committed
50
protected:
niklas.baumgarten's avatar
niklas.baumgarten committed
51
52
    virtual void method() = 0;

53
    virtual void solvePDE(SampleID id, double &valueQ, double &cost, Vector &solution) = 0;
niklas.baumgarten's avatar
niklas.baumgarten committed
54

55
    void updateSums(double fineCost, double diffQ, double fineQ);
56

57
    void updateAvg();
58

59
    void updateStatistic();
60
61
62
};

#endif //MLMC_MC_HPP