Commit befe2734 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

added parallel and use aggregate.MeanQ

parent b431d7aa
......@@ -7,15 +7,12 @@ void MonteCarlo::Method() {
method();
aggregate.UpdateParallel();
// sums.UpdateParallel(ctr);
vout(2) << sums;
avgs.Update(sums, aggregate.M);
vars.Update(avgs);
kurtosis.Update(avgs, vars);
aggregate.MeanQ = avgs.Q;
aggregate.SVarQ = vars.Q;
aggregate.MeanY = avgs.Y;
aggregate.SVarY = vars.Y;
vout(1) << "End with: " << aggregate;
......
......@@ -15,7 +15,7 @@ protected:
bool onlyFine = false;
bool parallel = true;
bool parallel;
int level;
......@@ -44,9 +44,10 @@ public:
SampleID fineId;
MonteCarlo(int level, int dM, bool onlyFine) :
MonteCarlo(int level, int dM, bool onlyFine, bool parallel) :
level(level),
onlyFine(onlyFine),
parallel(parallel),
pdeSolverCreator(PDESolverCreator()),
meshesCreator(MeshesCreator(pdeSolverCreator.GetMeshName()).
WithCommSplit(aggregate.commSplit). // Todo: Is this correct?
......@@ -55,10 +56,11 @@ public:
Init(dM);
}
MonteCarlo(int level, int dM, bool onlyFine,
MonteCarlo(int level, int dM, bool onlyFine, bool parallel,
MeshesCreator meshesCreator, PDESolverCreator pdeCreator) :
level(level),
onlyFine(onlyFine),
parallel(parallel),
pdeSolverCreator(pdeCreator),
meshesCreator(meshesCreator) {
Init(dM);
......
......@@ -6,7 +6,10 @@ void MultilevelMonteCarlo::initializeMonteCarloMap() {
for (unsigned long i = 0; i < initLevels.size(); i++) {
bool onlyFine = (i == 0) || (mcOnly);
int M = initSampleAmount[i];
auto mc = LevelMonteCarloPair(initLevels[i], MonteCarlo(initLevels[i], M, onlyFine));
auto mc = LevelMonteCarloPair(initLevels[i], MonteCarlo(initLevels[i],
M,
onlyFine,
true));
mcMap.insert(mc);
}
}
......
......@@ -23,7 +23,8 @@ void MonteCarloMap::AppendLevel(double epsilon, Exponents exponents, int newLeve
auto oldLevel = this->rbegin();
double varsY = oldLevel->second.vars.Y / pow(2.0, exponents.beta);
double avgsCost = oldLevel->second.avgs.Cost * pow(2.0, exponents.gamma);
_levelMap.insert(LevelMonteCarloPair(newLevel, MonteCarlo(newLevel, 0, false)));
_levelMap.insert(
LevelMonteCarloPair(newLevel, MonteCarlo(newLevel, 0, false, true)));
_levelMap.find(newLevel)->second.vars.Y = varsY;
_levelMap.find(newLevel)->second.avgs.Cost = avgsCost;
this->UpdateSampleCounter(epsilon);
......
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