summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorLester Solbakken <lesters@oath.com>2018-06-15 13:00:48 +0200
committerLester Solbakken <lesters@oath.com>2018-06-15 13:00:48 +0200
commit8c150dc0c10ca361f26b1a73b7383a0f2c4f8a95 (patch)
treecdcf66e3a503a155736c5accd552f7d02dbcb59d /searchlib
parent28be51e5511dd4482c22d9a571b0df78063f2b67 (diff)
Use correct seed and don't use spare for randomNormalStable
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp13
-rw-r--r--searchlib/src/vespa/searchlib/features/random_normal_stable_feature.h6
-rw-r--r--searchlib/src/vespa/searchlib/util/random_normal.h10
3 files changed, 16 insertions, 13 deletions
diff --git a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp
index 55b724285d6..5f3cf7fd063 100644
--- a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp
+++ b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "random_normal_stable_feature.h"
#include "utils.h"
@@ -13,7 +13,7 @@ namespace features {
RandomNormalStableExecutor::RandomNormalStableExecutor(uint64_t seed, double mean, double stddev) :
search::fef::FeatureExecutor(),
- _rnd(mean, stddev, true),
+ _rnd(mean, stddev, false), // don't use spares, as we reset seed on every generation
_seed(seed)
{
LOG(debug, "RandomNormalStableExecutor: seed=%zu, mean=%f, stddev=%f", seed, mean, stddev);
@@ -61,7 +61,7 @@ RandomNormalStableBlueprint::setup(const search::fef::IIndexEnvironment & env,
_stddev = params[1].asDouble();
}
- describeOutput("out" , "A random value drawn from the Gaussian distribution that is stable for a given Stable (document and query)");
+ describeOutput("out" , "A random value drawn from the Gaussian distribution that is stable for a given match (document and query)");
return true;
}
@@ -69,8 +69,11 @@ RandomNormalStableBlueprint::setup(const search::fef::IIndexEnvironment & env,
search::fef::FeatureExecutor &
RandomNormalStableBlueprint::createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const
{
- uint64_t seed = util::strToNum<uint64_t>
- (env.getProperties().lookup(getName(), "seed").get("1024")); // default seed
+ uint64_t seed = _seed;
+ if (seed == 0) {
+ seed = util::strToNum<uint64_t>
+ (env.getProperties().lookup(getName(), "seed").get("1024")); // default seed
+ }
return stash.create<RandomNormalStableExecutor>(seed, _mean, _stddev);
}
diff --git a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.h b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.h
index e0b3232c5a1..129c929ba3d 100644
--- a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.h
+++ b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.h
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
@@ -17,7 +17,7 @@ namespace features {
**/
class RandomNormalStableExecutor : public fef::FeatureExecutor {
private:
- RandomNormal _rnd; // seeded once per match
+ RandomNormal _rnd; // seeded once per match
uint64_t _seed;
public:
@@ -27,7 +27,7 @@ public:
/**
- * Implements the blueprint for the random normal feature.
+ * Implements the blueprint for the random normal stable feature.
*/
class RandomNormalStableBlueprint : public fef::Blueprint {
private:
diff --git a/searchlib/src/vespa/searchlib/util/random_normal.h b/searchlib/src/vespa/searchlib/util/random_normal.h
index 68e98f871d3..74596066312 100644
--- a/searchlib/src/vespa/searchlib/util/random_normal.h
+++ b/searchlib/src/vespa/searchlib/util/random_normal.h
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
@@ -7,6 +7,10 @@
namespace search {
+/**
+ * Draws a random number from the Gaussian distribution
+ * using the Marsaglia polar method.
+ */
class RandomNormal
{
private:
@@ -36,10 +40,6 @@ public:
_rnd.srand48(seed);
}
- /**
- * Draws a random number from the Gaussian distribution
- * using the Marsaglia polar method.
- */
feature_t next() {
feature_t result = _spare;
if (_useSpare && _hasSpare) {