MLMCMain.h 3.23 KB
Newer Older
1
2
3
#ifndef MLMC_MLMCMAIN_H
#define MLMC_MLMCMAIN_H

4
5
6
#include "assemble/AssembleHeader.h"
#include "problem/StochasticEllipticProblem.h"
#include "problem/StochasticTransportProblem.h"
7
#include "MultilevelMonteCarlo.h"
8
9
10
#include "discretization/DGDiscretization.h"
#include "stochastics/StochasticField.h"

11

12
13
14
15
class MLMCMain {
public:
    string problemName = "", modelName = "";
    string fieldName = "", experimentName = "";
16

17
18
19
20
21
22
    int enablePython = 1;
    double epsilon = 0.1;
    int pLevel = 0, maxLevel = 8, degree = 0;
    vector<int> initLevels = {3, 4, 5}, initSampleAmount = {12, 6, 3};
    vector<double> epsilonList = {0.1, 0.05, 0.01};

23
24
    Meshes *meshes = nullptr;
    Discretization *disc = nullptr;
25
26

    StochasticField *stochasticField = nullptr;
27
28
29
    StochasticProblem *problem = nullptr;
    Assemble *assemble = nullptr;
    MatrixGraphs *graphs = nullptr;
30
    Plot *plot = nullptr;
31
    MultilevelMonteCarlo *mlmc = nullptr;
niklas.baumgarten's avatar
niklas.baumgarten committed
32

33
    MLMCMain() {
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
        config.get("enablePython", enablePython);
        config.get("epsilon", epsilon);
        config.get("pLevel", pLevel);
        config.get("maxLevel", maxLevel);
        config.get("degree", degree);
        config.get("initLevels", initLevels);
        config.get("initSampleAmount", initSampleAmount);
        config.get("epsilonList", epsilonList);
        config.get("Problem", problemName);
        config.get("Model", modelName);
        config.get("StochasticField", fieldName);
        config.get("Experiment", experimentName);

        if (initSampleAmount.size() != initLevels.size()) Exit(
            "\ninitLevels and initSampleAmount have to be of the same size.\n")
        if (maxLevel < initLevels.back()) Exit(
            "\nLast element of initLevels has to be smaller or equal to maxLevel.\n")
niklas.baumgarten's avatar
niklas.baumgarten committed
51

52
53
        initialize();
    }
niklas.baumgarten's avatar
niklas.baumgarten committed
54

55
    ~MLMCMain() {
56
        delete meshes, delete disc, delete stochasticField;
57
58
59
        delete problem, delete assemble, delete graphs;
        delete mlmc;
    }
niklas.baumgarten's avatar
niklas.baumgarten committed
60

61
    void initialize();
niklas.baumgarten's avatar
niklas.baumgarten committed
62

63
64
    Meshes *getMeshes();

65
66
67
    Discretization *getDiscretization();

    Vector *getFieldSampleVector();
68

69
    StochasticField *getStochasticField();
70

71
    StochasticProblem *getStochasticProblem();
72

73
    Assemble *getAssemble();
74

75
    MatrixGraphs *getMatrixGraphs();
76
77
78

    void run();

niklas.baumgarten's avatar
niklas.baumgarten committed
79
80
    void printParameters();

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
    static void headConvergenceTest() {
        mout << endl << "**********************************************************"
             << endl << "*** Convergence tests, kurtosis, telescoping sum check ***"
             << endl << "**********************************************************"
             << endl;
    }

    static void headMLMCExperiment() {
        mout << endl << "**********************************************************"
             << endl << "***           MultilevelMonteCarlo test run            ***"
             << endl << "**********************************************************"
             << endl;
    }

    static void headMLMCOverEpsilon() {
        mout << endl << "**********************************************************"
             << endl << "***         MultilevelMonteCarlo over epsilon          ***"
             << endl << "**********************************************************"
             << endl;
    }
};
102
103

#endif //MLMC_MLMCMAIN_H