From d5a5101f484649466735af4da3c19b04f1c76c5c Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Wed, 13 Nov 2024 14:28:38 +0100 Subject: [PATCH] fix mac compilation issue --- ortools/algorithms/BUILD.bazel | 3 ++- ortools/algorithms/set_cover_invariant.cc | 6 ++++-- ortools/algorithms/set_cover_model.cc | 3 +-- ortools/algorithms/set_cover_model.h | 8 ++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ortools/algorithms/BUILD.bazel b/ortools/algorithms/BUILD.bazel index 4910c8799f..f0399a5577 100644 --- a/ortools/algorithms/BUILD.bazel +++ b/ortools/algorithms/BUILD.bazel @@ -289,6 +289,7 @@ cc_library( "//ortools/base:strong_vector", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", + "@com_google_absl//absl/numeric:bits", "@com_google_absl//absl/random", "@com_google_absl//absl/random:distributions", "@com_google_absl//absl/strings", @@ -367,8 +368,8 @@ cc_test( ":set_cover_invariant", ":set_cover_mip", ":set_cover_model", - "//ortools/base:parse_text_proto", "//ortools/base:gmock_main", + "//ortools/base:parse_text_proto", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", diff --git a/ortools/algorithms/set_cover_invariant.cc b/ortools/algorithms/set_cover_invariant.cc index c0f41468cd..d997bf5c67 100644 --- a/ortools/algorithms/set_cover_invariant.cc +++ b/ortools/algorithms/set_cover_invariant.cc @@ -103,7 +103,8 @@ void SetCoverInvariant::LoadSolution(const SubsetBoolVector& solution) { is_selected_ = solution; ClearTrace(); ClearRemovabilityInformation(); - for (SubsetIndex subset(0); bool b : solution) { + SubsetIndex subset(0); + for (const bool b : solution) { if (b) { trace_.push_back(SetCoverDecision(subset, true)); } @@ -167,7 +168,8 @@ std::tuple SetCoverInvariant::ComputeCostAndCoverage( // Initialize coverage, update cost, and compute the coverage for // all the elements covered by the selected subsets. const SubsetCostVector& subset_costs = model_->subset_costs(); - for (SubsetIndex subset(0); bool b : choices) { + SubsetIndex subset(0); + for (const bool b : choices) { if (b) { cst += subset_costs[subset]; for (const ElementIndex element : columns[subset]) { diff --git a/ortools/algorithms/set_cover_model.cc b/ortools/algorithms/set_cover_model.cc index dc159f6fc7..3ff87e6d36 100644 --- a/ortools/algorithms/set_cover_model.cc +++ b/ortools/algorithms/set_cover_model.cc @@ -14,18 +14,17 @@ #include "ortools/algorithms/set_cover_model.h" #include -#include #include #include #include #include #include -#include #include #include #include #include "absl/log/check.h" +#include "absl/numeric/bits.h" #include "absl/random/discrete_distribution.h" #include "absl/random/distributions.h" #include "absl/random/random.h" diff --git a/ortools/algorithms/set_cover_model.h b/ortools/algorithms/set_cover_model.h index 684fb3153b..cf7b18cc81 100644 --- a/ortools/algorithms/set_cover_model.h +++ b/ortools/algorithms/set_cover_model.h @@ -44,9 +44,9 @@ // - its columns are such that M(i, j) = 1 iff the i-th element of E is present // in S_j. // -// We alse use m to denote |E|, the number of elements, and n to denote |S|, the +// We also use m to denote |E|, the number of elements, and n to denote |S|, the // number of subsets. -// Finally, nnz or #nz denotes the numbers of non-zeros, i.e. the sum of the +// Finally, NNZ denotes the numbers of non-zeros, i.e. the sum of the // cardinalities of all the subsets. namespace operations_research { @@ -290,11 +290,11 @@ class SetCoverModel { // Vector of columns. Each column corresponds to a subset and contains the // elements of the given subset. - // This takes nnz (number of non-zeros) BaseInts, or |E| * |S| * fill_rate. + // This takes NNZ (number of non-zeros) BaseInts, or |E| * |S| * fill_rate. // On classical benchmarks, the fill rate is in the 2 to 5% range. // Some synthetic benchmarks have fill rates of 20%, while benchmarks for // rail rotations have a fill rate of 0.2 to 0.4%. - // TODO(user): try using a compressed representation like Protocol Buffers, + // TODO(user): try using a compressed representation like VarInt or LEB128, // since the data is only iterated upon. SparseColumnView columns_;