summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2019-05-11 21:02:27 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2019-05-11 21:02:27 +0200
commit18650bf589c459e60c2435d9a547218a744cdb32 (patch)
treeab32e46ab7ac2e52e1cd16070647510952560867 /src
parenteb362a5e4976d69509f35eb9e0c5771500041817 (diff)
Some cleaning up of the sample selection.
Diffstat (limited to 'src')
-rw-r--r--src/sample_selection.cc28
-rw-r--r--src/settings.h24
2 files changed, 26 insertions, 26 deletions
diff --git a/src/sample_selection.cc b/src/sample_selection.cc
index 92c4efc..1c35c87 100644
--- a/src/sample_selection.cc
+++ b/src/sample_selection.cc
@@ -171,14 +171,14 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos)
float value_opt{std::numeric_limits<float>::max()};
// the following three values are mostly for debugging
float random_opt = 0.;
- float distance_opt = 0.;
- float recent_opt = 0.;
+ float close_opt = 0.;
+ float diverse_opt = 0.;
DEBUG(rand, "level: %f, lvl: %f (mean: %.2f, stddev: %.2f,"
"power_min: %f, power_max: %f)\n", level, lvl, mean, stddev, power_min, power_max);
- const float f_distance = settings.sample_selection_f_distance.load();
- const float f_recent = settings.sample_selection_f_recent.load();
+ const float f_close = settings.sample_selection_f_close.load();
+ const float f_diverse = settings.sample_selection_f_diverse.load();
const float f_random = settings.sample_selection_f_random.load();
// start with most promising power value and then stop when reaching far values
@@ -186,8 +186,8 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos)
auto closest_it = std::lower_bound(samples.begin(), samples.end(), lvl);
std::size_t up_index = std::distance(samples.begin(), closest_it);
std::size_t down_index = (up_index == 0 ? 0 : up_index - 1);
- float up_value_lb = (up_index < samples.size() ? f_distance*pow2(samples[up_index].power-lvl) : std::numeric_limits<float>::max());
- float down_value_lb = (up_index != 0 ? f_distance*pow2(samples[down_index].power-lvl) : std::numeric_limits<float>::max());
+ float up_value_lb = (up_index < samples.size() ? f_close*pow2(samples[up_index].power-lvl) : std::numeric_limits<float>::max());
+ float down_value_lb = (up_index != 0 ? f_close*pow2(samples[down_index].power-lvl) : std::numeric_limits<float>::max());
std::size_t count = 0;
do
@@ -199,7 +199,7 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos)
if (up_index != samples.size()-1)
{
++up_index;
- up_value_lb = f_distance*pow2(samples[up_index].power-lvl);
+ up_value_lb = f_close*pow2(samples[up_index].power-lvl);
}
else
{
@@ -212,7 +212,7 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos)
if (down_index != 0)
{
--down_index;
- down_value_lb = f_distance*pow2(samples[down_index].power-lvl);
+ down_value_lb = f_close*pow2(samples[down_index].power-lvl);
}
else
{
@@ -221,9 +221,9 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos)
}
auto random = rand.floatInRange(0.,1.);
- auto distance = samples[current_index].power - lvl;
- auto recent = (float)settings.samplerate/std::max<std::size_t>(pos - last[current_index], 1);
- auto value = f_distance*pow2(distance) + f_recent*pow2(recent) + f_random*random;
+ auto close = samples[current_index].power - lvl;
+ auto diverse = (float)settings.samplerate/std::max<std::size_t>(pos - last[current_index], 1);
+ auto value = f_close*pow2(close) + f_diverse*pow2(diverse) + f_random*random;
if (value < value_opt)
{
@@ -231,14 +231,14 @@ const Sample* SampleSelection::getObjective(level_t level, std::size_t pos)
power_opt = samples[current_index].power;
value_opt = value;
random_opt = random;
- distance_opt = distance;
- recent_opt = recent;
+ close_opt = close;
+ diverse_opt = diverse;
}
++count;
}
while (up_value_lb <= value_opt || down_value_lb <= value_opt);
- DEBUG(rand, "Chose sample with index: %d, value: %f, power %f, random: %f, distance: %f, recent: %f, count: %d", (int)index_opt, value_opt, power_opt, random_opt, distance_opt, recent_opt, (int)count);
+ DEBUG(rand, "Chose sample with index: %d, value: %f, power %f, random: %f, close: %f, diverse: %f, count: %d", (int)index_opt, value_opt, power_opt, random_opt, close_opt, diverse_opt, (int)count);
last[index_opt] = pos;
return samples[index_opt].sample;
diff --git a/src/settings.h b/src/settings.h
index 6abbc72..1974bcd 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -75,14 +75,14 @@ struct Settings
static float constexpr velocity_modifier_falloff_default = 0.5f;
static float constexpr velocity_modifier_weight_default = 0.25f;
static float constexpr velocity_stddev_default = 1.0f;
- static float constexpr sample_selection_f_distance_default = 2.f;
- static float constexpr sample_selection_f_recent_default = .3f;
+ static float constexpr sample_selection_f_close_default = 2.f;
+ static float constexpr sample_selection_f_diverse_default = .3f;
static float constexpr sample_selection_f_random_default = 0.05f;
Atomic<float> velocity_modifier_falloff{velocity_modifier_falloff_default};
Atomic<float> velocity_modifier_weight{velocity_modifier_weight_default};
Atomic<float> velocity_stddev{velocity_stddev_default};
- Atomic<float> sample_selection_f_distance{sample_selection_f_distance_default};
- Atomic<float> sample_selection_f_recent{sample_selection_f_recent_default};
+ Atomic<float> sample_selection_f_close{sample_selection_f_close_default};
+ Atomic<float> sample_selection_f_diverse{sample_selection_f_diverse_default};
Atomic<float> sample_selection_f_random{sample_selection_f_random_default};
//! Control number of times to retry sample selection as long as the sample
@@ -170,8 +170,8 @@ struct SettingsGetter
SettingRef<float> velocity_modifier_falloff;
SettingRef<float> velocity_modifier_weight;
SettingRef<float> velocity_stddev;
- SettingRef<float> sample_selection_f_distance;
- SettingRef<float> sample_selection_f_recent;
+ SettingRef<float> sample_selection_f_close;
+ SettingRef<float> sample_selection_f_diverse;
SettingRef<float> sample_selection_f_random;
SettingRef<std::size_t> sample_selection_retry_count;
@@ -224,8 +224,8 @@ struct SettingsGetter
, velocity_modifier_falloff{settings.velocity_modifier_falloff}
, velocity_modifier_weight{settings.velocity_modifier_weight}
, velocity_stddev{settings.velocity_stddev}
- , sample_selection_f_distance{settings.sample_selection_f_distance}
- , sample_selection_f_recent{settings.sample_selection_f_recent}
+ , sample_selection_f_close{settings.sample_selection_f_close}
+ , sample_selection_f_diverse{settings.sample_selection_f_diverse}
, sample_selection_f_random{settings.sample_selection_f_random}
, sample_selection_retry_count(settings.sample_selection_retry_count)
, velocity_modifier_current{settings.velocity_modifier_current}
@@ -278,8 +278,8 @@ public:
Notifier<float> velocity_modifier_falloff;
Notifier<float> velocity_modifier_weight;
Notifier<float> velocity_stddev;
- Notifier<float> sample_selection_f_distance;
- Notifier<float> sample_selection_f_recent;
+ Notifier<float> sample_selection_f_close;
+ Notifier<float> sample_selection_f_diverse;
Notifier<float> sample_selection_f_random;
Notifier<std::size_t> sample_selection_retry_count;
Notifier<float> velocity_modifier_current;
@@ -336,8 +336,8 @@ public:
EVAL(velocity_modifier_falloff);
EVAL(velocity_modifier_weight);
EVAL(velocity_stddev);
- EVAL(sample_selection_f_distance);
- EVAL(sample_selection_f_recent);
+ EVAL(sample_selection_f_close);
+ EVAL(sample_selection_f_diverse);
EVAL(sample_selection_f_random);
EVAL(sample_selection_retry_count);
EVAL(velocity_modifier_current);