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

added constructor to WelfordAggregate and changed signature of Estimator constructor

parent ef83024a
Pipeline #149334 failed with stages
in 11 minutes and 52 seconds
......@@ -23,7 +23,10 @@ protected:
public:
WelfordAggregate aggregate;
Estimator() { config.get("epsilon", epsilon); }
Estimator(int initSamples = 0) :
aggregate(WelfordAggregate(initSamples)) {
config.get("epsilon", epsilon);
}
double TotalError() const { return errors.total; }
......
......@@ -18,7 +18,7 @@ protected:
bool parallel;
// Todo make unique pointer, there are issues with cleaning up this object!
// Todo make unique pointer, there are issues with cleaning up these objects
Meshes *meshes;
PDESolver *pdeSolver;
......@@ -34,20 +34,20 @@ public:
MonteCarlo(int level, int dM, bool onlyFine, bool parallel) :
level(level), onlyFine(onlyFine), parallel(parallel),
pdeSolverCreator(PDESolverCreator()),
Estimator(dM), pdeSolverCreator(PDESolverCreator()),
meshesCreator(MeshesCreator(pdeSolverCreator.GetMeshName())) {
Init(dM);
}
MonteCarlo(int level, int dM, bool onlyFine, bool parallel,
MeshesCreator meshesCreator, PDESolverCreator pdeCreator) :
level(level), onlyFine(onlyFine), parallel(parallel),
level(level), onlyFine(onlyFine), parallel(parallel), Estimator(dM),
pdeSolverCreator(pdeCreator), meshesCreator(meshesCreator) {
Init(dM);
}
MonteCarlo() :
pdeSolverCreator(PDESolverCreator()),
Estimator(), pdeSolverCreator(PDESolverCreator()),
meshesCreator(MeshesCreator(pdeSolverCreator.GetMeshName())) {
int dM = 0;
config.get("Level", level);
......@@ -58,7 +58,7 @@ public:
}
MonteCarlo(MeshesCreator meshesCreator, PDESolverCreator pdeCreator) :
pdeSolverCreator(pdeCreator), meshesCreator(meshesCreator) {
Estimator(), pdeSolverCreator(pdeCreator), meshesCreator(meshesCreator) {
int dM = 0;
config.get("Level", level);
config.get("Samples", dM);
......@@ -71,16 +71,6 @@ public:
return "MonteCarlo";
}
void EstimatorResults() const override {
mout.PrintInfo("MLMC Results", verbose,
PrintInfoEntry("Value", aggregate.mean.Q),
PrintInfoEntry("Cost", aggregate.mean.C * aggregate.ctr.M),
PrintInfoEntry("Epsilon", epsilon));
// PrintInfoEntry("Total Error", errors.total),
// PrintInfoEntry("Stochastical Error", errors.stochastic),
// PrintInfoEntry("Numerical Error", errors.numeric));
}
void Init(int dM) {
config.get("MCVerbose", verbose);
config.get("MCParallel", parallel);
......
......@@ -74,7 +74,8 @@ public:
CreateMonteCarloMap(estimatorMap, initLevels, initSamples);
}
MultilevelEstimator(const EstimatorMap &mcMap) : Estimator(), estimatorMap(mcMap) {
MultilevelEstimator(const EstimatorMap &estimatorMap) :
Estimator(), estimatorMap(estimatorMap) {
config.get("MLMCVerbose", verbose);
}
......
......@@ -8,6 +8,8 @@ class StochasticCollocation : public Estimator {
private:
public:
StochasticCollocation() {}
std::string Name() const override {
return "StochasticCollocation";
}
......
......@@ -60,7 +60,7 @@ struct Mean {
friend Logging &operator<<(Logging &s, const Mean &mean) {
return s << "MeanQ=" << mean.Q
<< " MeanY=" << mean.Y
// << " MeanC=" << mean.C
// << " MeanC=" << mean.C
<< " MeanQcomm=" << mean.Qcomm
<< " MeanYcomm=" << mean.Ycomm << endl;
// << " MeanCcomm=" << mean.Ccomm << endl;
......@@ -92,7 +92,7 @@ struct SVar {
friend Logging &operator<<(Logging &s, const SVar &sVar) {
return s << "SVarQ=" << sVar.Q
<< " SVarY=" << sVar.Y
// << " SVarC=" << sVar.C
// << " SVarC=" << sVar.C
<< " SVarQcomm=" << sVar.Qcomm
<< " SVarYcomm=" << sVar.Ycomm << endl;
// << " SVarCcomm=" << sVar.Ccomm << endl;
......@@ -194,6 +194,10 @@ public:
bool parallel = true;
public:
WelfordAggregate(int dM) {
UpdateSampleCounter(dM);
}
void Update(const SampleSolution &fineSolution, const SampleSolution &coarseSolution) {
double newC = fineSolution.Cost;
double newQ = fineSolution.Q;
......
#include "TestMonteCarlo.hpp"
/*
* Todo: More tests with other pde's.
* Maybe hand 1D problems to Chinmay.
* Test Parallel MonteCarlo against Seriell one
* MonteCarlo tests with epsilon, level such that total error can be met
* Idea: Point mesh for ode's -> Enables parallelized ode solving
*
* Extend this test idea to multilevel test
* Then Extend idea to Collocation
*
* Test of Estimators against each other
*/
INSTANTIATE_TEST_SUITE_P(TestMonteCarlo, TestMonteCarloSeriellInterval, Values(
TestStruct{"StochasticDummyScalarGeneratorProblem", "GeneratorValue", "DummyPDESolver",
0.0, 0.0, 1.0, 1.0},
......
......@@ -19,6 +19,7 @@ protected:
NormalDistributionReal normalDist;
TestWelfordAggregate(int numSamples) :
aggregate(WelfordAggregate(numSamples)),
meshes(MeshesCreator("Interval").CreateUnique()),
normalDist(NormalDistributionReal(*meshes)), numSamples(numSamples) {
}
......@@ -63,9 +64,7 @@ protected:
class TestWelfordAggregate4Samples : public TestWelfordAggregate {
public:
TestWelfordAggregate4Samples() : TestWelfordAggregate(4) {
aggregate.UpdateSampleCounter(numSamples);
}
TestWelfordAggregate4Samples() : TestWelfordAggregate(4) {}
};
TEST_F(TestWelfordAggregate4Samples, TestSampleCounter) {
......@@ -102,9 +101,7 @@ TEST_F(TestWelfordAggregate4Samples, TestSVar) { TestSVarParallel(); }
class TestWelfordAggregate8Samples : public TestWelfordAggregate {
public:
TestWelfordAggregate8Samples() : TestWelfordAggregate(8) {
aggregate.UpdateSampleCounter(numSamples);
}
TestWelfordAggregate8Samples() : TestWelfordAggregate(8) {}
};
TEST_F(TestWelfordAggregate8Samples, TestSampleCounter) {
......@@ -139,9 +136,7 @@ TEST_F(TestWelfordAggregate8Samples, TestMean) { TestMeanParallel(); }
class TestWelfordAggregate1e6Samples : public TestWelfordAggregate {
public:
TestWelfordAggregate1e6Samples() : TestWelfordAggregate(1e6) {
aggregate.UpdateSampleCounter(numSamples);
}
TestWelfordAggregate1e6Samples() : TestWelfordAggregate(1e6) {}
};
TEST_F(TestWelfordAggregate1e6Samples, TestSampleCounter) {
......@@ -166,21 +161,4 @@ TEST_F(TestWelfordAggregate1e6Samples, TestSampleCounter) {
TEST_F(TestWelfordAggregate1e6Samples, TestMean) { TestMeanParallel(); }
//while (aggregate.ctr.dMcomm != 0)
//aggregate.Update(
//1.0, normalDist.DrawAndEvalSample(SampleID(0, aggregate.index(), false)), 0.0
//);
//EXPECT_NEAR(aggregate.MeanQ, 0.0, sqrt(1.0 / numSamples));
//EXPECT_NEAR(aggregate.MeanY, 0.0, sqrt(1.0 / numSamples));
//// EXPECT_NEAR(aggregate.SVarQ, 1.0, sqrt(10.0 / numSamples));
//// EXPECT_NEAR(aggregate.SVarY, 1.0, sqrt(10.0 / numSamples));
#endif //TESTWELFORDAGGREGATE_HPP
%% Cell type:code id: tags:
``` python
import sys
sys.path.append('..')
import mpp.python.mppy as mppy
import mpp.python.mppy.utilities as utils
from python.mlmc_mppy import *
import pandas as pd
mpp = mppy.Mpp(project_name='MLMC',
executable='MLMC-M++',
kernels=4,
mute=False)
mpp.build()
```
%% Output
================ running cmake ================
-- Project directory= /home/niklas/CLionProjects/mlmc
-- Mpp directory= /home/niklas/CLionProjects/mlmc/mpp
-- Setting prepare commit message hook to mpp
file: /home/niklas/CLionProjects/mlmc/mpp/doc/../../.git/modules/mpp/hooks/prepare-commit-msg
-- Failed to find LLVM FileCheck
-- git Version: v1.5.2-bf585a27
-- Version: 1.5.2
-- Performing Test HAVE_STD_REGEX -- success
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Fully splitted MPI world communicator
-- A library with LAPACK API found.
-- C Compiler optimization= -O3
-- C++ version= 17
-- Compiler version= c++
-- Compiler optimization= -O0
-- Suppress deprecated warnings= OFF
-- Building space time library= OFF
-- Time dimension= 0
-- Using fftw library= ON
-- Space dimension= 2
-- Affine linear transformations= ON
-- Geometric tolerance= 1e-10
-- Near zero= 1e-15
-- Very large= 1e30
-- Infinity= 1e100
-- Checking for module 'libtirpc'
-- No package 'libtirpc' found
-- Could NOT find TIRPC (missing: TIRPC_LIBRARIES TIRPC_INCLUDE_DIRS)
-- Building mpp unit tests= OFF
-- Building mpp interval arithmetic unit tests= OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /home/niklas/CLionProjects/mlmc/build
================ running make ================
[ 5%] Built target benchmark
[ 6%] Built target gtest
[ 10%] Built target LIB_BASIC
[ 57%] Built target superlu
[ 57%] Built target benchmark_main
[ 58%] Built target gmock
[ 58%] Built target gtest_main
[ 61%] Built target LIB_MATH
[ 61%] Built target gmock_main
[ 62%] Built target LIB_TEST
[ 67%] Built target LIB_MESH
[ 70%] Built target LIB_DISC
[ 74%] Built target LIB_VECTOR
[ 79%] Built target LIB_ELEM
[ 84%] Built target LIB_SOLVERS
[ 84%] Built target MPP_LIBRARIES
[ 87%] Built target PDESOLVER
[ 88%] Built target PROBLEMS
[ 89%] Built target GENERATORS
[ 89%] Built target TestNormalDistribution
[ 89%] Built target TestUniformDistribution
[ 90%] Built target TestPlotting
[ 92%] Built target MONTECARLO
[ 94%] Built target TestSymmetricCovariance
[ 94%] Built target TestCirculantEmbedding
[ 95%] Built target TestPDESolver
[ 95%] Built target TestPDESolverMPI
[ 95%] Built target TestSPRNG5MPI
Scanning dependencies of target MLMC-M++
[ 96%] Built target TestWelfordAggregateMPI
[ 96%] Building CXX object CMakeFiles/MLMC-M++.dir/mlmc/src/Main.cpp.o
[ 96%] Built target TestMonteCarloMPI
[ 96%] Built target TestEllipticMultilevelMonteCarloMPI
[ 97%] Built target TestMultilevelErrors
[ 98%] Built target TestMainMPI
[ 98%] Built target TestLevelMaps
[ 99%] Built target TestExponents
[100%] Linking CXX executable MLMC-M++
[100%] Built target MLMC-M++
0
%% Cell type:code id: tags:
``` python
mpp.reset_data()
mpp.clean_data()
kwargs={"PDESolverPlotting": 1,
"initLevels": [4, 5, 6],
"Problem": "StochasticLaplace2DTest"}
mpp.run(4, config="mlmc_elliptic", kwargs=kwargs)
```
%% Output
================ running mpp ================
start program on 4 procs at Wed May 12 19:08:33 2021
Running on: niklas-ThinkPad-T470p
Config Info:
GeneratorVerbose: ......... 0
PDESolverVerbose: ......... 0
LinearVerbose: ............ 0
MeshVerbose: .............. 1
MainVerbose: .............. 1
MCVerbose: ................ 1
precision: ................ 3
MLMCVerbose: .............. 1
PDESolverPlotting: ........ 1
lambda: ................... [0.15, 0.15]
Model: .................... LagrangeElliptic
AssembleVerbose: .......... 0
degree: ................... 1
MCParallel: ............... false
maxLevel: ................. 7
Problem: .................. StochasticLaplace2DTest
StochasticField: .......... LogNormal
epsilon: .................. 0.01
ConfigVerbose: ............ 1
onlyFine: ................. false
Mean: ..................... 0.0
initLevels: ............... [4, 5, 6]
smoothing: ................ 1.0
Quantity: ................. L2
sigma: .................... 1.0
NewtonVerbose: ............ 0
initSamples: .............. [12, 6, 3]
MultilevelMonteCarlo Experiment: Start
Multilevel Method: eps=0.010000
MonteCarlo l=4: Start with: M=0 dM=12 MComm=0 dMComm=12
MonteCarlo l=4: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=4: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=4: End with: M=12 dM=0 MComm=12 dMComm=0
MonteCarlo l=4: MeanQ=0.578 MeanY=0.578 MeanQcomm=0.578 MeanYcomm=0.578
MonteCarlo l=4: SVarQ=1.75e-05 SVarY=1.75e-05 SVarQcomm=1.75e-05 SVarYcomm=1.75e-05
MonteCarlo l=4: 0.35 seconds
MonteCarlo l=5: Start with: M=0 dM=6 MComm=0 dMComm=6
MonteCarlo l=5: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=5: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=5: End with: M=6 dM=0 MComm=6 dMComm=0
MonteCarlo l=5: MeanQ=0.579 MeanY=4.46e-05 MeanQcomm=0.579 MeanYcomm=4.46e-05
MonteCarlo l=5: SVarQ=2.32e-05 SVarY=3.92e-09 SVarQcomm=2.32e-05 SVarYcomm=3.92e-09
MonteCarlo l=5: 0.91 seconds
MonteCarlo l=6: Start with: M=0 dM=3 MComm=0 dMComm=3
MonteCarlo l=6: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=6: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=6: End with: M=3 dM=0 MComm=3 dMComm=0
MonteCarlo l=6: MeanQ=0.58 MeanY=2.22e-05 MeanQcomm=0.58 MeanYcomm=2.22e-05
MonteCarlo l=6: SVarQ=1.55e-05 SVarY=9.92e-10 SVarQcomm=1.55e-05 SVarYcomm=9.92e-10
MonteCarlo l=6: 1.92 seconds
Multilevel Method: alpha=1 beta=1.98 gamma=1.91
Multilevel Method: dM=[-10, -4, -1]
Multilevel Method: numErr=2.22e-05
Multilevel Method: statErr=0.00121
Multilevel Method: 3.17 seconds
MultilevelMonteCarlo Experiment: 3.17 seconds
Multilevel Results Info:
E(Qf-Qc): ................. [0.578155, 4.45706e-05, 2.22304e-05]
E(Qf): .................... [0.578155, 0.578845, 0.579971]
V(Qf-Qc): ................. [1.74716e-05, 3.91703e-09, 9.92175e-10]
V(Qf): .................... [1.74716e-05, 2.31794e-05, 1.54784e-05]
E(cost): .................. [81, 289, 1089]
Used Levels: .............. [4, 5, 6]
Used Samples: ............. [12, 6, 3]
Exponents Info:
Final alpha: .............. 1
Final beta: ............... 1.98
Final gamma: .............. 1.91
Estimator Results Info:
Value: .................... 1.16
Cost: ..................... 2.92e+03
Epsilon: .................. 0.01
Total Error: .............. 0.00123
Numerical Error: .......... 2.22e-05
Stochastical Error: ....... 0.00121
end program after 3.29 seconds on 4 procs at Wed May 12 19:08:37 2021
0
%% Cell type:code id: tags:
``` python
from mpp.python.mppy.utilities import VtkPlot
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
@interact(n=widgets.IntSlider(min=0, max=5, step=1, value=0))
def plot_nth_frame(n):
p = VtkPlot(figsize=(16, 12))
plt.axis('off')
gs = gridspec.GridSpec(2, 2)
p.ax1 = p.fig.add_subplot(gs[0])
p.add_vtu("Kappa.5.0.{}.vtu".format(n), ax=p.ax1)
p.add_quivers("Flux.5.0.{}.vtu".format(n), ax=p.ax1)
p.ax2 = p.fig.add_subplot(gs[1])
p.add_vtu("Kappa.5.1.{}.vtu".format(n), ax=p.ax2)
p.add_quivers("Flux.5.1.{}.vtu".format(n), ax=p.ax2)
p.ax3 = p.fig.add_subplot(gs[2])
p.add_vtu("Pressure.5.0.{}.vtu".format(n), ax=p.ax3)
p.ax4 = p.fig.add_subplot(gs[3])
p.add_vtu("Pressure.5.1.{}.vtu".format(n), ax=p.ax4)
```
%% Output
%% Cell type:code id: tags:
``` python
from mpp.python.mppy.utilities import VtkPlot
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
@interact(n=widgets.IntSlider(min=0, max=2, step=1, value=0))
def plot_nth_frame(n):
p = VtkPlot(figsize=(16, 12))
plt.axis('off')
gs = gridspec.GridSpec(2, 2)
p.ax1 = p.fig.add_subplot(gs[0])
p.add_vtu("Kappa.6.0.{}.vtu".format(n), ax=p.ax1)
p.add_quivers("Flux.6.0.{}.vtu".format(n), ax=p.ax1)
p.ax2 = p.fig.add_subplot(gs[1])
p.add_vtu("Kappa.6.1.{}.vtu".format(n), ax=p.ax2)
p.add_quivers("Flux.6.1.{}.vtu".format(n), ax=p.ax2)
p.ax3 = p.fig.add_subplot(gs[2])
p.add_vtu("Pressure.6.0.{}.vtu".format(n), ax=p.ax3)
p.ax4 = p.fig.add_subplot(gs[3])
p.add_vtu("Pressure.6.1.{}.vtu".format(n), ax=p.ax4)
```
%% Output
%% Cell type:markdown id: tags:
## Convergence tests
%% Cell type:code id: tags:
``` python
test_case = True
if test_case:
mpp.kernels = 4
mpp.mute = False
kwargs = {"epsilon": 0.0,
"initLevels": [3, 4, 5, 6],
"initSamples": [100, 100, 100, 100],
"Problem": "StochasticLaplace2DTest"}
epsilons = [0.1, 0.03, 0.01, 0.003]
else:
mpp.kernels = 32
mpp.mute = True
kwargs = {"epsilon": 0.0,
"initLevels": [3, 4, 5, 6, 7, 8, 9],
"initSamples": [500, 500, 500, 500, 500, 500, 500],
"Problem": "StochasticLaplace2DTest"}
epsilons = [0.1, 0.03, 0.01, 0.003, 0.001, 0.0003]
```
%% Cell type:code id: tags:
``` python
mpp.clean_data()
mpp.reset_data()
kwargs["MCParallel"] = "false"
mpp.run(config="mlmc_elliptic", kwargs=kwargs)
mpp.parse_log()
convergence_plot(mpp)
```
%% Output
================ running mpp ================
start program on 4 procs at Wed May 12 19:08:40 2021
Running on: niklas-ThinkPad-T470p
Config Info:
GeneratorVerbose: ......... 0
PDESolverVerbose: ......... 0
LinearVerbose: ............ 0
MeshVerbose: .............. 1
MainVerbose: .............. 1
MCVerbose: ................ 1
precision: ................ 3
MLMCVerbose: .............. 1
PDESolverPlotting: ........ 0
lambda: ................... [0.15, 0.15]
Model: .................... LagrangeElliptic
AssembleVerbose: .......... 0
degree: ................... 1
MCParallel: ............... false
maxLevel: ................. 7
Problem: .................. StochasticLaplace2DTest
StochasticField: .......... LogNormal
epsilon: .................. 0.0
ConfigVerbose: ............ 1
onlyFine: ................. false
Mean: ..................... 0.0
initLevels: ............... [3, 4, 5, 6]
smoothing: ................ 1.0
Quantity: ................. L2
sigma: .................... 1.0
NewtonVerbose: ............ 0
initSamples: .............. [100, 100, 100, 100]
MultilevelMonteCarlo Experiment: Start
Multilevel Method: Non adaptive method
MonteCarlo l=3: Start with: M=0 dM=100 MComm=0 dMComm=100
MonteCarlo l=3: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=3: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=3: End with: M=100 dM=0 MComm=100 dMComm=0
MonteCarlo l=3: MeanQ=0.579 MeanY=0.579 MeanQcomm=0.579 MeanYcomm=0.579
MonteCarlo l=3: SVarQ=2.66e-05 SVarY=2.66e-05 SVarQcomm=2.66e-05 SVarYcomm=2.66e-05
MonteCarlo l=3: 0.32 seconds
MonteCarlo l=4: Start with: M=0 dM=100 MComm=0 dMComm=100
MonteCarlo l=4: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=4: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=4: End with: M=100 dM=0 MComm=100 dMComm=0
MonteCarlo l=4: MeanQ=0.58 MeanY=0.000129 MeanQcomm=0.58 MeanYcomm=0.000129
MonteCarlo l=4: SVarQ=2.79e-05 SVarY=2.41e-08 SVarQcomm=2.79e-05 SVarYcomm=2.41e-08
MonteCarlo l=4: 1.38 seconds
MonteCarlo l=5: Start with: M=0 dM=100 MComm=0 dMComm=100
MonteCarlo l=5: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=5: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=5: End with: M=100 dM=0 MComm=100 dMComm=0
MonteCarlo l=5: MeanQ=0.58 MeanY=4.38e-05 MeanQcomm=0.58 MeanYcomm=4.38e-05
MonteCarlo l=5: SVarQ=2.84e-05 SVarY=2.97e-09 SVarQcomm=2.84e-05 SVarYcomm=2.97e-09
MonteCarlo l=5: 5.38 seconds
MonteCarlo l=6: Start with: M=0 dM=100 MComm=0 dMComm=100
MonteCarlo l=6: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=6: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=6: End with: M=100 dM=0 MComm=100 dMComm=0
MonteCarlo l=6: MeanQ=0.58 MeanY=1.49e-05 MeanQcomm=0.58 MeanYcomm=1.49e-05
MonteCarlo l=6: SVarQ=2.86e-05 SVarY=3.76e-10 SVarQcomm=2.86e-05 SVarYcomm=3.76e-10
MonteCarlo l=6: 24.37 seconds
Multilevel Method: 31.43 seconds
MultilevelMonteCarlo Experiment: 31.43 seconds
Multilevel Results Info:
E(Qf-Qc): ................. [0.57941, 0.000128635, 4.37807e-05, 1.49277e-05]
E(Qf): .................... [0.57941, 0.579539, 0.579583, 0.579598]
V(Qf-Qc): ................. [2.66434e-05, 2.40786e-08, 2.96502e-09, 3.75725e-10]
V(Qf): .................... [2.66434e-05, 2.79398e-05, 2.83984e-05, 2.85606e-05]
E(cost): .................. [25, 81, 289, 1089]
Used Levels: .............. [3, 4, 5, 6]
Used Samples: ............. [100, 100, 100, 100]
Exponents Info:
Final alpha: .............. 1.55
Final beta: ............... 3
Final gamma: .............. 1.87
Estimator Results Info:
Value: .................... 0.58
Cost: ..................... 1.48e+03
Epsilon: .................. 0
Total Error: .............. 0.000533
Numerical Error: .......... 1.66e-05
Stochastical Error: ....... 0.000516
end program after 31.53 seconds on 4 procs at Wed May 12 19:09:12 2021
%% Cell type:code id: tags:
``` python
mpp.clean_data()
mpp.reset_data()
kwargs["MCParallel"] = "true"
mpp.run(config="mlmc_elliptic", kwargs=kwargs)
mpp.parse_log()
convergence_plot(mpp)
```
%% Output
================ running mpp ================
start program on 4 procs at Wed May 12 19:09:14 2021
Running on: niklas-ThinkPad-T470p
Config Info:
GeneratorVerbose: ......... 0
PDESolverVerbose: ......... 0
LinearVerbose: ............ 0
MeshVerbose: .............. 1
MainVerbose: .............. 1
MCVerbose: ................ 1
precision: ................ 3
MLMCVerbose: .............. 1
PDESolverPlotting: ........ 0
lambda: ................... [0.15, 0.15]
Model: .................... LagrangeElliptic
AssembleVerbose: .......... 0
degree: ................... 1
MCParallel: ............... true
maxLevel: ................. 7
Problem: .................. StochasticLaplace2DTest
StochasticField: .......... LogNormal
epsilon: .................. 0.0
ConfigVerbose: ............ 1
onlyFine: ................. false
Mean: ..................... 0.0
initLevels: ............... [3, 4, 5, 6]
smoothing: ................ 1.0
Quantity: ................. L2
sigma: .................... 1.0
NewtonVerbose: ............ 0
initSamples: .............. [100, 100, 100, 100]
MultilevelMonteCarlo Experiment: Start
Multilevel Method: Non adaptive method
MonteCarlo l=3: Start with: M=0 dM=100 MComm=0 dMComm=25
MonteCarlo l=3: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=3: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=3: End with: M=100 dM=0 MComm=25 dMComm=0
MonteCarlo l=3: MeanQ=0.579 MeanY=0.579 MeanQcomm=0.579 MeanYcomm=0.579
MonteCarlo l=3: SVarQ=3.15e-05 SVarY=3.15e-05 SVarQcomm=1.7e-05 SVarYcomm=1.7e-05
MonteCarlo l=3: 0.22 seconds
MonteCarlo l=4: Start with: M=0 dM=100 MComm=0 dMComm=25
MonteCarlo l=4: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=4: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=4: End with: M=100 dM=0 MComm=25 dMComm=0
MonteCarlo l=4: MeanQ=0.579 MeanY=0.000123 MeanQcomm=0.579 MeanYcomm=0.00012
MonteCarlo l=4: SVarQ=3.29e-05 SVarY=2.2e-08 SVarQcomm=1.78e-05 SVarYcomm=1.72e-08
MonteCarlo l=4: 1.04 seconds
MonteCarlo l=5: Start with: M=0 dM=100 MComm=0 dMComm=25
MonteCarlo l=5: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=5: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=5: End with: M=100 dM=0 MComm=25 dMComm=0
MonteCarlo l=5: MeanQ=0.579 MeanY=4.15e-05 MeanQcomm=0.579 MeanYcomm=4.09e-05
MonteCarlo l=5: SVarQ=3.33e-05 SVarY=2.64e-09 SVarQcomm=1.81e-05 SVarYcomm=2.17e-09
MonteCarlo l=5: 4.14 seconds
MonteCarlo l=6: Start with: M=0 dM=100 MComm=0 dMComm=25
MonteCarlo l=6: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=6: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
MonteCarlo l=6: End with: M=100 dM=0 MComm=25 dMComm=0
MonteCarlo l=6: MeanQ=0.579 MeanY=1.4e-05 MeanQcomm=0.579 MeanYcomm=1.39e-05
MonteCarlo l=6: SVarQ=3.35e-05 SVarY=3.26e-10 SVarQcomm=1.82e-05 SVarYcomm=2.79e-10
MonteCarlo l=6: 18.32 seconds
Multilevel Method: 23.70 seconds
MultilevelMonteCarlo Experiment: 23.70 seconds
Multilevel Results Info:
E(Qf-Qc): ................. [0.578972, 0.000122807, 4.14638e-05, 1.39919e-05]
E(Qf): .................... [0.578972, 0.579095, 0.579136, 0.57915]
V(Qf-Qc): ................. [3.14963e-05, 2.19686e-08, 2.63917e-09, 3.25902e-10]
V(Qf): .................... [3.14963e-05, 3.28542e-05, 3.33266e-05, 3.34911e-05]
E(cost): .................. [81, 289, 1089, 4225]
Used Levels: .............. [3, 4, 5, 6]
Used Samples: ............. [100, 100, 100, 100]
Exponents Info:
Final alpha: .............. 1.57
Final beta: ............... 3.04
Final gamma: .............. 1.93
Estimator Results Info:
Value: .................... 0.579
Cost: ..................... 5.68e+03
Epsilon: .................. 0
Total Error: .............. 0.000577
Numerical Error: .......... 1.56e-05
Stochastical Error: ....... 0.000561
end program after 23.85 seconds on 4 procs at Wed May 12 19:09:38 2021
%% Cell type:code id: tags:
``` python
mpp.clean_data()
mpp.reset_data()
kwargs["MCParallel"] = "false"
kwargs["Estimator"] = "MonteCarlo"
kwargs["MCVerbose"] = 2
kwargs["Level"] = 3
kwargs["Samples"] = 1000
mpp.run(config="mc_elliptic", kwargs=kwargs)
mpp.parse_log()
convergence_plot(mpp)
```
%% Output
================ running mpp ================
start program on 4 procs at Wed May 12 19:09:39 2021
Running on: niklas-ThinkPad-T470p
Config Info:
initLevels: ............... [3, 4, 5, 6]
GeneratorVerbose: ......... 0
initSamples: .............. [100, 100, 100, 100]
NewtonVerbose: ............ 0
PDESolverVerbose: ......... 0
LinearVerbose: ............ 0
Estimator: ................ MonteCarlo
MeshVerbose: .............. 1
Model: .................... LagrangeElliptic
Level: .................... 3
AssembleVerbose: .......... 0
degree: ................... 1
Quantity: ................. L2
Samples: .................. 1000
MCParallel: ............... false
Problem: .................. StochasticLaplace2DTest
epsilon: .................. 0.0
ConfigVerbose: ............ 1
onlyFine: ................. false
precision: ................ 3
MainVerbose: .............. 1
MCVerbose: ................ 2
PDESolverPlotting: ........ 0
MLMCVerbose: .............. 1
MonteCarlo Experiment: Start
MonteCarlo l=3: Start with: M=0 dM=1000 MComm=0 dMComm=1000
MonteCarlo l=3: MeanQ=0 MeanY=0 MeanQcomm=0 MeanYcomm=0
MonteCarlo l=3: SVarQ=0 SVarY=0 SVarQcomm=0 SVarYcomm=0
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-8-812128e7e28b> in <module>()
9
10
---> 11 mpp.run(config="mc_elliptic", kwargs=kwargs)
12 mpp.parse_log()
13
~/CLionProjects/mlmc/mpp/python/mppy/mppy.py in run(self, kernels, config, kwargs, return_log)
70 print('\n================ running mpp ================\n')
71 run_parameters = self.chain_run_parameters(kernels, config, kwargs)
---> 72 return self.run_subprocess(run_parameters, self.cwd, self.mute, return_log)
73
74 def chain_run_parameters(self, kernels, config, kwargs, executable=None):
~/CLionProjects/mlmc/mpp/python/mppy/mppy.py in run_subprocess(self, args, cwd, mute, return_log)
94
95 def run_subprocess(self, args, cwd, mute=False, return_log=False):
---> 96 return self.sm.run_subprocess(args, cwd, mute, return_log)
97
98 def reset_data(self):
~/CLionProjects/mlmc/mpp/python/mppy/utilities/subprocess_utilities.py in run_subprocess(self, args, cwd, mute, return_log)
20 process = Popen(args, cwd=cwd, stdout=PIPE, stderr=PIPE)
21 while True:
---> 22 stdout = process.stdout.readline()
23 if not mute:
24 if return_log:
KeyboardInterrupt:
%% Cell type:code id: tags:
``` python
```
......
Supports Markdown
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