summaryrefslogtreecommitdiff
path: root/src/sample_selection.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2019-03-07 01:24:24 +0100
committerAndré Nusser <andre.nusser@googlemail.com>2019-05-11 14:54:51 +0200
commitdcff4b6914d07c6dcff9cbbdc93dc0f4dc146d44 (patch)
tree4dd09bdc241754a29aae65d92a55c069fd4d2130 /src/sample_selection.cc
parenta673a209a71b06488df3244903b5b4b7f994451d (diff)
Make it simpler to conduct experiments for new sample alg.
Diffstat (limited to 'src/sample_selection.cc')
-rw-r--r--src/sample_selection.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/sample_selection.cc b/src/sample_selection.cc
index 8000879..8616e09 100644
--- a/src/sample_selection.cc
+++ b/src/sample_selection.cc
@@ -49,7 +49,7 @@ float pow2(float f)
} // end anonymous namespace
SampleSelection::SampleSelection(Settings& settings, Random& rand, const PowerList& powerlist)
- : settings(settings), rand(rand), powerlist(powerlist)
+ : settings(settings), rand(rand), powerlist(powerlist), alg(SelectionAlg::Old)
{
}
@@ -108,6 +108,7 @@ const Sample* SampleSelection::getOld(level_t level, std::size_t pos)
float mean = level * (power_span - mean_stepwidth) + (mean_stepwidth / 2.0);
float stddev = velocity_stddev * mean_stepwidth;
+ std::size_t index{0};
float power{0.f};
// note: loop is executed once + #retry
@@ -127,20 +128,21 @@ const Sample* SampleSelection::getOld(level_t level, std::size_t pos)
"level: %f, lvl: %f (mean: %.2f, stddev: %.2f, mean_stepwidth: %f, power_min: %f, power_max: %f)\n",
level, lvl, mean, stddev, mean_stepwidth, power_min, power_max);
- for (auto& item: samples)
+ for (std::size_t i = 0; i < samples.size(); ++i)
{
+ auto const& item = samples[i];
if (sample == nullptr || std::fabs(item.power - lvl) < std::fabs(power - lvl))
{
sample = item.sample;
+ index = i;
power = item.power;
}
}
} while (lastsample == sample && retry >= 0);
- DEBUG(rand, "Found sample with power %f\n", power);
+ DEBUG(rand, "Chose sample with index: %d, power %f", (int)index, power);
lastsample = sample;
-
return sample;
}
@@ -192,7 +194,7 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos)
power_min, power_max);
// TODO: expose parameters to GUI
- float alpha = 1.0;
+ float alpha = 2.0;
float beta = 1.0;
float gamma = .5;