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

added test cases

parent 82515b7d
Pipeline #168595 failed with stages
in 23 minutes and 50 seconds
......@@ -2,9 +2,10 @@
INSTANTIATE_TEST_SUITE_P(TestMultilevelMonteCarlo, TestMLMCWithoutEpsilon, Values(
// TestParams{"StochasticLaplace1D", "L2", "LagrangeElliptic"},
TestParams{"StochasticLaplace2DTest", "L2", "LagrangeElliptic"}
// TestParams{"StochasticLaplace2DTest", "L2", "LagrangeElliptic"}
TestParams{"StochasticLaplace1D", "L2", "LagrangeElliptic", {5, 6, 7}},
// TestParams{"StochasticLaplace2D", "L2", "LagrangeElliptic"},
TestParams{"StochasticLaplace2DTest", "L2", "LagrangeElliptic"},
TestParams{"StochasticLaplace2DTest", "Outflow", "HybridElliptic"}
));
TEST_P(TestMLMCWithoutEpsilon, TestSeriellAgainstParallel) {
......@@ -36,28 +37,29 @@ TEST_P(TestMLMCWithoutEpsilon, TestSeriellAgainstParallel) {
EXPECT_TRUE(mlmcParallel->GetExponents().gamma > 0);
}
//INSTANTIATE_TEST_SUITE_P(
// TestMultilevelMonteCarlo, TestMultilevelMonteCarloWithEpsilon, Values(
// TestParams{"StochasticLaplace1D", "L2", "LagrangeElliptic"},
// TestParams{"StochasticLaplace2D", "L2", "LagrangeElliptic"}
//));
//
//TEST_P(TestMultilevelMonteCarloWithEpsilon, TestWithEpsilon) {
// mout << GetParam() << endl;
// mlmcSeriell->Method();
// mlmcSeriell->EstimatorResults();
// mlmcSeriell->MultilevelResults();
// mlmcSeriell->ExponentResults();
//
// mout << GetParam() << endl;
// mlmcParallel->Method();
// mlmcParallel->EstimatorResults();
// mlmcParallel->MultilevelResults();
// mlmcParallel->ExponentResults();
//
// EXPECT_LE(mlmcSeriell->TotalError(), epsilon);
// EXPECT_LE(mlmcParallel->TotalError(), epsilon);
//}
INSTANTIATE_TEST_SUITE_P(TestMultilevelMonteCarlo, TestMLMCWithEpsilon, Values(
TestParams{"StochasticLaplace1D", "L2", "LagrangeElliptic", {5, 6, 7}},
TestParams{"StochasticLaplace2D", "L2", "LagrangeElliptic"},
TestParams{"StochasticLaplace2DTest", "L2", "LagrangeElliptic"},
TestParams{"StochasticLaplace2DTest", "Outflow", "HybridElliptic"}
));
TEST_P(TestMLMCWithEpsilon, TestWithEpsilon) {
mout << GetParam() << endl;
mlmcSeriell->Method();
mlmcSeriell->EstimatorResults();
mlmcSeriell->MultilevelResults();
mlmcSeriell->ExponentResults();
mout << GetParam() << endl;
mlmcParallel->Method();
mlmcParallel->EstimatorResults();
mlmcParallel->MultilevelResults();
mlmcParallel->ExponentResults();
EXPECT_LE(mlmcSeriell->TotalError(), epsilon);
EXPECT_LE(mlmcParallel->TotalError(), epsilon);
}
int main(int argc, char **argv) {
return MppTest(
......
......@@ -3,12 +3,26 @@
#include "MultilevelEstimator.hpp"
#include "TestMonteCarlo.hpp"
#include "TestEnvironment.hpp"
struct TestParams {
std::string problemName;
std::string quantity;
std::string model;
Levels levels{3, 4, 5};
};
Logging &operator<<(Logging &s, const TestParams &testParams) {
return s << "Problem Name: " << testParams.problemName << endl
<< "Quantity: " << testParams.quantity << endl
<< "Model: " << testParams.model << endl;
}
class TestMultilevelMonteCarlo : public TestWithParam<TestParams> {
protected:
Levels levels{3, 4, 5};
Samples samples;
......@@ -22,9 +36,13 @@ protected:
std::unique_ptr<Estimator> mlmcParallel;
double MeanTol() const { return epsilon; }
double MeanTol() const {
return 2 * max(mlmcSeriell->StochasticError(), mlmcParallel->StochasticError());
}
double SVarTol() const { return epsilon; }
double SVarTol() const {
return 2 * max(mlmcSeriell->StochasticError(), mlmcParallel->StochasticError());
}
TestMultilevelMonteCarlo(double epsilon, const Samples &samples) :
samples(samples), epsilon(epsilon),
......@@ -41,8 +59,8 @@ protected:
mlmcSeriell(EstimatorCreator(MULTILEVEL_MONTE_CARLO).
WithPDESolverCreator(pdeSolverCreator).
WithMeshesCreator(meshesCreator).
WithInitLevel(GetParam().levels).
WithInitSamples(samples).
WithInitLevel(levels).
WithEpsilon(epsilon).
WithParallel(false).
CreateUnique()),
......@@ -50,8 +68,8 @@ protected:
mlmcParallel(EstimatorCreator(MULTILEVEL_MONTE_CARLO).
WithPDESolverCreator(pdeSolverCreator).
WithMeshesCreator(meshesCreator).
WithInitLevel(GetParam().levels).
WithInitSamples(samples).
WithInitLevel(levels).
WithEpsilon(epsilon).
WithParallel(true).
CreateUnique()) {}
......@@ -65,9 +83,9 @@ public:
TestMultilevelMonteCarlo(0.0, {100, 100, 100}) {}
};
class TestMultilevelMonteCarloWithEpsilon : public TestMultilevelMonteCarlo {
class TestMLMCWithEpsilon : public TestMultilevelMonteCarlo {
public:
TestMultilevelMonteCarloWithEpsilon() :
TestMLMCWithEpsilon() :
TestMultilevelMonteCarlo(0.003, {12, 6, 3}) {}
};
......
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