algorithms fixup

This commit is contained in:
Corentin Le Molgat
2024-02-15 14:23:52 +01:00
parent 57248fe190
commit 4ca5951ecb

View File

@@ -19,16 +19,17 @@
#include <functional>
#include <limits>
#include <utility>
#include <vector>
#include "ortools/base/murmur.h"
#include "absl/base/log_severity.h"
#include "absl/numeric/int128.h"
#include "absl/random/distributions.h"
#include "absl/random/random.h"
#include "absl/strings/str_format.h"
#include "absl/time/time.h"
#include "benchmark/benchmark.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "ortools/base/hash.h"
namespace operations_research {
@@ -208,10 +209,12 @@ TEST(BinarySearchTest, NonMonoticPredicateReachesLocalInflexionPoint_Double) {
constexpr double kEps = std::numeric_limits<double>::epsilon();
const int kNumAttempts = 100000;
for (int attempt = 0; attempt < kNumAttempts; ++attempt) {
const uint64_t hash_seed = random();
std::function<bool(double)> non_monotonic_predicate =
[](double x) {
return util_hash::MurmurHash64(
reinterpret_cast<const char*>(&x), sizeof(x)) & 1;
[hash_seed](double x) {
return fasthash64(reinterpret_cast<const char*>(&x), sizeof(x),
hash_seed) &
1;
};
// Pick a random [x_true, x_false] interval which verifies f(x_true) = true
// and f(x_false) = false.