Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mpp
MLUQ
Commits
a02fd73b
Commit
a02fd73b
authored
May 15, 2021
by
niklas.baumgarten
Browse files
started with multilevel test
parent
92337c7d
Pipeline
#149572
failed with stages
in 17 minutes and 27 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
mlmc/tests/estimators/TestMultilevelMonteCarlo.cpp
View file @
a02fd73b
#include "TestMultilevelMonteCarlo.hpp"
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
);
}
int
main
(
int
argc
,
char
**
argv
)
{
return
MppTest
(
MppTestBuilder
(
argc
,
argv
).
WithConfigEntry
(
"Model"
,
"LagrangeElliptic"
).
WithConfigEntry
(
"Quantity"
,
"L2"
).
WithConfigEntry
(
"degree"
,
1
).
WithConfigEntry
(
"maxLevel"
,
8
).
WithConfigEntry
(
"MCParallel"
,
false
).
WithConfigEntry
(
"StochasticField"
,
"LogNormal"
).
WithConfigEntry
(
"lambda"
,
"[0.15, 0.15]"
).
WithConfigEntry
(
"Mean"
,
0.0
).
WithConfigEntry
(
"sigma"
,
1.0
).
WithConfigEntry
(
"smoothing"
,
1.8
).
WithConfigEntry
(
"PDESolverPlotting"
,
1
).
WithConfigEntry
(
"GeneratorVerbose"
,
0
).
WithConfigEntry
(
"PDESolverVerbose"
,
0
).
WithConfigEntry
(
"NewtonVerbose"
,
0
).
WithConfigEntry
(
"LinearVerbose"
,
0
).
WithConfigEntry
(
"ConfigVerbose"
,
1
).
WithConfigEntry
(
"MeshVerbose"
,
1
).
WithConfigEntry
(
"MainVerbose"
,
1
).
WithConfigEntry
(
"MLMCVerbose"
,
1
).
WithConfigEntry
(
"MCVerbose"
,
1
).
WithConfigEntry
(
"ConfigVerbose"
,
0
).
WithConfigEntry
(
"MeshVerbose"
,
0
).
WithConfigEntry
(
"MainVerbose"
,
0
).
WithConfigEntry
(
"MLMCVerbose"
,
0
).
WithConfigEntry
(
"MCVerbose"
,
0
).
WithScreenLogging
().
WithPPM
()
).
RUN_ALL_MPP_TESTS
();
...
...
mlmc/tests/estimators/TestMultilevelMonteCarlo.hpp
View file @
a02fd73b
...
...
@@ -3,24 +3,62 @@
#include "MultilevelEstimator.hpp"
#include "Test
Environment
.hpp"
#include "Test
MonteCarlo
.hpp"
struct
TestParams
{
class
TestMultilevelMonteCarlo
:
public
TestWithParam
<
TestParams
>
{
protected:
double
epsilon
=
0.003
;
Levels
levels
{
3
,
4
,
5
};
Samples
samples
{
12
,
6
,
3
};
};
class
TestMultilevelMonteCarlo
:
public
TestWithParam
<
TestParams
>
{
protected:
EstimatorMap
estimatorMap
;
MeshesCreator
meshesCreator
;
PDESolverCreator
pdeSolverCreator
;
EstimatorMap
estMapSeriell
;
EstimatorMap
estMapParallel
;
std
::
unique_ptr
<
Estimator
>
mlmcSeriell
;
std
::
unique_ptr
<
Estimator
>
mlmcParallel
;
double
MeanTolerance
()
{
return
mlmcSeriell
->
TotalError
();
}
double
SVarTolerance
()
{
return
mlmcSeriell
->
TotalError
();
}
TestMultilevelMonteCarlo
()
:
meshesCreator
(
MeshesCreator
().
WithDistribute
(
"RCB"
).
WithoutOverlap
()),
pdeSolverCreator
(
PDESolverCreator
().
WithProblem
(
GetParam
().
problemName
).
WithQuantity
(
GetParam
().
quantity
).
WithModel
(
GetParam
().
model
)),
mlmcSeriell
(
EstimatorCreator
(
"MultilevelMonteCarlo"
).
WithPDESolverCreator
(
pdeSolverCreator
).
WithMeshesCreator
(
meshesCreator
).
WithInitSamples
(
samples
).
WithInitLevel
(
levels
).
WithEpsilon
(
epsilon
).
WithParallel
(
false
).
CreateUnique
()),
MultilevelEstimator
mlmc
;
mlmcParallel
(
EstimatorCreator
(
"MultilevelMonteCarlo"
).
WithPDESolverCreator
(
pdeSolverCreator
).
WithMeshesCreator
(
meshesCreator
).
WithInitSamples
(
samples
).
WithInitLevel
(
levels
).
WithEpsilon
(
epsilon
).
WithParallel
(
true
).
CreateUnique
())
{
TestMultilevelMonteCarlo
()
{
CreateMonteCarloMap
(
estimatorMap
,
GetParam
().
levels
,
GetParam
().
samples
);
mlmc
=
MultilevelEstimator
(
estimatorMap
);
mlmc
.
Method
();
mlmcSeriell
->
Method
();
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment