diff --git a/examples/cpp/binpacking_2d_sat.cc b/examples/cpp/binpacking_2d_sat.cc index 0614b7f501..920168e829 100644 --- a/examples/cpp/binpacking_2d_sat.cc +++ b/examples/cpp/binpacking_2d_sat.cc @@ -23,10 +23,9 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "google/protobuf/text_format.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/packing/binpacking_2d_parser.h" #include "ortools/packing/multiple_dimensions_bin_packing.pb.h" @@ -38,8 +37,7 @@ ABSL_FLAG(std::string, params, "", "Sat parameters in text proto format."); ABSL_FLAG(int, max_bins, 0, "Maximum number of bins. The 0 default value implies the code will " "use some heuristics to compute this number."); -ABSL_FLAG(bool, symmetry_breaking, true, - "Use the advanced symmetry breaking constraints"); +ABSL_FLAG(bool, symmetry_breaking, true, "Use symmetry breaking constraints"); ABSL_FLAG(bool, global_area_constraint, false, "Redundant constraint to link the global area covered"); ABSL_FLAG(bool, alternate_model, true, @@ -222,8 +220,7 @@ void LoadAndSolve(const std::string& file_name, int instance) { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); if (absl::GetFlag(FLAGS_input).empty()) { LOG(FATAL) << "Please supply a data file with --input="; } diff --git a/examples/cpp/costas_array_sat.cc b/examples/cpp/costas_array_sat.cc index 9523dbabd3..aaa8f7fe9d 100644 --- a/examples/cpp/costas_array_sat.cc +++ b/examples/cpp/costas_array_sat.cc @@ -28,10 +28,9 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/sat/cp_model.h" @@ -297,8 +296,7 @@ void CostasBoolSoft(const int dim) { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); int min = 1; int max = 10; diff --git a/examples/cpp/cryptarithm_sat.cc b/examples/cpp/cryptarithm_sat.cc index e3e9c83d16..7dbac50d0c 100644 --- a/examples/cpp/cryptarithm_sat.cc +++ b/examples/cpp/cryptarithm_sat.cc @@ -50,7 +50,7 @@ void SendMoreMoney() { cp_model.AddEquality(c0, m); // Column 1: - cp_model.AddEquality(c1 + s + m + o, 10 * c0); + cp_model.AddEquality(c1 + s + m, o + 10 * c0); // Column 2: cp_model.AddEquality(c2 + e + o, n + 10 * c1); diff --git a/examples/cpp/cvrp_disjoint_tw.cc b/examples/cpp/cvrp_disjoint_tw.cc index b648a99c88..bacf402c31 100644 --- a/examples/cpp/cvrp_disjoint_tw.cc +++ b/examples/cpp/cvrp_disjoint_tw.cc @@ -25,12 +25,11 @@ #include #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/random/random.h" #include "examples/cpp/cvrptw_lib.h" #include "google/protobuf/text_format.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/constraint_solver/routing.h" @@ -51,9 +50,8 @@ using operations_research::RoutingSearchParameters; using operations_research::ServiceTimePlusTransition; using operations_research::Solver; -ABSL_FLAG(int, vrp_orders, 100, "Nodes in the problem."); -ABSL_FLAG(int, vrp_vehicles, 20, - "Size of Traveling Salesman Problem instance."); +ABSL_FLAG(int, vrp_orders, 100, "Number of nodes in the problem."); +ABSL_FLAG(int, vrp_vehicles, 20, "Number of vehicles in the problem."); ABSL_FLAG(int, vrp_windows, 5, "Number of disjoint windows per node."); ABSL_FLAG(bool, vrp_use_deterministic_random_seed, false, "Use deterministic random seeds."); @@ -69,8 +67,7 @@ const int64_t kMaxNodesPerGroup = 10; const int64_t kSameVehicleCost = 1000; int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); CHECK_LT(0, absl::GetFlag(FLAGS_vrp_orders)) << "Specify an instance size greater than 0."; CHECK_LT(0, absl::GetFlag(FLAGS_vrp_vehicles)) diff --git a/examples/cpp/cvrptw.cc b/examples/cpp/cvrptw.cc index 27820dc122..89f578b871 100644 --- a/examples/cpp/cvrptw.cc +++ b/examples/cpp/cvrptw.cc @@ -24,12 +24,11 @@ #include #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/random/random.h" #include "examples/cpp/cvrptw_lib.h" #include "google/protobuf/text_format.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/constraint_solver/routing.h" @@ -65,8 +64,7 @@ const int64_t kMaxNodesPerGroup = 10; const int64_t kSameVehicleCost = 1000; int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); CHECK_LT(0, absl::GetFlag(FLAGS_vrp_orders)) << "Specify an instance size greater than 0."; CHECK_LT(0, absl::GetFlag(FLAGS_vrp_vehicles)) diff --git a/examples/cpp/cvrptw_with_breaks.cc b/examples/cpp/cvrptw_with_breaks.cc index a0e9c960a7..be4d9a7632 100644 --- a/examples/cpp/cvrptw_with_breaks.cc +++ b/examples/cpp/cvrptw_with_breaks.cc @@ -28,13 +28,12 @@ #include #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/random/random.h" #include "absl/strings/str_cat.h" #include "examples/cpp/cvrptw_lib.h" #include "google/protobuf/text_format.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/constraint_solver/routing.h" @@ -71,8 +70,7 @@ const char* kTime = "Time"; const char* kCapacity = "Capacity"; int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); CHECK_LT(0, absl::GetFlag(FLAGS_vrp_orders)) << "Specify an instance size greater than 0."; CHECK_LT(0, absl::GetFlag(FLAGS_vrp_vehicles)) diff --git a/examples/cpp/cvrptw_with_refueling.cc b/examples/cpp/cvrptw_with_refueling.cc index 67008c0c0e..8a235812f6 100644 --- a/examples/cpp/cvrptw_with_refueling.cc +++ b/examples/cpp/cvrptw_with_refueling.cc @@ -22,12 +22,11 @@ #include #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/random/random.h" #include "examples/cpp/cvrptw_lib.h" #include "google/protobuf/text_format.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/constraint_solver/routing.h" @@ -67,8 +66,7 @@ bool IsRefuelNode(int64_t node) { } int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); CHECK_LT(0, absl::GetFlag(FLAGS_vrp_orders)) << "Specify an instance size greater than 0."; CHECK_LT(0, absl::GetFlag(FLAGS_vrp_vehicles)) diff --git a/examples/cpp/cvrptw_with_resources.cc b/examples/cpp/cvrptw_with_resources.cc index 8683582e96..7d1e29187c 100644 --- a/examples/cpp/cvrptw_with_resources.cc +++ b/examples/cpp/cvrptw_with_resources.cc @@ -24,12 +24,11 @@ #include #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/random/random.h" #include "examples/cpp/cvrptw_lib.h" #include "google/protobuf/text_format.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/constraint_solver/routing.h" @@ -65,8 +64,7 @@ const char* kTime = "Time"; const char* kCapacity = "Capacity"; int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); CHECK_LT(0, absl::GetFlag(FLAGS_vrp_orders)) << "Specify an instance size greater than 0."; CHECK_LT(0, absl::GetFlag(FLAGS_vrp_vehicles)) diff --git a/examples/cpp/cvrptw_with_stop_times_and_resources.cc b/examples/cpp/cvrptw_with_stop_times_and_resources.cc index 2c48c42053..61d3964ea4 100644 --- a/examples/cpp/cvrptw_with_stop_times_and_resources.cc +++ b/examples/cpp/cvrptw_with_stop_times_and_resources.cc @@ -22,13 +22,12 @@ #include #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/random/random.h" #include "absl/strings/str_cat.h" #include "examples/cpp/cvrptw_lib.h" #include "google/protobuf/text_format.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/constraint_solver/routing.h" @@ -65,8 +64,7 @@ const char* kTime = "Time"; const char* kCapacity = "Capacity"; int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); CHECK_LT(0, absl::GetFlag(FLAGS_vrp_stops)) << "Specify an instance size greater than 0."; CHECK_LT(0, absl::GetFlag(FLAGS_vrp_orders_per_stop)) diff --git a/examples/cpp/dimacs_assignment.cc b/examples/cpp/dimacs_assignment.cc index 39b587bbac..9ad2d4171c 100644 --- a/examples/cpp/dimacs_assignment.cc +++ b/examples/cpp/dimacs_assignment.cc @@ -18,13 +18,12 @@ #include #include "absl/container/flat_hash_map.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/str_format.h" #include "examples/cpp/parse_dimacs_assignment.h" #include "examples/cpp/print_dimacs_assignment.h" #include "ortools/algorithms/hungarian.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/timer.h" #include "ortools/graph/ebert_graph.h" @@ -188,8 +187,7 @@ int main(int argc, char* argv[]) { } else { usage = absl::StrFormat(kUsageTemplate, argv[0]); } - google::InitGoogleLogging(usage.c_str()); - absl::ParseCommandLine(argc, argv); + InitGoogle(usage.c_str(), &argc, &argv, true); if (argc < 2) { LOG(FATAL) << usage; diff --git a/examples/cpp/dobble_ls.cc b/examples/cpp/dobble_ls.cc index 7cfb161b61..3ca2516eee 100644 --- a/examples/cpp/dobble_ls.cc +++ b/examples/cpp/dobble_ls.cc @@ -34,11 +34,10 @@ #include #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/random/random.h" #include "absl/strings/str_format.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/map_util.h" #include "ortools/constraint_solver/constraint_solveri.h" @@ -761,8 +760,7 @@ void SolveDobble(int num_cards, int num_symbols, int num_symbols_per_card) { } // namespace operations_research int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); // These constants comes directly from the dobble game. // There are actually 55 cards, but we can create up to 57 cards. const int kSymbolsPerCard = absl::GetFlag(FLAGS_symbols_per_card); diff --git a/examples/cpp/flow_api.cc b/examples/cpp/flow_api.cc index 1d34bc7a97..031054121e 100644 --- a/examples/cpp/flow_api.cc +++ b/examples/cpp/flow_api.cc @@ -13,8 +13,7 @@ #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/graph/ebert_graph.h" #include "ortools/graph/max_flow.h" @@ -84,8 +83,7 @@ void MaxFeasibleFlow() { } // namespace operations_research int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); operations_research::MinCostFlowOn4x4Matrix(); operations_research::MaxFeasibleFlow(); return EXIT_SUCCESS; diff --git a/examples/cpp/golomb_sat.cc b/examples/cpp/golomb_sat.cc index 6164639a3f..9822cee7c0 100644 --- a/examples/cpp/golomb_sat.cc +++ b/examples/cpp/golomb_sat.cc @@ -28,10 +28,9 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/str_format.h" #include "google/protobuf/text_format.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/sat/cp_model.h" @@ -121,8 +120,7 @@ void GolombRuler(int size) { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); if (absl::GetFlag(FLAGS_size) != 0) { operations_research::sat::GolombRuler(absl::GetFlag(FLAGS_size)); diff --git a/examples/cpp/integer_programming.cc b/examples/cpp/integer_programming.cc index 6574346fad..8b61dd724f 100644 --- a/examples/cpp/integer_programming.cc +++ b/examples/cpp/integer_programming.cc @@ -13,10 +13,9 @@ // Integer programming example that shows how to use the API. -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/linear_solver/linear_solver.h" @@ -89,9 +88,7 @@ void RunAllExamples() { } // namespace operations_research int main(int argc, char** argv) { - absl::SetFlag(&FLAGS_alsologtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); operations_research::RunAllExamples(); return EXIT_SUCCESS; } diff --git a/examples/cpp/jobshop_sat.cc b/examples/cpp/jobshop_sat.cc index baa2b3b1d2..05aca3042f 100644 --- a/examples/cpp/jobshop_sat.cc +++ b/examples/cpp/jobshop_sat.cc @@ -18,12 +18,11 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/match.h" #include "absl/strings/str_join.h" #include "google/protobuf/text_format.h" #include "google/protobuf/wrappers.pb.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/timer.h" #include "ortools/graph/connected_components.h" @@ -876,8 +875,7 @@ void Solve(const JsspInputProblem& problem) { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); if (absl::GetFlag(FLAGS_input).empty()) { LOG(FATAL) << "Please supply a data file with --input="; diff --git a/examples/cpp/knapsack_2d_sat.cc b/examples/cpp/knapsack_2d_sat.cc index 15ac500e60..c585bedeb3 100644 --- a/examples/cpp/knapsack_2d_sat.cc +++ b/examples/cpp/knapsack_2d_sat.cc @@ -22,10 +22,9 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "google/protobuf/text_format.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/packing/binpacking_2d_parser.h" #include "ortools/packing/multiple_dimensions_bin_packing.pb.h" @@ -227,8 +226,7 @@ void LoadAndSolve(const std::string& file_name, int instance) { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); if (absl::GetFlag(FLAGS_input).empty()) { LOG(FATAL) << "Please supply a data file with --input="; } diff --git a/examples/cpp/linear_assignment_api.cc b/examples/cpp/linear_assignment_api.cc index 9ce778367e..d21fa576f3 100644 --- a/examples/cpp/linear_assignment_api.cc +++ b/examples/cpp/linear_assignment_api.cc @@ -13,8 +13,7 @@ #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/graph/ebert_graph.h" #include "ortools/graph/linear_assignment.h" @@ -69,8 +68,7 @@ void AnotherAssignment() { } // namespace operations_research int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); operations_research::AssignmentOn4x4Matrix(); operations_research::AnotherAssignment(); return EXIT_SUCCESS; diff --git a/examples/cpp/linear_programming.cc b/examples/cpp/linear_programming.cc index c22fc7db45..e29a418165 100644 --- a/examples/cpp/linear_programming.cc +++ b/examples/cpp/linear_programming.cc @@ -16,11 +16,10 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/match.h" #include "absl/strings/string_view.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/linear_solver.pb.h" @@ -120,8 +119,7 @@ void RunAllExamples() { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_alsologtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); operations_research::RunAllExamples(); return EXIT_SUCCESS; } diff --git a/examples/cpp/linear_solver_protocol_buffers.cc b/examples/cpp/linear_solver_protocol_buffers.cc index 9c73491b32..ae15c6c403 100644 --- a/examples/cpp/linear_solver_protocol_buffers.cc +++ b/examples/cpp/linear_solver_protocol_buffers.cc @@ -13,8 +13,7 @@ #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/linear_solver/linear_solver.h" #include "ortools/linear_solver/linear_solver.pb.h" @@ -100,8 +99,7 @@ void RunAllExamples() { } // namespace operations_research int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); operations_research::RunAllExamples(); return EXIT_SUCCESS; } diff --git a/examples/cpp/magic_sequence_sat.cc b/examples/cpp/magic_sequence_sat.cc index 4afefde14f..8827765a81 100644 --- a/examples/cpp/magic_sequence_sat.cc +++ b/examples/cpp/magic_sequence_sat.cc @@ -20,9 +20,8 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/str_format.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/sat/cp_model.h" @@ -91,8 +90,7 @@ void MagicSequence(int size) { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); operations_research::sat::MagicSequence(absl::GetFlag(FLAGS_size)); return EXIT_SUCCESS; diff --git a/examples/cpp/magic_square_sat.cc b/examples/cpp/magic_square_sat.cc index c962d4bd99..c5183c0305 100644 --- a/examples/cpp/magic_square_sat.cc +++ b/examples/cpp/magic_square_sat.cc @@ -15,10 +15,9 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/sat/cp_model.h" @@ -103,8 +102,7 @@ void MagicSquare(int size) { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); operations_research::sat::MagicSquare(absl::GetFlag(FLAGS_size)); return EXIT_SUCCESS; diff --git a/examples/cpp/mps_driver.cc b/examples/cpp/mps_driver.cc index 306cfe3f3a..7a90bf1344 100644 --- a/examples/cpp/mps_driver.cc +++ b/examples/cpp/mps_driver.cc @@ -18,8 +18,6 @@ #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/status/status.h" #include "absl/strings/match.h" #include "google/protobuf/descriptor.h" @@ -27,6 +25,7 @@ #include "google/protobuf/text_format.h" #include "ortools/base/commandlineflags.h" #include "ortools/base/file.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/base/timer.h" #include "ortools/glop/lp_solver.h" @@ -82,7 +81,12 @@ void ReadGlopParameters(GlopParameters* parameters) { } int main(int argc, char* argv[]) { - absl::ParseCommandLine(argc, argv); + InitGoogle( + "Runs Glop on a given pattern of files given by --input. " + "The files must be in Mps or linear_solver.proto format and can be " + "compressed with gzip.", + &argc, &argv, true); + absl::SetFlag(&FLAGS_logtostderr, true); GlopParameters parameters; ReadGlopParameters(¶meters); diff --git a/examples/cpp/multi_knapsack_sat.cc b/examples/cpp/multi_knapsack_sat.cc index ea9d5fa33e..d16ba3fce9 100644 --- a/examples/cpp/multi_knapsack_sat.cc +++ b/examples/cpp/multi_knapsack_sat.cc @@ -23,9 +23,8 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/sat/cp_model.h" @@ -110,8 +109,7 @@ void MultiKnapsackSat(int scaling, const std::string& params) { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); operations_research::sat::MultiKnapsackSat(absl::GetFlag(FLAGS_size), absl::GetFlag(FLAGS_params)); return EXIT_SUCCESS; diff --git a/examples/cpp/network_routing_sat.cc b/examples/cpp/network_routing_sat.cc index 7eab24a6cb..2f2c0ad4e5 100644 --- a/examples/cpp/network_routing_sat.cc +++ b/examples/cpp/network_routing_sat.cc @@ -36,11 +36,10 @@ #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/random/uniform_int_distribution.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/graph/shortestpaths.h" @@ -678,8 +677,7 @@ class NetworkRoutingSolver { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); operations_research::sat::NetworkRoutingData data; operations_research::sat::NetworkRoutingDataBuilder builder( diff --git a/examples/cpp/nqueens.cc b/examples/cpp/nqueens.cc index 2f7dd7a8ef..fedd37f016 100644 --- a/examples/cpp/nqueens.cc +++ b/examples/cpp/nqueens.cc @@ -22,10 +22,9 @@ #include #include "absl/container/flat_hash_map.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/str_format.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/integral_types.h" #include "ortools/base/logging.h" #include "ortools/base/map_util.h" @@ -272,8 +271,7 @@ void NQueens(int size) { } // namespace operations_research int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); if (absl::GetFlag(FLAGS_size) != 0) { operations_research::NQueens(absl::GetFlag(FLAGS_size)); } else { @@ -281,5 +279,5 @@ int main(int argc, char** argv) { operations_research::NQueens(n); } } - return EXIT_SUCCESS; + return 0; } diff --git a/examples/cpp/pdptw.cc b/examples/cpp/pdptw.cc index aede538b10..7a18a536af 100644 --- a/examples/cpp/pdptw.cc +++ b/examples/cpp/pdptw.cc @@ -42,14 +42,13 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/numbers.h" #include "absl/strings/str_format.h" #include "absl/strings/str_split.h" #include "google/protobuf/text_format.h" #include "ortools/base/commandlineflags.h" #include "ortools/base/file.h" +#include "ortools/base/init_google.h" #include "ortools/base/mathutil.h" #include "ortools/base/timer.h" #include "ortools/constraint_solver/routing.h" @@ -395,8 +394,7 @@ bool LoadAndSolve(const std::string& pdp_file, int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); operations_research::RoutingModelParameters model_parameters = operations_research::DefaultRoutingModelParameters(); model_parameters.set_reduce_vehicle_cost_model( diff --git a/examples/cpp/sat_cnf_reader.h b/examples/cpp/sat_cnf_reader.h index 824ac13a79..644913b117 100644 --- a/examples/cpp/sat_cnf_reader.h +++ b/examples/cpp/sat_cnf_reader.h @@ -15,12 +15,13 @@ #define OR_TOOLS_SAT_SAT_CNF_READER_H_ #include -#include #include #include #include #include +#include "absl/container/btree_map.h" +#include "absl/flags/flag.h" #include "absl/strings/numbers.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" @@ -317,7 +318,7 @@ class SatCnfReader { // We stores the objective in a map because we want the variables to appear // only once in the LinearObjective proto. - std::map positive_literal_to_weight_; + absl::btree_map positive_literal_to_weight_; int64_t objective_offset_; // Used for the wcnf format. diff --git a/examples/cpp/sat_runner.cc b/examples/cpp/sat_runner.cc index 1c186dc342..9287c3b5e7 100644 --- a/examples/cpp/sat_runner.cc +++ b/examples/cpp/sat_runner.cc @@ -12,7 +12,6 @@ // limitations under the License. #include -#include #include #include #include @@ -20,29 +19,31 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/memory/memory.h" +#include "absl/random/random.h" #include "absl/status/status.h" #include "absl/strings/match.h" #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "examples/cpp/opb_reader.h" #include "examples/cpp/sat_cnf_reader.h" #include "google/protobuf/text_format.h" #include "ortools/algorithms/sparse_permutation.h" -#include "ortools/base/commandlineflags.h" #include "ortools/base/file.h" -#include "ortools/base/int_type.h" -#include "ortools/base/integral_types.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" +#include "ortools/base/logging_flags.h" #include "ortools/base/timer.h" +#include "ortools/linear_solver/linear_solver.pb.h" +#include "ortools/lp_data/lp_data.h" +#include "ortools/lp_data/mps_reader.h" +#include "ortools/lp_data/proto_utils.h" #include "ortools/sat/boolean_problem.h" #include "ortools/sat/boolean_problem.pb.h" #include "ortools/sat/cp_model.pb.h" #include "ortools/sat/cp_model_solver.h" -#include "ortools/sat/drat_proof_handler.h" #include "ortools/sat/lp_utils.h" #include "ortools/sat/model.h" #include "ortools/sat/optimization.h" @@ -53,6 +54,8 @@ #include "ortools/sat/simplification.h" #include "ortools/sat/symmetry.h" #include "ortools/util/file_util.h" +#include "ortools/util/logging.h" +#include "ortools/util/strong_integers.h" #include "ortools/util/time_limit.h" ABSL_FLAG( @@ -450,8 +453,7 @@ int main(int argc, char** argv) { // By default, we want to show how the solver progress. Note that this needs // to be set before InitGoogle() which has the nice side-effect of allowing // the user to override it. - google::InitGoogleLogging(kUsage); - absl::ParseCommandLine(argc, argv); + InitGoogle(kUsage, &argc, &argv, /*remove_flags=*/true); absl::SetFlag(&FLAGS_alsologtostderr, true); return operations_research::sat::Run(); } diff --git a/examples/cpp/shift_minimization_sat.cc b/examples/cpp/shift_minimization_sat.cc index 21a3f755ef..1078c1733b 100644 --- a/examples/cpp/shift_minimization_sat.cc +++ b/examples/cpp/shift_minimization_sat.cc @@ -33,11 +33,10 @@ #include "absl/container/btree_set.h" #include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/numbers.h" #include "absl/strings/str_split.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/sat/cp_model.h" #include "ortools/sat/model.h" @@ -305,8 +304,7 @@ void LoadAndSolve(const std::string& file_name) { int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(argv[0]); - absl::ParseCommandLine(argc, argv); + InitGoogle(argv[0], &argc, &argv, true); if (absl::GetFlag(FLAGS_input).empty()) { LOG(FATAL) << "Please supply a data file with --input="; diff --git a/examples/cpp/sports_scheduling_sat.cc b/examples/cpp/sports_scheduling_sat.cc index c897fb16c9..2388420bb8 100644 --- a/examples/cpp/sports_scheduling_sat.cc +++ b/examples/cpp/sports_scheduling_sat.cc @@ -43,12 +43,11 @@ // We also introduces a variable at_home[d][i] which is true if team i // plays any opponent at home on day d. -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "ortools/base/commandlineflags.h" +#include "ortools/base/init_google.h" #include "ortools/base/logging.h" #include "ortools/sat/cp_model.h" #include "ortools/sat/cp_model.pb.h" @@ -326,8 +325,7 @@ static const char kUsage[] = int main(int argc, char** argv) { absl::SetFlag(&FLAGS_logtostderr, true); - google::InitGoogleLogging(kUsage); - absl::ParseCommandLine(argc, argv); + InitGoogle(kUsage, &argc, &argv, true); CHECK_EQ(0, absl::GetFlag(FLAGS_num_teams) % 2) << "The number of teams must be even"; CHECK_GE(absl::GetFlag(FLAGS_num_teams), 2) << "At least 2 teams"; diff --git a/examples/cpp/strawberry_fields_with_column_generation.cc b/examples/cpp/strawberry_fields_with_column_generation.cc index 83fb02a172..80c0872b33 100644 --- a/examples/cpp/strawberry_fields_with_column_generation.cc +++ b/examples/cpp/strawberry_fields_with_column_generation.cc @@ -59,10 +59,9 @@ #include #include -#include "absl/flags/parse.h" -#include "absl/flags/usage.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/base/macros.h" #include "ortools/linear_solver/linear_solver.h" @@ -604,8 +603,7 @@ int main(int argc, char** argv) { usage += " --colgen_max_iterations max columns to generate\n"; usage += " --colgen_complete generate all columns at start\n"; - google::InitGoogleLogging(usage.c_str()); - absl::ParseCommandLine(argc, argv); + InitGoogle(usage.c_str(), &argc, &argv, true); operations_research::MPSolver::OptimizationProblemType solver_type; bool found = false;