diff --git a/ortools/algorithms/BUILD.bazel b/ortools/algorithms/BUILD.bazel index cc52651272..186c2eccb4 100644 --- a/ortools/algorithms/BUILD.bazel +++ b/ortools/algorithms/BUILD.bazel @@ -240,9 +240,9 @@ cc_test( srcs = ["knapsack_solver_test.cc"], deps = [ ":knapsack_solver_lib", # buildcleaner: keep - "//ortools/base", "//ortools/base:gmock_main", "//ortools/util:time_limit", + "@com_google_absl//absl/base:core_headers", ], ) @@ -444,8 +444,10 @@ cc_test( ":dynamic_partition", "//ortools/base:gmock_main", "//ortools/base:stl_util", + "@com_google_absl//absl/base:log_severity", "@com_google_absl//absl/random", "@com_google_absl//absl/random:bit_gen_ref", + "@com_google_absl//absl/types:span", ], ) diff --git a/ortools/algorithms/adjustable_k_ary_heap_stress_test.cc b/ortools/algorithms/adjustable_k_ary_heap_stress_test.cc index d9220e1a3c..7e45780d9e 100644 --- a/ortools/algorithms/adjustable_k_ary_heap_stress_test.cc +++ b/ortools/algorithms/adjustable_k_ary_heap_stress_test.cc @@ -17,10 +17,10 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/random/random.h" #include "gtest/gtest.h" #include "ortools/algorithms/adjustable_k_ary_heap.h" -#include "ortools/base/logging.h" // Stress test for AdjustableKaryHeap. // The test generates a random heap of size num_elements. Then, it randomly diff --git a/ortools/algorithms/dynamic_partition_test.cc b/ortools/algorithms/dynamic_partition_test.cc index 62613e6f66..aeacd0686b 100644 --- a/ortools/algorithms/dynamic_partition_test.cc +++ b/ortools/algorithms/dynamic_partition_test.cc @@ -248,8 +248,13 @@ TEST(DynamicPartitionTest, FingerprintStressTest) { // The size are just indicative (in opt mode, we stress it a bit more). // // Timing as of 2014-04-30, on forge: fastbuild=7.5s, opt=22s. - const int kNumPartitions = DEBUG_MODE ? 1000 : 4000; - const int kPartitionSize = DEBUG_MODE ? 10 : 12; +#if defined(NDEBUG) + const int kNumPartitions = 4000; + const int kPartitionSize = 12; +#else + const int kNumPartitions = 1000; + const int kPartitionSize = 10; +#endif const int kMaxNumParts = 3; std::mt19937 random(12345); std::vector> partitions(kNumPartitions); diff --git a/ortools/algorithms/find_graph_symmetries.cc b/ortools/algorithms/find_graph_symmetries.cc index 303f8be04b..65539177c6 100644 --- a/ortools/algorithms/find_graph_symmetries.cc +++ b/ortools/algorithms/find_graph_symmetries.cc @@ -28,6 +28,7 @@ #include "absl/container/flat_hash_set.h" #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/numeric/int128.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" @@ -39,7 +40,6 @@ #include "ortools/algorithms/dynamic_partition.h" #include "ortools/algorithms/dynamic_permutation.h" #include "ortools/algorithms/sparse_permutation.h" -#include "ortools/base/logging.h" #include "ortools/graph/graph.h" #include "ortools/graph/iterators.h" #include "ortools/graph/util.h" diff --git a/ortools/algorithms/n_choose_k.cc b/ortools/algorithms/n_choose_k.cc index 3bbe4d5b39..697e16e2e7 100644 --- a/ortools/algorithms/n_choose_k.cc +++ b/ortools/algorithms/n_choose_k.cc @@ -19,6 +19,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/numeric/int128.h" #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -26,7 +27,6 @@ #include "absl/time/clock.h" #include "absl/time/time.h" #include "ortools/algorithms/binary_search.h" -#include "ortools/base/logging.h" #include "ortools/base/mathutil.h" namespace operations_research { diff --git a/ortools/algorithms/radix_sort.h b/ortools/algorithms/radix_sort.h index 8cc864ed98..7ed8764b06 100644 --- a/ortools/algorithms/radix_sort.h +++ b/ortools/algorithms/radix_sort.h @@ -46,8 +46,8 @@ #include "absl/algorithm/container.h" #include "absl/base/casts.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" namespace operations_research { diff --git a/ortools/algorithms/radix_sort_test.cc b/ortools/algorithms/radix_sort_test.cc index 0f01809939..88957d3ed0 100644 --- a/ortools/algorithms/radix_sort_test.cc +++ b/ortools/algorithms/radix_sort_test.cc @@ -24,6 +24,7 @@ #include #include "absl/algorithm/container.h" +#include "absl/log/log.h" #include "absl/random/bit_gen_ref.h" #include "absl/random/distributions.h" #include "absl/random/random.h" @@ -32,7 +33,6 @@ #include "gtest/gtest.h" #include "ortools/base/dump_vars.h" #include "ortools/base/gmock.h" -#include "ortools/base/logging.h" #include "ortools/base/mathutil.h" namespace operations_research { diff --git a/ortools/algorithms/samples/set_cover.cc b/ortools/algorithms/samples/set_cover.cc index 7d7892335e..0a22765462 100644 --- a/ortools/algorithms/samples/set_cover.cc +++ b/ortools/algorithms/samples/set_cover.cc @@ -15,10 +15,10 @@ // [START import] #include +#include "absl/log/log.h" #include "ortools/algorithms/set_cover_heuristics.h" #include "ortools/algorithms/set_cover_invariant.h" #include "ortools/algorithms/set_cover_model.h" -#include "ortools/base/logging.h" // [END import] namespace operations_research { diff --git a/ortools/algorithms/samples/simple_knapsack_program.cc b/ortools/algorithms/samples/simple_knapsack_program.cc index d48ac81e6b..155d3c0314 100644 --- a/ortools/algorithms/samples/simple_knapsack_program.cc +++ b/ortools/algorithms/samples/simple_knapsack_program.cc @@ -21,8 +21,8 @@ #include #include +#include "absl/log/log.h" #include "ortools/algorithms/knapsack_solver.h" -#include "ortools/base/logging.h" // [END import] namespace operations_research { diff --git a/ortools/algorithms/set_cover_heuristics.cc b/ortools/algorithms/set_cover_heuristics.cc index 27a36f846b..e81bac48a6 100644 --- a/ortools/algorithms/set_cover_heuristics.cc +++ b/ortools/algorithms/set_cover_heuristics.cc @@ -23,6 +23,7 @@ #include "absl/base/casts.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/numeric/bits.h" #include "absl/random/distributions.h" #include "absl/random/random.h" diff --git a/ortools/algorithms/set_cover_invariant.cc b/ortools/algorithms/set_cover_invariant.cc index 00146aabc2..425518a50c 100644 --- a/ortools/algorithms/set_cover_invariant.cc +++ b/ortools/algorithms/set_cover_invariant.cc @@ -19,6 +19,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/types/span.h" #include "ortools/algorithms/set_cover_model.h" #include "ortools/base/logging.h" diff --git a/ortools/algorithms/set_cover_mip.cc b/ortools/algorithms/set_cover_mip.cc index 13c9453196..bfb095e568 100644 --- a/ortools/algorithms/set_cover_mip.cc +++ b/ortools/algorithms/set_cover_mip.cc @@ -17,10 +17,10 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/types/span.h" #include "ortools/algorithms/set_cover_invariant.h" #include "ortools/algorithms/set_cover_model.h" -#include "ortools/base/logging.h" #include "ortools/linear_solver/linear_solver.h" #include "ortools/lp_data/lp_types.h" diff --git a/ortools/algorithms/set_cover_model.cc b/ortools/algorithms/set_cover_model.cc index ff7a8e3f73..0d0e5f59f5 100644 --- a/ortools/algorithms/set_cover_model.cc +++ b/ortools/algorithms/set_cover_model.cc @@ -24,6 +24,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/numeric/bits.h" #include "absl/random/discrete_distribution.h" #include "absl/random/distributions.h" @@ -32,7 +33,6 @@ #include "absl/types/span.h" #include "ortools/algorithms/radix_sort.h" #include "ortools/algorithms/set_cover.pb.h" -#include "ortools/base/logging.h" namespace operations_research { diff --git a/ortools/algorithms/set_cover_reader.cc b/ortools/algorithms/set_cover_reader.cc index 40092a5b2f..a8c3b922f5 100644 --- a/ortools/algorithms/set_cover_reader.cc +++ b/ortools/algorithms/set_cover_reader.cc @@ -23,6 +23,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -32,7 +33,6 @@ #include "ortools/algorithms/set_cover_model.h" #include "ortools/base/file.h" #include "ortools/base/helpers.h" -#include "ortools/base/logging.h" #include "ortools/base/options.h" #include "ortools/util/filelineiter.h" diff --git a/ortools/algorithms/set_cover_solve.cc b/ortools/algorithms/set_cover_solve.cc index 95b139a116..707fff19b3 100644 --- a/ortools/algorithms/set_cover_solve.cc +++ b/ortools/algorithms/set_cover_solve.cc @@ -16,6 +16,7 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/match.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" @@ -25,7 +26,6 @@ #include "ortools/algorithms/set_cover_model.h" #include "ortools/algorithms/set_cover_reader.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/base/timer.h" ABSL_FLAG(std::string, input, "", "REQUIRED: Input file name."); diff --git a/ortools/algorithms/set_cover_test.cc b/ortools/algorithms/set_cover_test.cc index bb343485d8..6ab6d5056d 100644 --- a/ortools/algorithms/set_cover_test.cc +++ b/ortools/algorithms/set_cover_test.cc @@ -16,6 +16,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "benchmark/benchmark.h" #include "gtest/gtest.h" @@ -25,7 +26,6 @@ #include "ortools/algorithms/set_cover_mip.h" #include "ortools/algorithms/set_cover_model.h" #include "ortools/base/gmock.h" -#include "ortools/base/logging.h" #include "ortools/base/parse_text_proto.h" namespace operations_research { diff --git a/ortools/base/file.cc b/ortools/base/file.cc index 6d0cd7445e..0c6b45b708 100644 --- a/ortools/base/file.cc +++ b/ortools/base/file.cc @@ -33,13 +33,13 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/tokenizer.h" #include "google/protobuf/message.h" #include "google/protobuf/text_format.h" -#include "ortools/base/logging.h" File::File(FILE* descriptor, absl::string_view name) : f_(descriptor), name_(name) {} diff --git a/ortools/base/fuzztest.h b/ortools/base/fuzztest.h index 8c7c992aa1..00d868a937 100644 --- a/ortools/base/fuzztest.h +++ b/ortools/base/fuzztest.h @@ -14,19 +14,15 @@ #ifndef OR_TOOLS_BASE_FUZZTEST_H_ #define OR_TOOLS_BASE_FUZZTEST_H_ -#include -#include #include #include #include +// #include "fuzztest/googletest_fixture_adapter.h" #include "fuzztest/domain.h" #include "fuzztest/fuzztest.h" -#include "fuzztest/googletest_fixture_adapter.h" #include "fuzztest/init_fuzztest.h" -#include "google/protobuf/message.h" #include "google/protobuf/text_format.h" -#include "ortools/base/logging.h" namespace fuzztest { diff --git a/ortools/base/gzipstring.h b/ortools/base/gzipstring.h index fb0add93b1..d8185112ce 100644 --- a/ortools/base/gzipstring.h +++ b/ortools/base/gzipstring.h @@ -16,10 +16,12 @@ #include -#include "ortools/base/logging.h" +#include "absl/log/log.h" +#include "absl/strings/string_view.h" +#include "zconf.h" #include "zlib.h" -bool GunzipString(absl::string_view str, std::string* out) { +inline bool GunzipString(absl::string_view str, std::string* out) { z_stream zs; zs.zalloc = Z_NULL; zs.zfree = Z_NULL; @@ -60,7 +62,8 @@ bool GunzipString(absl::string_view str, std::string* out) { return true; } -bool GzipString(absl::string_view uncompressed, std::string* compressed) { +inline bool GzipString(absl::string_view uncompressed, + std::string* compressed) { z_stream zs; zs.zalloc = Z_NULL; zs.zfree = Z_NULL; diff --git a/ortools/base/helpers.h b/ortools/base/helpers.h index ad3210c2e7..72c3cb959a 100644 --- a/ortools/base/helpers.h +++ b/ortools/base/helpers.h @@ -14,6 +14,6 @@ #ifndef OR_TOOLS_BASE_HELPERS_H_ #define OR_TOOLS_BASE_HELPERS_H_ -#include "ortools/base/file.h" +#include "ortools/base/file.h" // IWYU pragma: export #endif // OR_TOOLS_BASE_HELPERS_H_ diff --git a/ortools/base/logging.h b/ortools/base/logging.h index 1452a4b256..489162df16 100644 --- a/ortools/base/logging.h +++ b/ortools/base/logging.h @@ -14,21 +14,21 @@ #ifndef OR_TOOLS_BASE_LOGGING_H_ #define OR_TOOLS_BASE_LOGGING_H_ -#include "absl/base/log_severity.h" -#include "absl/flags/declare.h" -#include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/die_if_null.h" -#include "absl/log/log.h" -#include "absl/log/vlog_is_on.h" -#include "absl/memory/memory.h" -#include "absl/status/status.h" -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" -#include "ortools/base/macros.h" - -// Forward the new flag. -ABSL_DECLARE_FLAG(int, stderrthreshold); +#include "absl/base/log_severity.h" // IWYU pragma: export +#include "absl/base/macros.h" // IWYU pragma: export +#include "absl/flags/declare.h" // IWYU pragma: export +#include "absl/flags/flag.h" // IWYU pragma: export +#include "absl/log/check.h" // IWYU pragma: export +#include "absl/log/die_if_null.h" // IWYU pragma: export +#include "absl/log/globals.h" // IWYU pragma: export +#include "absl/log/log.h" // IWYU pragma: export +#include "absl/log/vlog_is_on.h" // IWYU pragma: export +#include "absl/memory/memory.h" // IWYU pragma: export +#include "absl/status/status.h" // IWYU pragma: export +#include "absl/strings/str_cat.h" // IWYU pragma: export +#include "absl/strings/string_view.h" // IWYU pragma: export +#include "ortools/base/base_export.h" // IWYU pragma: export +#include "ortools/base/macros.h" // IWYU pragma: export namespace operations_research { diff --git a/ortools/base/protobuf_util.h b/ortools/base/protobuf_util.h index 9300fa9cba..8433ec008e 100644 --- a/ortools/base/protobuf_util.h +++ b/ortools/base/protobuf_util.h @@ -17,6 +17,7 @@ #include #include "google/protobuf/repeated_field.h" +#include "google/protobuf/repeated_ptr_field.h" #include "google/protobuf/text_format.h" #include "ortools/base/logging.h" diff --git a/ortools/base/recordio.cc b/ortools/base/recordio.cc index 99b6745dc9..4ee9ea9ed6 100644 --- a/ortools/base/recordio.cc +++ b/ortools/base/recordio.cc @@ -13,18 +13,19 @@ #include "ortools/base/recordio.h" -#include - +#include #include #include -#include "ortools/base/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" +#include "ortools/base/file.h" +#include "zlib.h" namespace recordio { const int RecordWriter::kMagicNumber = 0x3ed7230a; -RecordWriter::RecordWriter(File* const file) - : file_(file), use_compression_(true) {} +RecordWriter::RecordWriter(File* file) : file_(file), use_compression_(true) {} bool RecordWriter::Close() { return file_->Close(); } diff --git a/ortools/bop/bop_base.cc b/ortools/bop/bop_base.cc index 6fde070914..bd8f6693f8 100644 --- a/ortools/bop/bop_base.cc +++ b/ortools/bop/bop_base.cc @@ -21,9 +21,9 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/string_view.h" #include "absl/synchronization/mutex.h" -#include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" #include "ortools/bop/bop_parameters.pb.h" #include "ortools/bop/bop_solution.h" diff --git a/ortools/bop/bop_fs.cc b/ortools/bop/bop_fs.cc index 5cf2a099bf..e60685c664 100644 --- a/ortools/bop/bop_fs.cc +++ b/ortools/bop/bop_fs.cc @@ -23,12 +23,12 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/random/bit_gen_ref.h" #include "absl/random/distributions.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "ortools/algorithms/sparse_permutation.h" -#include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" #include "ortools/bop/bop_base.h" #include "ortools/bop/bop_parameters.pb.h" diff --git a/ortools/bop/bop_lns.cc b/ortools/bop/bop_lns.cc index 121c3e2954..4912f7e791 100644 --- a/ortools/bop/bop_lns.cc +++ b/ortools/bop/bop_lns.cc @@ -21,10 +21,10 @@ #include "absl/cleanup/cleanup.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/random/bit_gen_ref.h" #include "absl/random/distributions.h" #include "absl/strings/string_view.h" -#include "ortools/base/logging.h" #include "ortools/base/strong_vector.h" #include "ortools/bop/bop_base.h" #include "ortools/bop/bop_parameters.pb.h" diff --git a/ortools/bop/bop_portfolio.cc b/ortools/bop/bop_portfolio.cc index 68b146a771..83d1d92e6b 100644 --- a/ortools/bop/bop_portfolio.cc +++ b/ortools/bop/bop_portfolio.cc @@ -24,10 +24,10 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "ortools/algorithms/sparse_permutation.h" -#include "ortools/base/logging.h" #include "ortools/base/stl_util.h" #include "ortools/base/strong_vector.h" #include "ortools/bop/bop_base.h" diff --git a/ortools/bop/bop_solver.cc b/ortools/bop/bop_solver.cc index 1582014952..1c3ebe4930 100644 --- a/ortools/bop/bop_solver.cc +++ b/ortools/bop/bop_solver.cc @@ -19,10 +19,10 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "google/protobuf/text_format.h" -#include "ortools/base/logging.h" #include "ortools/base/threadpool.h" #include "ortools/bop/bop_base.h" #include "ortools/bop/bop_parameters.pb.h" diff --git a/ortools/bop/integral_solver.cc b/ortools/bop/integral_solver.cc index e0ab929420..24c292300c 100644 --- a/ortools/bop/integral_solver.cc +++ b/ortools/bop/integral_solver.cc @@ -22,8 +22,8 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include "ortools/base/logging.h" #include "ortools/bop/bop_solver.h" #include "ortools/bop/bop_types.h" #include "ortools/lp_data/lp_data.h" diff --git a/ortools/constraint_solver/samples/cp_is_fun_cp.cc b/ortools/constraint_solver/samples/cp_is_fun_cp.cc index c69f634ab6..d8af070475 100644 --- a/ortools/constraint_solver/samples/cp_is_fun_cp.cc +++ b/ortools/constraint_solver/samples/cp_is_fun_cp.cc @@ -20,12 +20,14 @@ // This problem has 72 different solutions in base 10. // [START import] #include +#include #include -#include "absl/flags/flag.h" -#include "absl/log/flags.h" +#include "absl/base/log_severity.h" +#include "absl/log/check.h" +#include "absl/log/globals.h" +#include "absl/log/log.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/constraint_solver/constraint_solver.h" // [END import] @@ -147,7 +149,7 @@ void CPIsFunCp() { int main(int argc, char** argv) { InitGoogle(argv[0], &argc, &argv, true); - absl::SetFlag(&FLAGS_stderrthreshold, 0); + absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); operations_research::CPIsFunCp(); return EXIT_SUCCESS; } diff --git a/ortools/constraint_solver/samples/minimal_jobshop_cp.cc b/ortools/constraint_solver/samples/minimal_jobshop_cp.cc index 47591eca79..e8d5d93561 100644 --- a/ortools/constraint_solver/samples/minimal_jobshop_cp.cc +++ b/ortools/constraint_solver/samples/minimal_jobshop_cp.cc @@ -12,6 +12,7 @@ // limitations under the License. #include +#include #include #include #include // std::iota @@ -21,10 +22,10 @@ #include #include -#include "absl/flags/flag.h" -#include "absl/log/flags.h" +#include "absl/base/log_severity.h" +#include "absl/log/globals.h" +#include "absl/log/log.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/constraint_solver/constraint_solver.h" // Solve a job shop problem: @@ -198,7 +199,7 @@ void SolveJobShopExample() { int main(int argc, char** argv) { InitGoogle(argv[0], &argc, &argv, true); - absl::SetFlag(&FLAGS_stderrthreshold, 0); + absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); operations_research::SolveJobShopExample(); return EXIT_SUCCESS; } diff --git a/ortools/constraint_solver/samples/nurses_cp.cc b/ortools/constraint_solver/samples/nurses_cp.cc index 4ab0da3a2b..a01f4400d8 100644 --- a/ortools/constraint_solver/samples/nurses_cp.cc +++ b/ortools/constraint_solver/samples/nurses_cp.cc @@ -13,15 +13,16 @@ #include #include +#include #include #include // std::iota #include #include -#include "absl/flags/flag.h" -#include "absl/log/flags.h" +#include "absl/base/log_severity.h" +#include "absl/log/globals.h" +#include "absl/log/log.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/constraint_solver/constraint_solver.h" namespace operations_research { @@ -205,7 +206,7 @@ void SolveNursesExample() { int main(int argc, char** argv) { InitGoogle(argv[0], &argc, &argv, true); - absl::SetFlag(&FLAGS_stderrthreshold, 0); + absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); operations_research::SolveNursesExample(); return EXIT_SUCCESS; } diff --git a/ortools/constraint_solver/samples/rabbits_and_pheasants_cp.cc b/ortools/constraint_solver/samples/rabbits_and_pheasants_cp.cc index 49ad19fcbc..b88dd99cd2 100644 --- a/ortools/constraint_solver/samples/rabbits_and_pheasants_cp.cc +++ b/ortools/constraint_solver/samples/rabbits_and_pheasants_cp.cc @@ -13,10 +13,12 @@ // Knowing that we see 20 heads and 56 legs, // how many pheasants and rabbits are we looking at ? -#include "absl/flags/flag.h" -#include "absl/log/flags.h" +#include + +#include "absl/base/log_severity.h" +#include "absl/log/globals.h" +#include "absl/log/log.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/constraint_solver/constraint_solver.h" namespace operations_research { @@ -60,7 +62,7 @@ void RunConstraintProgrammingExample() { int main(int argc, char** argv) { InitGoogle(argv[0], &argc, &argv, true); - absl::SetFlag(&FLAGS_stderrthreshold, 0); + absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); operations_research::RunConstraintProgrammingExample(); return EXIT_SUCCESS; } diff --git a/ortools/constraint_solver/samples/simple_ls_program.cc b/ortools/constraint_solver/samples/simple_ls_program.cc index 2db8dbb0ac..05b82fa3e8 100644 --- a/ortools/constraint_solver/samples/simple_ls_program.cc +++ b/ortools/constraint_solver/samples/simple_ls_program.cc @@ -15,11 +15,15 @@ // Local Search. It solves the same trivial problem with a Large // Neighborhood Search approach, a Local Search approach, and a Local // Search with Filter approach. +#include +#include #include -#include "absl/log/flags.h" +#include "absl/base/log_severity.h" +#include "absl/log/check.h" +#include "absl/log/globals.h" +#include "absl/log/log.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/constraint_solver/constraint_solver.h" #include "ortools/constraint_solver/constraint_solveri.h" @@ -199,7 +203,7 @@ void SolveProblem(SolveType solve_type) { int main(int argc, char** argv) { InitGoogle(argv[0], &argc, &argv, true); - absl::SetFlag(&FLAGS_stderrthreshold, 0); + absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); operations_research::SolveProblem(operations_research::LNS); operations_research::SolveProblem(operations_research::LS); operations_research::SolveProblem(operations_research::LS_WITH_FILTER); diff --git a/ortools/constraint_solver/search.cc b/ortools/constraint_solver/search.cc index 84d464ac20..477702ef4d 100644 --- a/ortools/constraint_solver/search.cc +++ b/ortools/constraint_solver/search.cc @@ -27,6 +27,7 @@ #include "absl/container/flat_hash_map.h" #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/random/distributions.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" diff --git a/ortools/flatzinc/checker.cc b/ortools/flatzinc/checker.cc index e606e2800c..c53d56a53a 100644 --- a/ortools/flatzinc/checker.cc +++ b/ortools/flatzinc/checker.cc @@ -25,7 +25,7 @@ #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/log/check.h" -#include "ortools/base/logging.h" +#include "absl/log/log.h" #include "ortools/flatzinc/model.h" #include "ortools/util/logging.h" diff --git a/ortools/flatzinc/cp_model_fz_solver.cc b/ortools/flatzinc/cp_model_fz_solver.cc index 683b671fc6..61baf310f1 100644 --- a/ortools/flatzinc/cp_model_fz_solver.cc +++ b/ortools/flatzinc/cp_model_fz_solver.cc @@ -26,12 +26,12 @@ #include "absl/container/flat_hash_set.h" #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/types/span.h" #include "google/protobuf/text_format.h" #include "ortools/base/iterator_adaptors.h" -#include "ortools/base/logging.h" #include "ortools/flatzinc/checker.h" #include "ortools/flatzinc/model.h" #include "ortools/sat/cp_model.pb.h" diff --git a/ortools/flatzinc/fz.cc b/ortools/flatzinc/fz.cc index 04e4219190..9b7b956c31 100644 --- a/ortools/flatzinc/fz.cc +++ b/ortools/flatzinc/fz.cc @@ -29,6 +29,7 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" #include "absl/log/initialize.h" +#include "absl/log/log.h" #include "absl/strings/match.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" diff --git a/ortools/flatzinc/model.cc b/ortools/flatzinc/model.cc index 08406b222f..0b93d8fa38 100644 --- a/ortools/flatzinc/model.cc +++ b/ortools/flatzinc/model.cc @@ -23,12 +23,12 @@ #include "absl/container/flat_hash_set.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" #include "ortools/base/stl_util.h" #include "ortools/util/logging.h" #include "ortools/util/string_array.h" diff --git a/ortools/flatzinc/parser.cc b/ortools/flatzinc/parser.cc index 7c856bc870..30364eb740 100644 --- a/ortools/flatzinc/parser.cc +++ b/ortools/flatzinc/parser.cc @@ -16,7 +16,7 @@ #include #include -#include "ortools/base/logging.h" +#include "absl/log/log.h" #include "ortools/flatzinc/model.h" #include "ortools/flatzinc/parser.tab.hh" #include "ortools/flatzinc/parser_util.h" diff --git a/ortools/flatzinc/parser.yy b/ortools/flatzinc/parser.yy index 32d7b7069a..3987bf5f16 100644 --- a/ortools/flatzinc/parser.yy +++ b/ortools/flatzinc/parser.yy @@ -34,6 +34,7 @@ typedef operations_research::fz::LexerInfo YYSTYPE; // Code in the implementation file. %code { +#include "absl/log/check.h" #include "absl/strings/match.h" #include "absl/strings/str_format.h" #include "ortools/flatzinc/parser_util.cc" diff --git a/ortools/flatzinc/parser_main.cc b/ortools/flatzinc/parser_main.cc index 505b14e01b..e8466609a0 100644 --- a/ortools/flatzinc/parser_main.cc +++ b/ortools/flatzinc/parser_main.cc @@ -19,9 +19,9 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/match.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/base/timer.h" #include "ortools/flatzinc/model.h" #include "ortools/flatzinc/parser.h" diff --git a/ortools/glop/lp_solver.cc b/ortools/glop/lp_solver.cc index c3c711b2ff..212fdef013 100644 --- a/ortools/glop/lp_solver.cc +++ b/ortools/glop/lp_solver.cc @@ -21,10 +21,10 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "google/protobuf/text_format.h" -#include "ortools/base/logging.h" #include "ortools/base/version.h" #include "ortools/glop/parameters.pb.h" #include "ortools/glop/preprocessor.h" diff --git a/ortools/glop/primal_edge_norms.cc b/ortools/glop/primal_edge_norms.cc index 9840b83dc6..d0eeb1683e 100644 --- a/ortools/glop/primal_edge_norms.cc +++ b/ortools/glop/primal_edge_norms.cc @@ -17,7 +17,7 @@ #include #include "absl/log/check.h" -#include "ortools/base/logging.h" +#include "absl/log/log.h" #include "ortools/glop/basis_representation.h" #include "ortools/glop/parameters.pb.h" #include "ortools/glop/update_row.h" diff --git a/ortools/glop/reduced_costs.cc b/ortools/glop/reduced_costs.cc index 9adb31a54f..4542c3ff03 100644 --- a/ortools/glop/reduced_costs.cc +++ b/ortools/glop/reduced_costs.cc @@ -18,8 +18,8 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/random/bit_gen_ref.h" -#include "ortools/base/logging.h" #include "ortools/glop/basis_representation.h" #include "ortools/glop/parameters.pb.h" #include "ortools/glop/primal_edge_norms.h" diff --git a/ortools/glop/update_row.cc b/ortools/glop/update_row.cc index f73da6b1bc..cc10283d6e 100644 --- a/ortools/glop/update_row.cc +++ b/ortools/glop/update_row.cc @@ -17,8 +17,8 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" #include "ortools/glop/basis_representation.h" #include "ortools/glop/parameters.pb.h" #include "ortools/glop/variables_info.h" diff --git a/ortools/glop/variable_values.cc b/ortools/glop/variable_values.cc index a433ca24c7..734ee5fd4f 100644 --- a/ortools/glop/variable_values.cc +++ b/ortools/glop/variable_values.cc @@ -19,8 +19,8 @@ #include "absl/base/attributes.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" #include "ortools/glop/basis_representation.h" #include "ortools/glop/dual_edge_norms.h" #include "ortools/glop/parameters.pb.h" diff --git a/ortools/graph/bidirectional_dijkstra.h b/ortools/graph/bidirectional_dijkstra.h index e83c08c050..c0bd51e6ab 100644 --- a/ortools/graph/bidirectional_dijkstra.h +++ b/ortools/graph/bidirectional_dijkstra.h @@ -21,6 +21,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/synchronization/mutex.h" #include "absl/synchronization/notification.h" diff --git a/ortools/graph/cliques_test.cc b/ortools/graph/cliques_test.cc index b005d0fd48..1a9341f3fe 100644 --- a/ortools/graph/cliques_test.cc +++ b/ortools/graph/cliques_test.cc @@ -27,12 +27,12 @@ #include "absl/flags/flag.h" #include "absl/functional/bind_front.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/random/distributions.h" #include "absl/strings/str_cat.h" #include "absl/types/span.h" #include "benchmark/benchmark.h" #include "gtest/gtest.h" -#include "ortools/base/logging.h" #include "ortools/util/time_limit.h" namespace operations_research { diff --git a/ortools/graph/dag_shortest_path.h b/ortools/graph/dag_shortest_path.h index 6d615937c7..91d11bd8d9 100644 --- a/ortools/graph/dag_shortest_path.h +++ b/ortools/graph/dag_shortest_path.h @@ -24,10 +24,10 @@ #include "absl/algorithm/container.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" namespace operations_research { // TODO(b/332475231): extend to non-floating lengths. diff --git a/ortools/graph/hamiltonian_path_test.cc b/ortools/graph/hamiltonian_path_test.cc index 01d7c6a43e..1fd5a23c14 100644 --- a/ortools/graph/hamiltonian_path_test.cc +++ b/ortools/graph/hamiltonian_path_test.cc @@ -15,18 +15,19 @@ #include #include -#include #include +#include #include #include #include +#include "absl/base/macros.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/random/distributions.h" #include "absl/strings/str_format.h" #include "absl/types/span.h" #include "gtest/gtest.h" -#include "ortools/base/logging.h" -#include "ortools/base/macros.h" namespace operations_research { diff --git a/ortools/graph/k_shortest_paths.h b/ortools/graph/k_shortest_paths.h index cd61e2b002..64fc2a8bc7 100644 --- a/ortools/graph/k_shortest_paths.h +++ b/ortools/graph/k_shortest_paths.h @@ -66,9 +66,9 @@ #include "absl/base/optimization.h" #include "absl/container/flat_hash_set.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_join.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" #include "ortools/graph/bounded_dijkstra.h" #include "ortools/graph/shortest_paths.h" diff --git a/ortools/graph/line_graph.h b/ortools/graph/line_graph.h index 697b9f0070..ee849cfdbf 100644 --- a/ortools/graph/line_graph.h +++ b/ortools/graph/line_graph.h @@ -14,7 +14,7 @@ #ifndef OR_TOOLS_GRAPH_LINE_GRAPH_H_ #define OR_TOOLS_GRAPH_LINE_GRAPH_H_ -#include "ortools/base/logging.h" +#include "absl/log/log.h" namespace operations_research { diff --git a/ortools/graph/min_cost_flow.cc b/ortools/graph/min_cost_flow.cc index 71e0e50096..99b680019b 100644 --- a/ortools/graph/min_cost_flow.cc +++ b/ortools/graph/min_cost_flow.cc @@ -24,9 +24,9 @@ #include "absl/base/attributes.h" #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" -#include "ortools/base/logging.h" #include "ortools/base/mathutil.h" #include "ortools/graph/generic_max_flow.h" #include "ortools/graph/graph.h" diff --git a/ortools/graph/min_cost_flow.h b/ortools/graph/min_cost_flow.h index 90964c7893..6dde2db8eb 100644 --- a/ortools/graph/min_cost_flow.h +++ b/ortools/graph/min_cost_flow.h @@ -173,8 +173,8 @@ #include #include +#include "absl/log/log.h" #include "absl/strings/string_view.h" -#include "ortools/base/logging.h" #include "ortools/graph/graph.h" #include "ortools/util/stats.h" #include "ortools/util/zvector.h" diff --git a/ortools/graph/min_cost_flow_test.cc b/ortools/graph/min_cost_flow_test.cc index f4b7d39e3e..fc2c6d3e8a 100644 --- a/ortools/graph/min_cost_flow_test.cc +++ b/ortools/graph/min_cost_flow_test.cc @@ -21,20 +21,22 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/random/distributions.h" #include "absl/strings/str_format.h" #include "absl/types/span.h" #include "benchmark/benchmark.h" #include "gtest/gtest.h" #include "ortools/algorithms/binary_search.h" -#include "ortools/base/logging.h" -#include "ortools/graph/ebert_graph.h" #include "ortools/graph/graph.h" #include "ortools/linear_solver/linear_solver.h" namespace operations_research { namespace { +using FlowQuantity = int64_t; +using CostValue = int64_t; + TEST(SolveTest, CapacityTooLarge) { using Graph = ::util::ReverseArcListGraph; using Solver = @@ -162,8 +164,10 @@ TYPED_TEST(GenericMinCostFlowTest, CapacityRange) { const int kNumNodes = 7; const int kNumArcs = 12; const FlowQuantity kNodeSupply[kNumNodes] = {20, 10, 25, -11, -13, -17, -14}; - const NodeIndex kTail[kNumArcs] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2}; - const NodeIndex kHead[kNumArcs] = {3, 4, 5, 6, 3, 4, 5, 6, 3, 4, 5, 6}; + const typename TypeParam::NodeIndex kTail[kNumArcs] = {0, 0, 0, 0, 1, 1, + 1, 1, 2, 2, 2, 2}; + const typename TypeParam::NodeIndex kHead[kNumArcs] = {3, 4, 5, 6, 3, 4, + 5, 6, 3, 4, 5, 6}; const CostValue kCost[kNumArcs] = {1, 6, 3, 5, 7, 3, 1, 6, 9, 4, 5, 3}; // Since MinCostFlow stores node excess as a FlowQuantity, one must take care // to check that the total flow in/out of a node is less than kint64max. To @@ -185,8 +189,8 @@ TYPED_TEST(GenericMinCostFlowTest, Test1) { const int kNumNodes = 2; const int kNumArcs = 1; const FlowQuantity kNodeSupply[kNumNodes] = {12, -12}; - const NodeIndex kTail[kNumArcs] = {0}; - const NodeIndex kHead[kNumArcs] = {1}; + const typename TypeParam::NodeIndex kTail[kNumArcs] = {0}; + const typename TypeParam::NodeIndex kHead[kNumArcs] = {1}; const CostValue kCost[kNumArcs] = {10}; const FlowQuantity kCapacity[kNumArcs] = {20}; const CostValue kExpectedFlowCost = 120; @@ -200,8 +204,10 @@ TYPED_TEST(GenericMinCostFlowTest, Test2) { const int kNumNodes = 7; const int kNumArcs = 12; const FlowQuantity kNodeSupply[kNumNodes] = {20, 10, 25, -11, -13, -17, -14}; - const NodeIndex kTail[kNumArcs] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2}; - const NodeIndex kHead[kNumArcs] = {3, 4, 5, 6, 3, 4, 5, 6, 3, 4, 5, 6}; + const typename TypeParam::NodeIndex kTail[kNumArcs] = {0, 0, 0, 0, 1, 1, + 1, 1, 2, 2, 2, 2}; + const typename TypeParam::NodeIndex kHead[kNumArcs] = {3, 4, 5, 6, 3, 4, + 5, 6, 3, 4, 5, 6}; const CostValue kCost[kNumArcs] = {1, 6, 3, 5, 7, 3, 1, 6, 9, 4, 5, 3}; const FlowQuantity kCapacity[kNumArcs] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}; @@ -217,8 +223,10 @@ TYPED_TEST(GenericMinCostFlowTest, Test3) { const int kNumNodes = 7; const int kNumArcs = 12; const FlowQuantity kNodeSupply[kNumNodes] = {20, 10, 25, -11, -13, -17, -14}; - const NodeIndex kTail[kNumArcs] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2}; - const NodeIndex kHead[kNumArcs] = {3, 4, 5, 6, 3, 4, 5, 6, 3, 4, 5, 6}; + const typename TypeParam::NodeIndex kTail[kNumArcs] = {0, 0, 0, 0, 1, 1, + 1, 1, 2, 2, 2, 2}; + const typename TypeParam::NodeIndex kHead[kNumArcs] = {3, 4, 5, 6, 3, 4, + 5, 6, 3, 4, 5, 6}; const CostValue kCost[kNumArcs] = {0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0}; const FlowQuantity kCapacity[kNumArcs] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}; @@ -241,28 +249,34 @@ TYPED_TEST(GenericMinCostFlowTest, Small4x4Matrix) { {45, 110, 95, 115}}; const CostValue kExpectedCost = 275; TypeParam graph(kNumSources + kNumTargets, kNumSources * kNumTargets); - for (NodeIndex source = 0; source < kNumSources; ++source) { - for (NodeIndex target = 0; target < kNumTargets; ++target) { + for (typename TypeParam::NodeIndex source = 0; source < kNumSources; + ++source) { + for (typename TypeParam::NodeIndex target = 0; target < kNumTargets; + ++target) { graph.AddArc(source, kNumSources + target); } } - std::vector permutation; + std::vector permutation; graph.Build(&permutation); EXPECT_TRUE(permutation.empty()); GenericMinCostFlow min_cost_flow(&graph); int arc = 0; - for (NodeIndex source = 0; source < kNumSources; ++source) { - for (NodeIndex target = 0; target < kNumTargets; ++target) { + for (typename TypeParam::NodeIndex source = 0; source < kNumSources; + ++source) { + for (typename TypeParam::NodeIndex target = 0; target < kNumTargets; + ++target) { min_cost_flow.SetArcUnitCost(arc, kCost[source][target]); min_cost_flow.SetArcCapacity(arc, 1); ++arc; } } - for (NodeIndex source = 0; source < kNumSources; ++source) { + for (typename TypeParam::NodeIndex source = 0; source < kNumSources; + ++source) { min_cost_flow.SetNodeSupply(source, 1); } - for (NodeIndex target = 0; target < kNumTargets; ++target) { + for (typename TypeParam::NodeIndex target = 0; target < kNumTargets; + ++target) { min_cost_flow.SetNodeSupply(kNumSources + target, -1); } EXPECT_TRUE(min_cost_flow.Solve()); @@ -277,8 +291,8 @@ TYPED_TEST(GenericMinCostFlowTest, TotalFlowCostOverflow) { const int kNumNodes = 2; const int kNumArcs = 1; const FlowQuantity kNodeSupply[kNumNodes] = {1LL << 61, -(1LL << 61)}; - const NodeIndex kTail[kNumArcs] = {0}; - const NodeIndex kHead[kNumArcs] = {1}; + const typename TypeParam::NodeIndex kTail[kNumArcs] = {0}; + const typename TypeParam::NodeIndex kHead[kNumArcs] = {1}; const CostValue kCost[kNumArcs] = {10}; const FlowQuantity kCapacity[kNumArcs] = {1LL << 61}; const CostValue kExpectedFlowCost = std::numeric_limits::max(); @@ -400,8 +414,10 @@ TEST(SimpleMinCostFlowTest, FeasibleProblem) { const int kNumNodes = 7; const int kNumArcs = 12; const FlowQuantity kNodeSupply[kNumNodes] = {20, 10, 25, -11, -13, -17, -14}; - const NodeIndex kTail[kNumArcs] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2}; - const NodeIndex kHead[kNumArcs] = {3, 4, 5, 6, 3, 4, 5, 6, 3, 4, 5, 6}; + const SimpleMinCostFlow::NodeIndex kTail[kNumArcs] = {0, 0, 0, 0, 1, 1, + 1, 1, 2, 2, 2, 2}; + const SimpleMinCostFlow::NodeIndex kHead[kNumArcs] = {3, 4, 5, 6, 3, 4, + 5, 6, 3, 4, 5, 6}; const CostValue kCost[kNumArcs] = {0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0}; const FlowQuantity kCapacity[kNumArcs] = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}; @@ -411,10 +427,10 @@ TEST(SimpleMinCostFlowTest, FeasibleProblem) { 10, 0, 4, 0, 7, 14}; SimpleMinCostFlow min_cost_flow; - for (NodeIndex node = 0; node < kNumNodes; ++node) { + for (SimpleMinCostFlow::NodeIndex node = 0; node < kNumNodes; ++node) { min_cost_flow.SetNodeSupply(node, kNodeSupply[node]); } - for (ArcIndex arc = 0; arc < kNumArcs; ++arc) { + for (SimpleMinCostFlow::ArcIndex arc = 0; arc < kNumArcs; ++arc) { EXPECT_EQ(arc, min_cost_flow.AddArcWithCapacityAndUnitCost( kTail[arc], kHead[arc], kCapacity[arc], kCost[arc])); } @@ -422,7 +438,7 @@ TEST(SimpleMinCostFlowTest, FeasibleProblem) { EXPECT_EQ(SimpleMinCostFlow::OPTIMAL, status); EXPECT_EQ(kExpectedFlowCost, min_cost_flow.OptimalCost()); EXPECT_EQ(kExpectedFlowVolume, min_cost_flow.MaximumFlow()); - for (ArcIndex arc = 0; arc < kNumArcs; ++arc) { + for (SimpleMinCostFlow::ArcIndex arc = 0; arc < kNumArcs; ++arc) { EXPECT_EQ(kExpectedFlow[arc], min_cost_flow.Flow(arc)) << " for Arc #" << arc << ": " << kTail[arc] << "->" << kHead[arc]; } @@ -432,15 +448,17 @@ TEST(SimpleMinCostFlowTest, InfeasibleProblem) { const int kNumNodes = 7; const int kNumArcs = 12; const FlowQuantity kNodeSupply[kNumNodes] = {20, 10, 25, -11, -13, -17, -14}; - const NodeIndex kTail[kNumArcs] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2}; - const NodeIndex kHead[kNumArcs] = {3, 4, 5, 6, 3, 4, 5, 6, 3, 4, 5, 6}; + const SimpleMinCostFlow::NodeIndex kTail[kNumArcs] = {0, 0, 0, 0, 1, 1, + 1, 1, 2, 2, 2, 2}; + const SimpleMinCostFlow::NodeIndex kHead[kNumArcs] = {3, 4, 5, 6, 3, 4, + 5, 6, 3, 4, 5, 6}; const CostValue kCost[kNumArcs] = {0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0}; SimpleMinCostFlow min_cost_flow; - for (NodeIndex node = 0; node < kNumNodes; ++node) { + for (SimpleMinCostFlow::NodeIndex node = 0; node < kNumNodes; ++node) { min_cost_flow.SetNodeSupply(node, kNodeSupply[node]); } - for (ArcIndex arc = 0; arc < kNumArcs; ++arc) { + for (SimpleMinCostFlow::ArcIndex arc = 0; arc < kNumArcs; ++arc) { min_cost_flow.AddArcWithCapacityAndUnitCost(kTail[arc], kHead[arc], 1.0, kCost[arc]); } @@ -450,7 +468,7 @@ TEST(SimpleMinCostFlowTest, InfeasibleProblem) { // There should be unit flow through all the arcs we added. EXPECT_EQ(6, min_cost_flow.OptimalCost()); EXPECT_EQ(12, min_cost_flow.MaximumFlow()); - for (ArcIndex arc = 0; arc < kNumArcs; ++arc) { + for (SimpleMinCostFlow::ArcIndex arc = 0; arc < kNumArcs; ++arc) { EXPECT_EQ(1, min_cost_flow.Flow(arc)) << " for Arc #" << arc << ": " << kTail[arc] << "->" << kHead[arc]; } @@ -484,45 +502,50 @@ TEST(SimpleMinCostFlowTest, OverflowCostBound) { } template -void GenerateCompleteGraph(const NodeIndex num_sources, - const NodeIndex num_targets, Graph* graph) { - const NodeIndex num_nodes = num_sources + num_targets; - const ArcIndex num_arcs = num_sources * num_targets; +void GenerateCompleteGraph(const typename Graph::NodeIndex num_sources, + const typename Graph::NodeIndex num_targets, + Graph* graph) { + const typename Graph::NodeIndex num_nodes = num_sources + num_targets; + const typename Graph::ArcIndex num_arcs = num_sources * num_targets; graph->Reserve(num_nodes, num_arcs); - for (NodeIndex source = 0; source < num_sources; ++source) { - for (NodeIndex target = 0; target < num_targets; ++target) { + for (typename Graph::NodeIndex source = 0; source < num_sources; ++source) { + for (typename Graph::NodeIndex target = 0; target < num_targets; ++target) { graph->AddArc(source, target + num_sources); } } } template -void GeneratePartialRandomGraph(const NodeIndex num_sources, - const NodeIndex num_targets, - const NodeIndex degree, Graph* graph) { - const NodeIndex num_nodes = num_sources + num_targets; - const ArcIndex num_arcs = num_sources * degree; +void GeneratePartialRandomGraph(const typename Graph::NodeIndex num_sources, + const typename Graph::NodeIndex num_targets, + const typename Graph::NodeIndex degree, + Graph* graph) { + const typename Graph::NodeIndex num_nodes = num_sources + num_targets; + const typename Graph::ArcIndex num_arcs = num_sources * degree; graph->Reserve(num_nodes, num_arcs); std::mt19937 randomizer(12345); - for (NodeIndex source = 0; source < num_sources; ++source) { + for (typename Graph::NodeIndex source = 0; source < num_sources; ++source) { // For each source, we create degree - 1 random arcs. - for (NodeIndex d = 0; d < degree - 1; ++d) { - NodeIndex target = absl::Uniform(randomizer, 0, num_targets); + for (typename Graph::NodeIndex d = 0; d < degree - 1; ++d) { + typename Graph::NodeIndex target = + absl::Uniform(randomizer, 0, num_targets); graph->AddArc(source, target + num_sources); } } // Make sure that each target has at least one corresponding source. - for (NodeIndex target = 0; target < num_targets; ++target) { - NodeIndex source = absl::Uniform(randomizer, 0, num_sources); + for (typename Graph::NodeIndex target = 0; target < num_targets; ++target) { + typename Graph::NodeIndex source = + absl::Uniform(randomizer, 0, num_sources); graph->AddArc(source, target + num_sources); } } -void GenerateRandomSupply(const NodeIndex num_sources, - const NodeIndex num_targets, - const NodeIndex num_generations, const int64_t range, - std::vector* supply) { - const NodeIndex num_nodes = num_sources + num_targets; +template +void GenerateRandomSupply(const typename Graph::NodeIndex num_sources, + const typename Graph::NodeIndex num_targets, + const typename Graph::NodeIndex num_generations, + const int64_t range, std::vector* supply) { + const typename Graph::NodeIndex num_nodes = num_sources + num_targets; supply->resize(num_nodes, 0); std::mt19937 randomizer(12345); for (int64_t i = 0; i < num_sources * num_generations; ++i) { @@ -534,8 +557,9 @@ void GenerateRandomSupply(const NodeIndex num_sources, } } -void GenerateAssignmentSupply(const NodeIndex num_sources, - const NodeIndex num_targets, +template +void GenerateAssignmentSupply(const typename Graph::NodeIndex num_sources, + const typename Graph::NodeIndex num_targets, std::vector* supply) { supply->resize(num_sources + num_targets); for (int i = 0; i < num_sources; ++i) { @@ -546,27 +570,29 @@ void GenerateAssignmentSupply(const NodeIndex num_sources, } } -void GenerateRandomArcValuations(const ArcIndex num_arcs, +template +void GenerateRandomArcValuations(const typename Graph::ArcIndex num_arcs, const int64_t max_range, std::vector* arc_valuation) { arc_valuation->resize(num_arcs); std::mt19937 randomizer(12345); - for (ArcIndex arc = 0; arc < num_arcs; ++arc) { + for (typename Graph::ArcIndex arc = 0; arc < num_arcs; ++arc) { (*arc_valuation)[arc] = absl::Uniform(randomizer, 0, max_range); } } template -void SetUpNetworkData(absl::Span permutation, +void SetUpNetworkData(absl::Span permutation, absl::Span supply, absl::Span arc_cost, absl::Span arc_capacity, Graph* graph, GenericMinCostFlow* min_cost_flow) { - for (NodeIndex node = 0; node < graph->num_nodes(); ++node) { + for (typename Graph::NodeIndex node = 0; node < graph->num_nodes(); ++node) { min_cost_flow->SetNodeSupply(node, supply[node]); } - for (ArcIndex arc = 0; arc < graph->num_arcs(); ++arc) { - ArcIndex permuted_arc = arc < permutation.size() ? permutation[arc] : arc; + for (typename Graph::ArcIndex arc = 0; arc < graph->num_arcs(); ++arc) { + typename Graph::ArcIndex permuted_arc = + arc < permutation.size() ? permutation[arc] : arc; min_cost_flow->SetArcUnitCost(permuted_arc, arc_cost[arc]); min_cost_flow->SetArcCapacity(permuted_arc, arc_capacity[arc]); } @@ -578,7 +604,8 @@ CostValue SolveMinCostFlow(GenericMinCostFlow* min_cost_flow) { if (ok && min_cost_flow->status() == GenericMinCostFlow::OPTIMAL) { CostValue cost = min_cost_flow->GetOptimalCost(); CostValue computed_cost = 0; - for (ArcIndex arc = 0; arc < min_cost_flow->graph()->num_arcs(); ++arc) { + for (typename Graph::ArcIndex arc = 0; + arc < min_cost_flow->graph()->num_arcs(); ++arc) { const FlowQuantity flow = min_cost_flow->Flow(arc); EXPECT_GE(min_cost_flow->Capacity(arc), flow); computed_cost += min_cost_flow->UnitCost(arc) * flow; @@ -594,17 +621,17 @@ template CostValue SolveMinCostFlowWithLP(GenericMinCostFlow* min_cost_flow) { MPSolver solver("LPSolver", MPSolver::GLOP_LINEAR_PROGRAMMING); const Graph* graph = min_cost_flow->graph(); - const NodeIndex num_nodes = graph->num_nodes(); - const ArcIndex num_arcs = graph->num_arcs(); + const typename Graph::NodeIndex num_nodes = graph->num_nodes(); + const typename Graph::ArcIndex num_arcs = graph->num_arcs(); std::unique_ptr constraint(new MPConstraint*[num_nodes]); - for (NodeIndex node = 0; node < graph->num_nodes(); ++node) { + for (typename Graph::NodeIndex node = 0; node < graph->num_nodes(); ++node) { constraint[node] = solver.MakeRowConstraint(); FlowQuantity supply = min_cost_flow->Supply(node); constraint[node]->SetBounds(supply, supply); } std::unique_ptr var(new MPVariable*[num_arcs]); MPObjective* const objective = solver.MutableObjective(); - for (ArcIndex arc = 0; arc < graph->num_arcs(); ++arc) { + for (typename Graph::ArcIndex arc = 0; arc < graph->num_arcs(); ++arc) { var[arc] = solver.MakeNumVar(0.0, min_cost_flow->Capacity(arc), absl::StrFormat("v%d", arc)); constraint[graph->Tail(arc)]->SetCoefficient(var[arc], 1.0); @@ -618,7 +645,7 @@ CostValue SolveMinCostFlowWithLP(GenericMinCostFlow* min_cost_flow) { template bool CheckAssignmentFeasibility(const Graph& graph, absl::Span supply) { - for (NodeIndex node = 0; node < graph.num_nodes(); ++node) { + for (typename Graph::NodeIndex node = 0; node < graph.num_nodes(); ++node) { if (supply[node] != 0) { typename Graph::OutgoingOrOppositeIncomingArcIterator it(graph, node); EXPECT_TRUE(it.Ok()) << node << " has no incident arc"; @@ -634,7 +661,8 @@ struct MinCostFlowSolver { template void FullRandomAssignment(typename MinCostFlowSolver::Solver f, - NodeIndex num_sources, NodeIndex num_targets, + typename Graph::NodeIndex num_sources, + typename Graph::NodeIndex num_targets, CostValue expected_cost1, CostValue /*expected_cost2*/) { const CostValue kCostRange = 1000; @@ -644,11 +672,11 @@ void FullRandomAssignment(typename MinCostFlowSolver::Solver f, graph.Build(&permutation); std::vector supply; - GenerateAssignmentSupply(num_sources, num_targets, &supply); + GenerateAssignmentSupply(num_sources, num_targets, &supply); EXPECT_TRUE(CheckAssignmentFeasibility(graph, supply)); std::vector arc_capacity(graph.num_arcs(), 1); std::vector arc_cost(graph.num_arcs()); - GenerateRandomArcValuations(graph.num_arcs(), kCostRange, &arc_cost); + GenerateRandomArcValuations(graph.num_arcs(), kCostRange, &arc_cost); GenericMinCostFlow min_cost_flow(&graph); SetUpNetworkData(permutation, supply, arc_cost, arc_capacity, &graph, &min_cost_flow); @@ -659,10 +687,11 @@ void FullRandomAssignment(typename MinCostFlowSolver::Solver f, template void PartialRandomAssignment(typename MinCostFlowSolver::Solver f, - NodeIndex num_sources, NodeIndex num_targets, + typename Graph::NodeIndex num_sources, + typename Graph::NodeIndex num_targets, CostValue expected_cost1, CostValue /*expected_cost2*/) { - const NodeIndex kDegree = 10; + const typename Graph::NodeIndex kDegree = 10; const CostValue kCostRange = 1000; Graph graph; GeneratePartialRandomGraph(num_sources, num_targets, kDegree, &graph); @@ -670,13 +699,13 @@ void PartialRandomAssignment(typename MinCostFlowSolver::Solver f, graph.Build(&permutation); std::vector supply; - GenerateAssignmentSupply(num_sources, num_targets, &supply); + GenerateAssignmentSupply(num_sources, num_targets, &supply); EXPECT_TRUE(CheckAssignmentFeasibility(graph, supply)); EXPECT_EQ(graph.num_arcs(), num_sources * kDegree); std::vector arc_capacity(graph.num_arcs(), 1); std::vector arc_cost(graph.num_arcs()); - GenerateRandomArcValuations(graph.num_arcs(), kCostRange, &arc_cost); + GenerateRandomArcValuations(graph.num_arcs(), kCostRange, &arc_cost); GenericMinCostFlow min_cost_flow(&graph); SetUpNetworkData(permutation, supply, arc_cost, arc_capacity, &graph, &min_cost_flow); @@ -685,15 +714,16 @@ void PartialRandomAssignment(typename MinCostFlowSolver::Solver f, } template -void ChangeCapacities(absl::Span permutation, +void ChangeCapacities(absl::Span permutation, absl::Span arc_capacity, FlowQuantity delta, GenericMinCostFlow* min_cost_flow, float probability) { std::mt19937 randomizer(12345); - const ArcIndex num_arcs = min_cost_flow->graph()->num_arcs(); - for (ArcIndex arc = 0; arc < num_arcs; ++arc) { - ArcIndex permuted_arc = arc < permutation.size() ? permutation[arc] : arc; + const typename Graph::ArcIndex num_arcs = min_cost_flow->graph()->num_arcs(); + for (typename Graph::ArcIndex arc = 0; arc < num_arcs; ++arc) { + typename Graph::ArcIndex permuted_arc = + arc < permutation.size() ? permutation[arc] : arc; if (absl::Bernoulli(randomizer, probability)) { min_cost_flow->SetArcCapacity( permuted_arc, std::max(arc_capacity[arc] - delta, int64_t{0})); @@ -705,9 +735,10 @@ void ChangeCapacities(absl::Span permutation, template void PartialRandomFlow(typename MinCostFlowSolver::Solver f, - NodeIndex num_sources, NodeIndex num_targets, + typename Graph::NodeIndex num_sources, + typename Graph::NodeIndex num_targets, CostValue expected_cost1, CostValue expected_cost2) { - const NodeIndex kDegree = 15; + const typename Graph::NodeIndex kDegree = 15; const FlowQuantity kSupplyRange = 500; const int64_t kSupplyGens = 15; const FlowQuantity kCapacityRange = 10000; @@ -720,13 +751,14 @@ void PartialRandomFlow(typename MinCostFlowSolver::Solver f, graph.Build(&permutation); std::vector supply; - GenerateRandomSupply(num_sources, num_targets, kSupplyGens, kSupplyRange, - &supply); + GenerateRandomSupply(num_sources, num_targets, kSupplyGens, + kSupplyRange, &supply); EXPECT_TRUE(CheckAssignmentFeasibility(graph, supply)); std::vector arc_capacity(graph.num_arcs()); - GenerateRandomArcValuations(graph.num_arcs(), kCapacityRange, &arc_capacity); + GenerateRandomArcValuations(graph.num_arcs(), kCapacityRange, + &arc_capacity); std::vector arc_cost(graph.num_arcs()); - GenerateRandomArcValuations(graph.num_arcs(), kCostRange, &arc_cost); + GenerateRandomArcValuations(graph.num_arcs(), kCostRange, &arc_cost); GenericMinCostFlow min_cost_flow(&graph); SetUpNetworkData(permutation, supply, arc_cost, arc_capacity, &graph, &min_cost_flow); @@ -744,7 +776,8 @@ void PartialRandomFlow(typename MinCostFlowSolver::Solver f, template void FullRandomFlow(typename MinCostFlowSolver::Solver f, - NodeIndex num_sources, NodeIndex num_targets, + typename Graph::NodeIndex num_sources, + typename Graph::NodeIndex num_targets, CostValue expected_cost1, CostValue expected_cost2) { const FlowQuantity kSupplyRange = 1000; const int64_t kSupplyGens = 10; @@ -758,13 +791,14 @@ void FullRandomFlow(typename MinCostFlowSolver::Solver f, graph.Build(&permutation); std::vector supply; - GenerateRandomSupply(num_sources, num_targets, kSupplyGens, kSupplyRange, - &supply); + GenerateRandomSupply(num_sources, num_targets, kSupplyGens, + kSupplyRange, &supply); EXPECT_TRUE(CheckAssignmentFeasibility(graph, supply)); std::vector arc_capacity(graph.num_arcs()); - GenerateRandomArcValuations(graph.num_arcs(), kCapacityRange, &arc_capacity); + GenerateRandomArcValuations(graph.num_arcs(), kCapacityRange, + &arc_capacity); std::vector arc_cost(graph.num_arcs()); - GenerateRandomArcValuations(graph.num_arcs(), kCostRange, &arc_cost); + GenerateRandomArcValuations(graph.num_arcs(), kCostRange, &arc_cost); GenericMinCostFlow min_cost_flow(&graph); SetUpNetworkData(permutation, supply, arc_cost, arc_capacity, &graph, diff --git a/ortools/graph/one_tree_lower_bound.h b/ortools/graph/one_tree_lower_bound.h index 225bece6f7..dd53cb0889 100644 --- a/ortools/graph/one_tree_lower_bound.h +++ b/ortools/graph/one_tree_lower_bound.h @@ -128,8 +128,8 @@ #include #include +#include "absl/log/log.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" #include "ortools/graph/christofides.h" #include "ortools/graph/graph.h" #include "ortools/graph/minimum_spanning_tree.h" diff --git a/ortools/graph/one_tree_lower_bound_test.cc b/ortools/graph/one_tree_lower_bound_test.cc index dccbdf827e..4a5e917450 100644 --- a/ortools/graph/one_tree_lower_bound_test.cc +++ b/ortools/graph/one_tree_lower_bound_test.cc @@ -19,9 +19,9 @@ #include #include +#include "absl/log/log.h" #include "absl/types/span.h" #include "gtest/gtest.h" -#include "ortools/base/logging.h" #include "ortools/base/path.h" #include "ortools/routing/parsers/tsplib_parser.h" diff --git a/ortools/graph/perfect_matching.cc b/ortools/graph/perfect_matching.cc index 033456c8aa..c04bcff785 100644 --- a/ortools/graph/perfect_matching.cc +++ b/ortools/graph/perfect_matching.cc @@ -24,9 +24,9 @@ #include "absl/base/log_severity.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include "ortools/base/logging.h" #include "ortools/util/saturated_arithmetic.h" namespace operations_research { diff --git a/ortools/graph/rooted_tree.h b/ortools/graph/rooted_tree.h index 7f701ebf16..a4c64af0cd 100644 --- a/ortools/graph/rooted_tree.h +++ b/ortools/graph/rooted_tree.h @@ -33,12 +33,12 @@ #include "absl/algorithm/container.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" #include "ortools/base/status_builder.h" #include "ortools/base/status_macros.h" diff --git a/ortools/graph/samples/assignment_linear_sum_assignment.cc b/ortools/graph/samples/assignment_linear_sum_assignment.cc index fd553eee82..882c97db65 100644 --- a/ortools/graph/samples/assignment_linear_sum_assignment.cc +++ b/ortools/graph/samples/assignment_linear_sum_assignment.cc @@ -20,7 +20,7 @@ #include #include -#include "ortools/base/logging.h" +#include "absl/log/log.h" // [END import] namespace operations_research { diff --git a/ortools/graph/shortest_paths_benchmarks.cc b/ortools/graph/shortest_paths_benchmarks.cc index e82b30908a..8c0d735e20 100644 --- a/ortools/graph/shortest_paths_benchmarks.cc +++ b/ortools/graph/shortest_paths_benchmarks.cc @@ -19,10 +19,10 @@ #include #include +#include "absl/log/log.h" #include "absl/random/distributions.h" #include "benchmark/benchmark.h" #include "isp/fiber/auto_design/utils/parallelizer.h" -#include "ortools/base/logging.h" #include "ortools/base/threadlocal.h" #include "ortools/graph/bounded_dijkstra.h" #include "ortools/graph/graph.h" diff --git a/ortools/graph/solve_flow_model.cc b/ortools/graph/solve_flow_model.cc index deed8253d4..31e98c162f 100644 --- a/ortools/graph/solve_flow_model.cc +++ b/ortools/graph/solve_flow_model.cc @@ -28,17 +28,17 @@ #include #include +#include "absl/base/log_severity.h" #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/globals.h" +#include "absl/log/log.h" #include "absl/strings/match.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" -#include "ortools/base/commandlineflags.h" -#include "ortools/base/file.h" #include "ortools/base/filesystem.h" #include "ortools/base/helpers.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/base/options.h" #include "ortools/base/path.h" #include "ortools/base/timer.h" @@ -303,7 +303,7 @@ int main(int argc, char** argv) { "The files must be in Dimacs text format or in binary FlowModelProto " "format.", &argc, &argv, true); - absl::SetFlag(&FLAGS_stderrthreshold, 0); + absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); if (absl::GetFlag(FLAGS_input).empty()) { LOG(FATAL) << "Please specify input pattern via --input=..."; } diff --git a/ortools/gscip/gscip_constraint_handler.cc b/ortools/gscip/gscip_constraint_handler.cc index 597db3837b..061255ce07 100644 --- a/ortools/gscip/gscip_constraint_handler.cc +++ b/ortools/gscip/gscip_constraint_handler.cc @@ -19,9 +19,9 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" #include "ortools/base/status_macros.h" #include "ortools/gscip/gscip.h" #include "ortools/gscip/gscip_callback_result.h" diff --git a/ortools/linear_solver/proto_solver/glop_proto_solver.cc b/ortools/linear_solver/proto_solver/glop_proto_solver.cc index 4b25f744bd..cf4b6eea2a 100644 --- a/ortools/linear_solver/proto_solver/glop_proto_solver.cc +++ b/ortools/linear_solver/proto_solver/glop_proto_solver.cc @@ -23,8 +23,8 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" -#include "ortools/base/logging.h" #include "ortools/glop/lp_solver.h" #include "ortools/glop/parameters_validation.h" #include "ortools/linear_solver/linear_solver.pb.h" diff --git a/ortools/linear_solver/proto_solver/gurobi_proto_solver.cc b/ortools/linear_solver/proto_solver/gurobi_proto_solver.cc index fbc8c4eb21..aba0d9ded5 100644 --- a/ortools/linear_solver/proto_solver/gurobi_proto_solver.cc +++ b/ortools/linear_solver/proto_solver/gurobi_proto_solver.cc @@ -26,6 +26,7 @@ #include "absl/base/attributes.h" #include "absl/cleanup/cleanup.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" @@ -36,7 +37,6 @@ #include "absl/time/clock.h" #include "absl/time/time.h" #include "absl/types/optional.h" -#include "ortools/base/logging.h" #include "ortools/base/status_macros.h" #include "ortools/base/timer.h" #include "ortools/gurobi/environment.h" diff --git a/ortools/linear_solver/proto_solver/proto_utils.h b/ortools/linear_solver/proto_solver/proto_utils.h index 981b5e1db6..fecaaf1dc6 100644 --- a/ortools/linear_solver/proto_solver/proto_utils.h +++ b/ortools/linear_solver/proto_solver/proto_utils.h @@ -19,9 +19,9 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/statusor.h" #include "google/protobuf/message.h" -#include "ortools/base/logging.h" #include "ortools/linear_solver/linear_solver.pb.h" #include "ortools/port/proto_utils.h" diff --git a/ortools/linear_solver/proto_solver/sat_proto_solver.cc b/ortools/linear_solver/proto_solver/sat_proto_solver.cc index 29558de0d5..8db86cd5dc 100644 --- a/ortools/linear_solver/proto_solver/sat_proto_solver.cc +++ b/ortools/linear_solver/proto_solver/sat_proto_solver.cc @@ -28,9 +28,9 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/types/span.h" -#include "ortools/base/logging.h" #include "ortools/glop/preprocessor.h" #include "ortools/linear_solver/linear_solver.pb.h" #include "ortools/linear_solver/model_validator.h" diff --git a/ortools/linear_solver/proto_solver/scip_proto_solver.cc b/ortools/linear_solver/proto_solver/scip_proto_solver.cc index 941ef8c0c4..c5c71fc0b6 100644 --- a/ortools/linear_solver/proto_solver/scip_proto_solver.cc +++ b/ortools/linear_solver/proto_solver/scip_proto_solver.cc @@ -17,28 +17,28 @@ #include #include +#include #include #include #include #include #include -#include #include #include +#include "absl/base/attributes.h" #include "absl/cleanup/cleanup.h" #include "absl/container/btree_set.h" +#include "absl/flags/flag.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" -#include "absl/strings/ascii.h" -#include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include "absl/strings/str_split.h" #include "absl/strings/string_view.h" +#include "absl/time/clock.h" #include "absl/time/time.h" -#include "ortools/base/commandlineflags.h" -#include "ortools/base/logging.h" #include "ortools/base/status_macros.h" #include "ortools/base/timer.h" #include "ortools/gscip/legacy_scip_params.h" @@ -46,20 +46,36 @@ #include "ortools/linear_solver/model_validator.h" #include "ortools/linear_solver/scip_helper_macros.h" #include "ortools/util/lazy_mutable_copy.h" +#include "scip/cons_and.h" #include "scip/cons_disjunction.h" +#include "scip/cons_indicator.h" #include "scip/cons_linear.h" +#include "scip/cons_or.h" #include "scip/cons_quadratic.h" +#include "scip/cons_sos1.h" +#include "scip/cons_sos2.h" +#include "scip/def.h" +#include "scip/pub_event.h" #include "scip/pub_var.h" -#include "scip/scip.h" +#include "scip/scip_cons.h" +#include "scip/scip_event.h" +#include "scip/scip_general.h" +#include "scip/scip_message.h" #include "scip/scip_numerics.h" #include "scip/scip_param.h" #include "scip/scip_prob.h" +#include "scip/scip_sol.h" +#include "scip/scip_solve.h" +#include "scip/scip_solvingstats.h" #include "scip/scip_var.h" #include "scip/scipdefplugins.h" -#include "scip/set.h" -#include "scip/struct_paramset.h" +#include "scip/type_clock.h" #include "scip/type_cons.h" -#include "scip/type_paramset.h" +#include "scip/type_prob.h" +#include "scip/type_retcode.h" +#include "scip/type_scip.h" +#include "scip/type_sol.h" +#include "scip/type_stat.h" #include "scip/type_var.h" ABSL_FLAG(std::string, scip_proto_solver_output_cip_file, "", diff --git a/ortools/linear_solver/samples/basic_example.cc b/ortools/linear_solver/samples/basic_example.cc index 038c7ffb94..0da0f8e9da 100644 --- a/ortools/linear_solver/samples/basic_example.cc +++ b/ortools/linear_solver/samples/basic_example.cc @@ -17,10 +17,10 @@ #include #include -#include "absl/flags/flag.h" -#include "absl/log/flags.h" +#include "absl/base/log_severity.h" +#include "absl/log/globals.h" +#include "absl/log/log.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/init/init.h" #include "ortools/linear_solver/linear_solver.h" // [END import] @@ -97,8 +97,8 @@ void BasicExample() { } // namespace operations_research int main(int argc, char* argv[]) { + absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); InitGoogle(argv[0], &argc, &argv, true); - absl::SetFlag(&FLAGS_stderrthreshold, 0); operations_research::BasicExample(); return EXIT_SUCCESS; } diff --git a/ortools/linear_solver/samples/network_design_ilph.cc b/ortools/linear_solver/samples/network_design_ilph.cc index 6042b13891..b61c9006b6 100644 --- a/ortools/linear_solver/samples/network_design_ilph.cc +++ b/ortools/linear_solver/samples/network_design_ilph.cc @@ -20,11 +20,11 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/time/time.h" -#include "ortools/base/logging.h" #include "ortools/graph/graph.h" #include "ortools/linear_solver/linear_solver.h" #include "ortools/linear_solver/linear_solver.pb.h" diff --git a/ortools/linear_solver/samples/network_design_ilph_main.cc b/ortools/linear_solver/samples/network_design_ilph_main.cc index fb85e13820..f4bdfe6dad 100644 --- a/ortools/linear_solver/samples/network_design_ilph_main.cc +++ b/ortools/linear_solver/samples/network_design_ilph_main.cc @@ -13,11 +13,11 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "ortools/base/commandlineflags.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/linear_solver/linear_solver.h" #include "ortools/linear_solver/samples/network_design_ilph.h" #include "ortools/routing/parsers/capacity_planning.pb.h" diff --git a/ortools/linear_solver/samples/stigler_diet.cc b/ortools/linear_solver/samples/stigler_diet.cc index 222ac8e30f..5b8477f959 100644 --- a/ortools/linear_solver/samples/stigler_diet.cc +++ b/ortools/linear_solver/samples/stigler_diet.cc @@ -16,15 +16,16 @@ // [START import] #include #include +#include #include #include #include // std::pair #include -#include "absl/flags/flag.h" -#include "absl/log/flags.h" +#include "absl/base/log_severity.h" +#include "absl/log/globals.h" +#include "absl/log/log.h" #include "ortools/base/init_google.h" -#include "ortools/base/logging.h" #include "ortools/linear_solver/linear_solver.h" // [END import] @@ -321,7 +322,7 @@ void StiglerDiet() { int main(int argc, char** argv) { InitGoogle(argv[0], &argc, &argv, true); - absl::SetFlag(&FLAGS_stderrthreshold, 0); + absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); operations_research::StiglerDiet(); return EXIT_SUCCESS; } diff --git a/ortools/lp_data/lp_parser.cc b/ortools/lp_data/lp_parser.cc index b0447adb3c..42db79de0f 100644 --- a/ortools/lp_data/lp_parser.cc +++ b/ortools/lp_data/lp_parser.cc @@ -21,6 +21,7 @@ #include "absl/base/attributes.h" #include "absl/container/flat_hash_set.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/match.h" @@ -28,7 +29,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" -#include "ortools/base/logging.h" #include "ortools/linear_solver/linear_solver.pb.h" #include "ortools/lp_data/lp_data.h" #include "ortools/lp_data/lp_types.h" diff --git a/ortools/lp_data/lp_types.cc b/ortools/lp_data/lp_types.cc index ecca90bdbe..d1fe0b039f 100644 --- a/ortools/lp_data/lp_types.cc +++ b/ortools/lp_data/lp_types.cc @@ -15,7 +15,7 @@ #include -#include "ortools/base/logging.h" +#include "absl/log/log.h" namespace operations_research { namespace glop { diff --git a/ortools/lp_data/model_reader.cc b/ortools/lp_data/model_reader.cc index eb8bc424e4..a64051d11a 100644 --- a/ortools/lp_data/model_reader.cc +++ b/ortools/lp_data/model_reader.cc @@ -15,7 +15,7 @@ #include -#include "ortools/base/logging.h" +#include "absl/log/log.h" #include "ortools/linear_solver/linear_solver.pb.h" #include "ortools/lp_data/lp_data.h" #include "ortools/lp_data/proto_utils.h" diff --git a/ortools/lp_data/mps_reader.cc b/ortools/lp_data/mps_reader.cc index 14cd154e4a..3c374f3b70 100644 --- a/ortools/lp_data/mps_reader.cc +++ b/ortools/lp_data/mps_reader.cc @@ -20,11 +20,11 @@ #include "absl/container/btree_set.h" #include "absl/container/flat_hash_map.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "ortools/base/logging.h" #include "ortools/base/protobuf_util.h" #include "ortools/base/status_macros.h" #include "ortools/linear_solver/linear_solver.pb.h" diff --git a/ortools/lp_data/mps_reader_template.h b/ortools/lp_data/mps_reader_template.h index 388d23a47d..a0cbe5a5f5 100644 --- a/ortools/lp_data/mps_reader_template.h +++ b/ortools/lp_data/mps_reader_template.h @@ -283,6 +283,7 @@ #include "absl/container/flat_hash_set.h" #include "absl/container/inlined_vector.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/ascii.h" @@ -291,7 +292,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" -#include "ortools/base/logging.h" #include "ortools/base/status_macros.h" #include "ortools/util/filelineiter.h" diff --git a/ortools/packing/vector_bin_packing_main.cc b/ortools/packing/vector_bin_packing_main.cc index 787f3810e1..e79b3aaf60 100644 --- a/ortools/packing/vector_bin_packing_main.cc +++ b/ortools/packing/vector_bin_packing_main.cc @@ -16,6 +16,8 @@ #include #include "absl/flags/flag.h" +#include "absl/log/globals.h" +#include "absl/log/log.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "ortools/base/helpers.h" @@ -94,7 +96,7 @@ void ParseAndSolve(const std::string& filename, absl::string_view solver, } // namespace operations_research int main(int argc, char** argv) { - absl::SetFlag(&FLAGS_stderrthreshold, 0); + absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); InitGoogle(argv[0], &argc, &argv, true); if (absl::GetFlag(FLAGS_input).empty()) { LOG(FATAL) << "Please supply a data file with --input="; diff --git a/ortools/pdlp/primal_dual_hybrid_gradient.cc b/ortools/pdlp/primal_dual_hybrid_gradient.cc index a027b46936..2aaf59241e 100644 --- a/ortools/pdlp/primal_dual_hybrid_gradient.cc +++ b/ortools/pdlp/primal_dual_hybrid_gradient.cc @@ -29,6 +29,7 @@ #include "Eigen/SparseCore" #include "absl/algorithm/container.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" @@ -37,7 +38,6 @@ #include "absl/time/clock.h" #include "absl/time/time.h" #include "google/protobuf/repeated_ptr_field.h" -#include "ortools/base/logging.h" #include "ortools/base/mathutil.h" #include "ortools/base/timer.h" #include "ortools/glop/parameters.pb.h" diff --git a/ortools/pdlp/primal_dual_hybrid_gradient_test.cc b/ortools/pdlp/primal_dual_hybrid_gradient_test.cc index df209f6b9c..122ab5fd25 100644 --- a/ortools/pdlp/primal_dual_hybrid_gradient_test.cc +++ b/ortools/pdlp/primal_dual_hybrid_gradient_test.cc @@ -29,12 +29,12 @@ #include "Eigen/SparseCore" #include "absl/container/flat_hash_map.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "gtest/gtest.h" #include "ortools/base/gmock.h" -#include "ortools/base/logging.h" #include "ortools/glop/parameters.pb.h" #include "ortools/linear_solver/linear_solver.pb.h" #include "ortools/lp_data/lp_data.h" diff --git a/ortools/pdlp/quadratic_program_io.cc b/ortools/pdlp/quadratic_program_io.cc index dcb77738f5..27dbdb9a3f 100644 --- a/ortools/pdlp/quadratic_program_io.cc +++ b/ortools/pdlp/quadratic_program_io.cc @@ -26,6 +26,7 @@ #include "absl/base/casts.h" #include "absl/container/flat_hash_map.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/match.h" @@ -33,7 +34,6 @@ #include "absl/strings/string_view.h" #include "ortools/base/file.h" #include "ortools/base/helpers.h" -#include "ortools/base/logging.h" #include "ortools/base/mathutil.h" #include "ortools/base/options.h" #include "ortools/base/status_builder.h" diff --git a/ortools/pdlp/scheduler.h b/ortools/pdlp/scheduler.h index cc9b5d062e..dd86dd7d2d 100644 --- a/ortools/pdlp/scheduler.h +++ b/ortools/pdlp/scheduler.h @@ -23,6 +23,7 @@ #include #include "absl/functional/any_invocable.h" +#include "absl/log/log.h" #include "absl/synchronization/blocking_counter.h" #include "ortools/base/threadpool.h" #include "ortools/pdlp/solvers.pb.h" diff --git a/ortools/pdlp/sharded_optimization_utils.cc b/ortools/pdlp/sharded_optimization_utils.cc index ceb6040e31..8d8822c3ad 100644 --- a/ortools/pdlp/sharded_optimization_utils.cc +++ b/ortools/pdlp/sharded_optimization_utils.cc @@ -25,8 +25,8 @@ #include "Eigen/Core" #include "Eigen/SparseCore" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/random/distributions.h" -#include "ortools/base/logging.h" #include "ortools/base/mathutil.h" #include "ortools/pdlp/quadratic_program.h" #include "ortools/pdlp/sharded_quadratic_program.h" diff --git a/ortools/pdlp/sharded_quadratic_program.cc b/ortools/pdlp/sharded_quadratic_program.cc index edfe8979b5..f6c708cc47 100644 --- a/ortools/pdlp/sharded_quadratic_program.cc +++ b/ortools/pdlp/sharded_quadratic_program.cc @@ -22,8 +22,8 @@ #include "Eigen/Core" #include "Eigen/SparseCore" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/string_view.h" -#include "ortools/base/logging.h" #include "ortools/pdlp/quadratic_program.h" #include "ortools/pdlp/scheduler.h" #include "ortools/pdlp/sharder.h" diff --git a/ortools/pdlp/sharder.cc b/ortools/pdlp/sharder.cc index fe196b3c09..59c472eea5 100644 --- a/ortools/pdlp/sharder.cc +++ b/ortools/pdlp/sharder.cc @@ -22,9 +22,9 @@ #include "Eigen/Core" #include "Eigen/SparseCore" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/synchronization/blocking_counter.h" #include "absl/time/time.h" -#include "ortools/base/logging.h" #include "ortools/base/mathutil.h" #include "ortools/base/timer.h" #include "ortools/pdlp/scheduler.h" diff --git a/ortools/pdlp/sharder_test.cc b/ortools/pdlp/sharder_test.cc index 1cb2c0b4d6..2db1f34cfa 100644 --- a/ortools/pdlp/sharder_test.cc +++ b/ortools/pdlp/sharder_test.cc @@ -22,10 +22,10 @@ #include "Eigen/Core" #include "Eigen/SparseCore" +#include "absl/log/log.h" #include "absl/random/distributions.h" #include "gtest/gtest.h" #include "ortools/base/gmock.h" -#include "ortools/base/logging.h" #include "ortools/base/mathutil.h" #include "ortools/pdlp/scheduler.h" diff --git a/ortools/pdlp/termination.cc b/ortools/pdlp/termination.cc index 8140a7eb7c..90bcd405db 100644 --- a/ortools/pdlp/termination.cc +++ b/ortools/pdlp/termination.cc @@ -17,7 +17,7 @@ #include #include -#include "ortools/base/logging.h" +#include "absl/log/log.h" #include "ortools/pdlp/solve_log.pb.h" #include "ortools/pdlp/solvers.pb.h" diff --git a/ortools/pdlp/trust_region.cc b/ortools/pdlp/trust_region.cc index c17d4cd07c..698bc462b3 100644 --- a/ortools/pdlp/trust_region.cc +++ b/ortools/pdlp/trust_region.cc @@ -23,7 +23,7 @@ #include "Eigen/Core" #include "absl/log/check.h" -#include "ortools/base/logging.h" +#include "absl/log/log.h" #include "ortools/base/mathutil.h" #include "ortools/pdlp/quadratic_program.h" #include "ortools/pdlp/sharded_optimization_utils.h" diff --git a/ortools/util/bitset.h b/ortools/util/bitset.h index 9e2e47b00f..9469bb8342 100644 --- a/ortools/util/bitset.h +++ b/ortools/util/bitset.h @@ -27,7 +27,6 @@ #include #include "absl/log/check.h" -#include "ortools/base/logging.h" namespace operations_research { @@ -911,9 +910,9 @@ class SparseBitset { // This is useful to iterate on the "set" positions while clearing them for // instance. This way, after the loop, a client can call this for efficiency. void NotifyAllClear() { - if (DEBUG_MODE) { +#if !defined(NDEBUG) for (IntegerType index : to_clear_) CHECK(!bitset_[index]); - } +#endif to_clear_.clear(); } diff --git a/ortools/util/file_util.cc b/ortools/util/file_util.cc index 31c8c9a083..6ee86f6e52 100644 --- a/ortools/util/file_util.cc +++ b/ortools/util/file_util.cc @@ -17,6 +17,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_format.h"