TestMultilevelMonteCarlo.cpp 1.49 KB
Newer Older
niklas.baumgarten's avatar
niklas.baumgarten committed
1
#include "TestMultilevelMonteCarlo.hpp"
niklas.baumgarten's avatar
niklas.baumgarten committed
2
3


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

INSTANTIATE_TEST_SUITE_P(TestMultilevelMonteCarlo, TestMultilevelMonteCarlo, Values(
  TestParams{"StochasticDummyScalarGeneratorProblem", "GeneratorValue", "DummyPDESolver"},
  TestParams{"StochasticLaplace2DTest", "L2", "LagrangeElliptic"},
  TestParams{"StochasticLaplace2DTest", "Outflow", "HybridElliptic"}
  // Todo add more test cases
));

TEST_P(TestMultilevelMonteCarlo, TestSeriellAgainstParallel) {
  EXPECT_NEAR(mlmcParallel->aggregate.mean.Q, mlmcSeriell->aggregate.mean.Q, MeanTolerance());
  EXPECT_NEAR(mlmcParallel->aggregate.mean.Y, mlmcSeriell->aggregate.mean.Y, MeanTolerance());
  EXPECT_NEAR(mlmcParallel->aggregate.sVar.Q, mlmcSeriell->aggregate.sVar.Q, SVarTolerance());
  EXPECT_NEAR(mlmcParallel->aggregate.sVar.Y, mlmcSeriell->aggregate.sVar.Y, SVarTolerance());
}

TEST_P(TestMultilevelMonteCarlo, TestWithEpsilon) {
  EXPECT_LE(mlmcSeriell->TotalError(), epsilon);
  EXPECT_LE(mlmcParallel->TotalError(), epsilon);
}

niklas.baumgarten's avatar
niklas.baumgarten committed
24
25
26
27
int main(int argc, char **argv) {
  return MppTest(
    MppTestBuilder(argc, argv).
      WithConfigEntry("GeneratorVerbose", 0).
niklas.baumgarten's avatar
niklas.baumgarten committed
28
      WithConfigEntry("PDESolverVerbose", 0).
niklas.baumgarten's avatar
niklas.baumgarten committed
29
30
      WithConfigEntry("NewtonVerbose", 0).
      WithConfigEntry("LinearVerbose", 0).
31
32
33
      WithConfigEntry("ConfigVerbose", 0).
      WithConfigEntry("MeshVerbose", 0).
      WithConfigEntry("MainVerbose", 0).
niklas.baumgarten's avatar
niklas.baumgarten committed
34
35
      WithConfigEntry("MLMCVerbose", 1).
      WithConfigEntry("MCVerbose", 1).
niklas.baumgarten's avatar
niklas.baumgarten committed
36
37
38
39
      WithScreenLogging().
      WithPPM()
  ).RUN_ALL_MPP_TESTS();
}