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

added more tests for mc

parent 70d8b609
......@@ -2,7 +2,7 @@
INSTANTIATE_TEST_SUITE_P(TestMonteCarlo, TestMonteCarloWithoutEpsilon, Values(
TestParams{"ScalarGeneratorProblem", "FunctionEvaluation", "DummyPDESolver"},
TestParams{"ScalarGeneratorProblem", "FunctionEvaluation", "DummyPDESolver", 1, true},
TestParams{"StochasticLaplace1D", "L2", "LagrangeElliptic", 5},
TestParams{"StochasticLaplace2D", "L2", "LagrangeElliptic"},
TestParams{"StochasticLaplace2DTest", "L2", "LagrangeElliptic"},
......@@ -26,23 +26,37 @@ TEST_P(TestMonteCarloWithoutEpsilon, TestSeriellAgainstParallel) {
EXPECT_NEAR(mcParallel->aggregate.sVar.Y, mcSeriell->aggregate.sVar.Y, SVarTol());
}
//INSTANTIATE_TEST_SUITE_P(TestMonteCarlo, TestMonteCarloWithEpsilon, Values(
// TestParams{"ScalarGeneratorProblem", "FunctionEvaluation", "DummyPDESolver"},
// TestParams{"StochasticLaplace2DTest", "L2", "LagrangeElliptic"},
// TestParams{"StochasticLaplace2DTest", "Outflow", "HybridElliptic"}
//));
//
//TEST_P(TestMonteCarloWithEpsilon, TestWithEpsilon) {
// mout << GetParam() << endl;
//
// mout.StartBlock("Monte Carlo parallel");
// mout << "Start" << endl;
// mcParallel->Method();
// mout.EndBlock();
// mout << endl;
//
// mcParallel->EstimatorResults();
//}
INSTANTIATE_TEST_SUITE_P(TestMonteCarlo, TestMonteCarloWithEpsilon, Values(
TestParams{"ScalarGeneratorProblem", "FunctionEvaluation", "DummyPDESolver", 1, true},
TestParams{"StochasticLaplace1D", "L2", "LagrangeElliptic", 5},
TestParams{"StochasticLaplace2D", "L2", "LagrangeElliptic"},
TestParams{"StochasticLaplace2DTest", "L2", "LagrangeElliptic"},
TestParams{"StochasticLaplace2DTest", "Outflow", "HybridElliptic"}
));
TEST_P(TestMonteCarloWithEpsilon, TestSeriell) {
mout << GetParam() << endl;
mcSeriell->Method();
mout << endl;
mcSeriell->EstimatorResults();
EXPECT_LE(mcSeriell->StochasticError(), mcSeriell->Epsilon());
EXPECT_LE(mcSeriell->NumericError(), mcSeriell->Epsilon());
EXPECT_LE(mcSeriell->TotalError(), mcSeriell->Epsilon());
}
TEST_P(TestMonteCarloWithEpsilon, TestParallel) {
mout << GetParam() << endl;
mcParallel->Method();
mout << endl;
mcParallel->EstimatorResults();
EXPECT_LE(mcParallel->StochasticError(), mcParallel->Epsilon());
EXPECT_LE(mcParallel->NumericError(), mcParallel->Epsilon());
EXPECT_LE(mcParallel->TotalError(), mcParallel->Epsilon());
}
int main(int argc, char **argv) {
return MppTest(
......
......@@ -17,7 +17,7 @@ struct TestParams {
int level = 3;
bool onlyFine = true;
bool onlyFine = false;
};
Logging &operator<<(Logging &s, const TestParams &testParams) {
......@@ -40,9 +40,13 @@ protected:
std::unique_ptr<Estimator> mcParallel;
double MeanTol() const { return sqrt(1.0 / samples); }
double MeanTol() const {
return 2 * max(mcSeriell->StochasticError(), mcParallel->StochasticError());
}
double SVarTol() const { return sqrt(10.0 / samples); }
double SVarTol() const {
return 2 * max(mcSeriell->StochasticError(), mcParallel->StochasticError());
}
TestMonteCarlo(double epsilon, int samples) :
samples(samples), epsilon(epsilon),
......@@ -87,7 +91,7 @@ class TestMonteCarloWithEpsilon : public TestMonteCarlo {
// 0.01
// 0.003
public:
TestMonteCarloWithEpsilon() : TestMonteCarlo(0.03, 10) {}
TestMonteCarloWithEpsilon() : TestMonteCarlo(0.03, 20) {}
};
#endif //TESTMONTECARLO_HPP
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