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
13b08eb3
Commit
13b08eb3
authored
Sep 28, 2020
by
niklas.baumgarten
Browse files
refactored MonteCarlo
parent
b1fe4c71
Changes
2
Hide whitespace changes
Inline
Side-by-side
mlmc/src/montecarlo/MonteCarlo.cpp
View file @
13b08eb3
...
...
@@ -14,22 +14,18 @@ void MonteCarlo::Method() {
void
MonteCarlo
::
method
()
{
for
(
int
m
=
ctr
.
M
;
m
<
ctr
.
M
+
ctr
.
dM
;
m
++
)
{
fineId
.
number
=
m
;
fineSolution
.
id
=
fineId
;
plotter
->
SetDirectory
(
fineId
);
assemble
->
DrawSample
(
fineId
);
pdeSolver
->
Run
(
assemble
,
fineSolution
);
if
(
!
onlyFine
)
{
coarseId
.
number
=
m
;
coarseSolution
.
id
=
coarseId
;
plotter
->
SetDirectory
(
coarseId
);
assemble
->
DrawSample
(
coarseId
);
pdeSolver
->
Run
(
assemble
,
coarseSolution
);
}
else
{
coarseSolution
.
Init
();
}
sums
.
Update
(
fineSolution
.
Cost
,
fineSolution
.
Q
-
coarseSolution
.
Q
,
fineSolution
.
Q
);
findSampleSolution
(
m
,
fineId
,
fineSolution
);
if
(
onlyFine
)
coarseSolution
.
Init
();
else
findSampleSolution
(
m
,
coarseId
,
coarseSolution
);
sums
.
Update
(
fineSolution
,
coarseSolution
);
ctr
.
Update
();
}
}
void
MonteCarlo
::
findSampleSolution
(
int
m
,
SampleID
&
id
,
SampleSolution
&
solution
)
{
id
.
number
=
m
;
solution
.
id
=
id
;
plotter
->
SetDirectory
(
id
);
assemble
->
DrawSample
(
id
);
pdeSolver
->
Run
(
assemble
,
solution
);
}
mlmc/src/montecarlo/MonteCarlo.hpp
View file @
13b08eb3
...
...
@@ -2,7 +2,7 @@
#define MLMC_MC_HPP
#include "main/MultilevelPlotter.hpp"
#include "
Statist
icMeasures.hpp"
#include "
Empir
icMeasures.hpp"
#include "PDESolver.hpp"
#include "utility/SampleID.hpp"
#include "assemble/IStochasticAssemble.hpp"
...
...
@@ -16,6 +16,8 @@ protected:
virtual
void
method
();
void
findSampleSolution
(
int
m
,
SampleID
&
id
,
SampleSolution
&
solution
);
public:
int
level
=
0
;
int
pLevel
=
0
;
...
...
@@ -45,8 +47,8 @@ public:
level
(
level
),
onlyFine
(
onlyFine
),
assemble
(
assemble
),
pdeSolver
(
pdeSolver
),
solMGraphs
(
MatrixGraphs
(
meshes
,
*
assemble
->
GetDiscretization
())),
coarseSolution
(
SampleSolution
(
solMGraphs
,
level
-
1
)),
fineSolution
(
SampleSolution
(
solMGraphs
,
level
))
{
coarseSolution
(
SampleSolution
(
solMGraphs
,
level
-
meshes
.
pLevel
()
-
1
)),
fineSolution
(
SampleSolution
(
solMGraphs
,
level
-
meshes
.
pLevel
()
))
{
config
.
get
(
"MCPlotting"
,
plotting
);
config
.
get
(
"MCVerbose"
,
verbose
);
...
...
@@ -54,7 +56,7 @@ public:
ctr
.
dM
=
dM
;
fineId
.
level
=
level
;
fineId
.
coarse
=
false
;
coarseId
.
level
=
level
-
1
;
coarseId
.
level
=
level
;
coarseId
.
coarse
=
true
;
}
...
...
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