cleanup
This commit is contained in:
@@ -186,7 +186,11 @@ class AdjustableKAryHeap {
|
||||
if (heap_index >= heap_size()) return false;
|
||||
PerformSwap(heap_index, heap_size() - 1);
|
||||
--heap_size_;
|
||||
SiftDown(heap_index);
|
||||
if (HasPriority(heap_index, Parent(heap_index))) {
|
||||
SiftUp(heap_index);
|
||||
} else {
|
||||
SiftDown(heap_index);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,27 @@ TEST(AdjustableKAryHeapTest, UpdateStrongCheck) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(AdjustableKAryHeapTest, RemoveStrongCheck) {
|
||||
const int kSize = 10'000;
|
||||
const int kNumRemovals = kSize;
|
||||
const double priority_range = kSize / 10;
|
||||
std::random_device rd;
|
||||
std::mt19937 generator(rd()); // Mersenne Twister generator
|
||||
std::uniform_real_distribution<float> priority_dist(0, priority_range);
|
||||
std::uniform_int_distribution<int> index_dist(0, kSize);
|
||||
std::vector<PriorityAggregate> subsets_and_values(kSize);
|
||||
for (int i = 0; i < kSize; ++i) {
|
||||
subsets_and_values[i] = {priority_dist(generator), i};
|
||||
}
|
||||
AdjustableKAryHeap<PriorityAggregate, 4, true> heap(subsets_and_values,
|
||||
kSize);
|
||||
EXPECT_TRUE(heap.CheckHeapProperty());
|
||||
for (int iter = 0; iter < kNumRemovals; ++iter) {
|
||||
heap.Remove(iter);
|
||||
EXPECT_TRUE(heap.CheckHeapProperty());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(AdjustableKAryHeapTest, OneByOneStrongCheck) {
|
||||
const int kSize = 10'000;
|
||||
const int kNumInsertions = kSize;
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
#ifndef OR_TOOLS_ALGORITHMS_SET_COVER_MODEL_H_
|
||||
#define OR_TOOLS_ALGORITHMS_SET_COVER_MODEL_H_
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -285,9 +285,9 @@ class MyMPCallback : public MPCallback {
|
||||
MyMPCallback(MPSolver* mpSolver, bool should_throw)
|
||||
: MPCallback(false, false),
|
||||
mpSolver_(mpSolver),
|
||||
should_throw_(should_throw){};
|
||||
should_throw_(should_throw) {};
|
||||
|
||||
~MyMPCallback() override{};
|
||||
~MyMPCallback() override {};
|
||||
|
||||
void RunCallback(MPCallbackContext* callback_context) override {
|
||||
if (should_throw_) {
|
||||
@@ -1354,8 +1354,8 @@ TEST_F(XpressFixtureMIP, CallbackThrowsException) {
|
||||
} // namespace operations_research
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
absl::SetFlag(&FLAGS_stderrthreshold, 0);
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
auto solver = operations_research::MPSolver::CreateSolver("XPRESS_LP");
|
||||
if (solver == nullptr) {
|
||||
LOG(ERROR) << "Xpress solver is not available";
|
||||
|
||||
Reference in New Issue
Block a user