Commit 7ab473f5 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

fix and refactoring

parent 109cc0b9
Pipeline #115815 canceled with stages
in 17 minutes and 51 seconds
......@@ -19,12 +19,12 @@ void MonteCarloMap::UpdateSampleCounter(double epsilon) {
void MonteCarloMap::AppendLevel(double epsilon, Exponents exponents,
Level newLevel, MonteCarlo *newMc) {
if (newLevel <= 9) {
if (newLevel <= maxLevel) {
auto oldLevel = this->rbegin()->first;
(*this)[newLevel] = newMc;
(*this)[newLevel]->vars.Y =
(*this)[newLevel - 1]->vars.Y * pow(2.0, exponents.beta);
(*this)[newLevel]->vars.Y = (*this)[oldLevel]->vars.Y / pow(2.0, exponents.beta);
(*this)[newLevel]->avgs.Cost =
(*this)[newLevel - 1]->avgs.Cost * pow(2.0, exponents.gamma);
(*this)[oldLevel]->avgs.Cost * pow(2.0, exponents.gamma);
(*this).UpdateSampleCounter(epsilon);
} else {
Exit ("Maximum level has been reached.")
......
......@@ -10,7 +10,7 @@
// Todo: make second key template for degree to realize MultidegreeMonteCarlo
// Todo: also key should include proc information
template<typename T>
struct LevelMap : std::map<Level, T> {
struct LevelMap : public std::map<Level, T> {
std::vector<int> GetLevelVector() const {
std::vector<int> levelVector;
for (auto &&[level, entry]: *this)
......@@ -71,12 +71,18 @@ struct LevelMap : std::map<Level, T> {
struct Exponents;
struct MonteCarloMap : LevelMap<MonteCarlo *> {
struct MonteCarloMap : public LevelMap<MonteCarlo *> {
MonteCarloMap() {};
int maxLevel = 10;
MonteCarloMap() {
config.get("maxLevel", maxLevel);
};
MonteCarloMap(std::initializer_list<std::pair<Level, MonteCarlo *>> mcMap) :
LevelMap<MonteCarlo *>(mcMap) {};
LevelMap<MonteCarlo *>(mcMap) {
config.get("maxLevel", maxLevel);
};
void UpdateSampleCounter(double epsilon);
......@@ -84,7 +90,7 @@ struct MonteCarloMap : LevelMap<MonteCarlo *> {
Level newLevel, MonteCarlo *newMc);
};
struct SampleCounterMap : LevelMap<SampleCounter> {
struct SampleCounterMap : public LevelMap<SampleCounter> {
SampleCounterMap() {};
......@@ -96,7 +102,7 @@ struct SampleCounterMap : LevelMap<SampleCounter> {
bool NoSamplesLeft();
};
struct AveragesMap : LevelMap<Averages> {
struct AveragesMap : public LevelMap<Averages> {
double Q = 0.0;
double Cost = 0.0;
......@@ -112,7 +118,7 @@ struct AveragesMap : LevelMap<Averages> {
void Update(const MonteCarloMap &mcMap);
};
struct VariancesMap : LevelMap<Variances> {
struct VariancesMap : public LevelMap<Variances> {
VariancesMap() {};
......
Supports Markdown
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