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

missing file

parent b5813e94
#include "EmpiricMeasureLevelMaps.hpp"
#include "Exponents.hpp"
void MonteCarloMap::UpdateSampleCounter(double epsilon) {
int optimalM;
double factor = 0.0;
for (auto &[level, mc] : *this)
factor += sqrt(mc->vars.Y * mc->avgs.Cost);
for (auto &[level, mc] : *this) {
optimalM = (int) (ceil(2 * pow(epsilon, -2) * factor *
sqrt(mc->vars.Y / mc->avgs.Cost)));
if (optimalM == 1) optimalM++; // Hack
mc->ctr.dM = optimalM - mc->ctr.M;
}
}
void MonteCarloMap::AppendLevel(double epsilon, Exponents exponents,
Level newLevel, MonteCarlo *newMc) {
if (newLevel <= 9) {
(*this)[newLevel] = newMc;
(*this)[newLevel]->vars.Y =
(*this)[newLevel - 1]->vars.Y * pow(2.0, exponents.beta);
(*this)[newLevel]->avgs.Cost =
(*this)[newLevel - 1]->avgs.Cost * pow(2.0, exponents.gamma);
(*this).UpdateSampleCounter(epsilon);
} else {
Exit ("Maximum level has been reached.")
}
}
void SampleCounterMap::Update(const MonteCarloMap &mcMap) {
for (auto &[level, mc]: mcMap)
(*this)[level] = mc->ctr;
}
bool SampleCounterMap::NoSamplesLeft() {
bool noSamplesLeft = true;
for (auto &&[level, entry]: *this)
if (entry.dM > 0) {
noSamplesLeft = false;
break;
}
return noSamplesLeft;
}
void AveragesMap::Update(const MonteCarloMap &mcMap) {
for (auto &&[level, mc]: mcMap) {
(*this)[level] = mc->avgs;
Q += mc->avgs.Y;
Cost += mc->avgs.Cost; // Todo at the right place?
}
}
void VariancesMap::Update(const MonteCarloMap &mcMap) {
for (auto &mc: mcMap)
(*this)[mc.first] = mc.second->vars;
}
void KurtosisMap::Update(const MonteCarloMap &mcMap) {
for (auto &mc: mcMap)
(*this)[mc.first] = mc.second->kurtosis;
}
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