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
6dc8d671
Commit
6dc8d671
authored
May 15, 2021
by
niklas.baumgarten
Browse files
moving EstimatorMap to Estimator
parent
cba9860d
Changes
2
Hide whitespace changes
Inline
Side-by-side
mlmc/src/estimators/MultilevelEstimator.cpp
View file @
6dc8d671
#include
"MultilevelEstimator.hpp"
EstimatorMap
CreateCollocationMap
(
Levels
initLevels
,
Samples
initSamples
)
{
EstimatorMap
estimatorMap
;
return
estimatorMap
;
}
void
CreateMonteCarloMap
(
EstimatorMap
&
estimatorMap
,
Levels
initLevels
,
Samples
initSamples
)
{
for
(
unsigned
long
i
=
0
;
i
<
initLevels
.
size
();
i
++
)
{
bool
onlyFine
=
(
i
==
0
);
int
M
=
initSamples
[
i
];
estimatorMap
.
insert
(
{
initLevels
[
i
],
new
MonteCarlo
(
initLevels
[
i
],
M
,
onlyFine
,
true
)}
);
}
}
void
MultilevelEstimator
::
Method
()
{
mout
.
StartBlock
(
"Multilevel Method"
);
if
(
epsilon
==
0.0
)
{
vout
(
1
)
<<
"Non
a
daptive
m
ethod"
<<
endl
;
vout
(
1
)
<<
"Non
-A
daptive
M
ethod"
<<
endl
;
method
();
}
else
{
vout
(
1
)
<<
"eps="
<<
to_string
(
epsilon
)
<<
endl
;
vout
(
1
)
<<
"eps
ilon
="
<<
to_string
(
epsilon
)
<<
endl
;
adaptiveMethod
();
}
...
...
@@ -72,12 +56,6 @@ void MultilevelEstimator::adaptiveMethod() {
}
}
void
MultilevelEstimator
::
PrintInfo
()
const
{
mout
.
PrintInfo
(
"MultilevelEstimator"
,
verbose
,
PrintInfoEntry
(
"initLevels"
,
vec2str
(
initLevels
)),
PrintInfoEntry
(
"initSample"
,
vec2str
(
initSamples
)));
}
void
MultilevelEstimator
::
MultilevelResults
()
const
{
data
.
MultilevelResults
();
}
...
...
mlmc/src/estimators/MultilevelEstimator.hpp
View file @
6dc8d671
...
...
@@ -8,50 +8,13 @@
#include
"Estimator.hpp"
struct
EstimatorMap
:
public
LevelMap
<
Estimator
*>
{
int
maxLevel
=
10
;
EstimatorMap
()
{
config
.
get
(
"maxLevel"
,
maxLevel
);
};
EstimatorMap
(
std
::
initializer_list
<
std
::
pair
<
int
,
Estimator
*>>
estimatorMap
)
:
LevelMap
<
Estimator
*>
(
estimatorMap
)
{
config
.
get
(
"maxLevel"
,
maxLevel
);
};
void
UpdateSampleCounter
(
double
epsilon
);
void
AppendLevel
(
double
epsilon
,
Exponents
exponents
,
int
newLevel
);
void
SetEstimatorMapData
(
const
MultilevelData
&
_data
)
{
for
(
auto
&
[
level
,
estimator
]
:
_levelMap
)
{
estimator
->
aggregate
.
ctr
=
_data
.
ctrs
.
at
(
level
);
estimator
->
aggregate
.
mean
=
_data
.
means
.
at
(
level
);
estimator
->
aggregate
.
sVar
=
_data
.
sVars
.
at
(
level
);
estimator
->
aggregate
.
kurtosis
=
_data
.
kurtosis
.
at
(
level
);
}
}
};
typedef
std
::
vector
<
int
>
Levels
;
typedef
std
::
vector
<
int
>
Samples
;
EstimatorMap
CreateCollocationMap
(
Levels
initLevels
,
Samples
initSamples
);
void
CreateMonteCarloMap
(
EstimatorMap
&
estimatorMap
,
Levels
initLevels
,
Samples
initSamples
);
class
MultilevelEstimator
:
public
Estimator
{
private:
int
verbose
=
1
;
Levels
initLevels
{
3
,
4
,
5
}
;
Levels
initLevels
;
Samples
initSamples
{
12
,
6
,
3
}
;
Samples
initSamples
;
void
adaptiveMethod
();
...
...
@@ -66,17 +29,15 @@ public:
MultilevelErrors
mlErrors
;
MultilevelEstimator
(
)
:
Estimator
()
{
config
.
get
(
"MLMCVerbose"
,
verbose
);
config
.
get
(
"initLevels"
,
initLevels
);
config
.
get
(
"initSamples"
,
initSamples
);
MultilevelEstimator
(
Levels
initLevels
,
Samples
initSamples
,
const
std
::
string
&
estName
,
bool
parallel
,
MeshesCreator
meshesCreator
=
MeshesCreator
(),
PDESolverCreator
pdeCreator
=
PDESolverCreator
())
:
Estimator
()
{
CreateMonteCarloMap
(
estimatorMap
,
initLevels
,
initSamples
);
}
MultilevelEstimator
(
const
EstimatorMap
&
estimatorMap
)
:
Estimator
(),
estimatorMap
(
estimatorMap
)
{
config
.
get
(
"MLMCVerbose"
,
verbose
);
estimatorMap
.
Fill
(
initLevels
,
initSamples
,
estName
,
parallel
,
meshesCreator
,
pdeCreator
);
}
~
MultilevelEstimator
()
{
...
...
@@ -89,8 +50,6 @@ public:
void
Method
()
override
;
void
PrintInfo
()
const
;
void
MultilevelResults
()
const
override
;
void
ExponentResults
()
const
override
;
...
...
Write
Preview
Supports
Markdown
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