Commit 5ddb9d68 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

minor refactoring

parent d7f1bd8b
......@@ -19,7 +19,7 @@ MCParallel = false
epsilon = 0.01
onlyFine = false
initLevels = [3, 4, 5]
initSampleAmount = [12, 6, 3]
initSamples = [12, 6, 3]
# ----- Stochastic Field -----
StochasticField = LogNormal
......
#include "MultilevelEstimator.hpp"
void MultilevelEstimator::initializeCollocationMap() {
EstimatorMap CreateCollocationMap(Levels initLevels, Samples initSamples) {
EstimatorMap estimatorMap;
return estimatorMap;
}
void MultilevelEstimator::initializeMonteCarloMap() {
estimatorMap.clear();
EstimatorMap CreateMonteCarloMap(Levels initLevels, Samples initSamples) {
EstimatorMap estimatorMap;
for (unsigned long i = 0; i < initLevels.size(); i++) {
bool onlyFine = (i == 0);
int M = initSampleAmount[i];
int M = initSamples[i];
estimatorMap.insert(
{initLevels[i], new MonteCarlo(initLevels[i], M, onlyFine, true)}
);
}
return estimatorMap;
}
void MultilevelEstimator::Method() {
......@@ -69,7 +72,7 @@ void MultilevelEstimator::adaptiveMethod() {
void MultilevelEstimator::PrintInfo() const {
mout.PrintInfo("MultilevelEstimator", verbose,
PrintInfoEntry("initLevels", vec2str(initLevels)),
PrintInfoEntry("initSample", vec2str(initSampleAmount)));
PrintInfoEntry("initSample", vec2str(initSamples)));
}
void MultilevelEstimator::MultilevelResults() const {
......
......@@ -26,17 +26,21 @@ struct EstimatorMap : public LevelMap<Estimator *> {
void AppendLevel(double epsilon, Exponents exponents, int newLevel);
};
typedef std::vector<int> Levels;
typedef std::vector<int> Samples;
EstimatorMap CreateCollocationMap(Levels initLevels, Samples initSamples);
EstimatorMap CreateMonteCarloMap(Levels initLevels, Samples initSamples);
class MultilevelEstimator : public Estimator {
private:
int verbose = 1;
std::vector<int> initLevels{3, 4, 5};
Levels initLevels{3, 4, 5};
std::vector<int> initSampleAmount{12, 6, 3};
void initializeCollocationMap();
void initializeMonteCarloMap();
Samples initSamples{12, 6, 3};
void adaptiveMethod();
......@@ -54,9 +58,9 @@ public:
MultilevelEstimator() : Estimator() {
config.get("MLMCVerbose", verbose);
config.get("initLevels", initLevels);
config.get("initSampleAmount", initSampleAmount);
config.get("initSamples", initSamples);
initializeMonteCarloMap();
estimatorMap = CreateMonteCarloMap(initLevels, initSamples);
}
MultilevelEstimator(const EstimatorMap &mcMap) : Estimator(), estimatorMap(mcMap) {
......@@ -67,9 +71,7 @@ public:
estimatorMap.clear();
}
std::string Name() const override {
return "MultilevelMonteCarlo";
}
std::string Name() const override { return "MultilevelMonteCarlo"; }
void Method() override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment