use init_google.h in c++ examples

This commit is contained in:
Laurent Perron
2022-02-25 09:47:52 +01:00
parent 19667205a2
commit 4c8570a57c
31 changed files with 80 additions and 130 deletions

View File

@@ -23,10 +23,9 @@
#include <vector>
#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=";
}

View File

@@ -28,10 +28,9 @@
#include <utility>
#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;

View File

@@ -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);

View File

@@ -25,12 +25,11 @@
#include <cstdint>
#include <vector>
#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))

View File

@@ -24,12 +24,11 @@
#include <cstdint>
#include <vector>
#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))

View File

@@ -28,13 +28,12 @@
#include <cstdint>
#include <vector>
#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))

View File

@@ -22,12 +22,11 @@
#include <cstdint>
#include <vector>
#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))

View File

@@ -24,12 +24,11 @@
#include <cstdint>
#include <vector>
#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))

View File

@@ -22,13 +22,12 @@
#include <cstdint>
#include <vector>
#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))

View File

@@ -18,13 +18,12 @@
#include <vector>
#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;

View File

@@ -34,11 +34,10 @@
#include <cstdlib>
#include <vector>
#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);

View File

@@ -13,8 +13,7 @@
#include <cstdlib>
#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;

View File

@@ -28,10 +28,9 @@
#include <cstdio>
#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));

View File

@@ -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;
}

View File

@@ -18,12 +18,11 @@
#include <vector>
#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=";

View File

@@ -22,10 +22,9 @@
#include <vector>
#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=";
}

View File

@@ -13,8 +13,7 @@
#include <cstdlib>
#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;

View File

@@ -16,11 +16,10 @@
#include <cstdlib>
#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;
}

View File

@@ -13,8 +13,7 @@
#include <string>
#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;
}

View File

@@ -20,9 +20,8 @@
#include <cstdlib>
#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;

View File

@@ -15,10 +15,9 @@
#include <vector>
#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;

View File

@@ -18,8 +18,6 @@
#include <string>
#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(&parameters);

View File

@@ -23,9 +23,8 @@
#include <vector>
#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;

View File

@@ -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(

View File

@@ -22,10 +22,9 @@
#include <map>
#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;
}

View File

@@ -42,14 +42,13 @@
#include <vector>
#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(

View File

@@ -15,12 +15,13 @@
#define OR_TOOLS_SAT_SAT_CNF_READER_H_
#include <cstdint>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#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<int, int64_t> positive_literal_to_weight_;
absl::btree_map<int, int64_t> positive_literal_to_weight_;
int64_t objective_offset_;
// Used for the wcnf format.

View File

@@ -12,7 +12,6 @@
// limitations under the License.
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <memory>
#include <string>
@@ -20,29 +19,31 @@
#include <vector>
#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();
}

View File

@@ -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=";

View File

@@ -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";

View File

@@ -59,10 +59,9 @@
#include <utility>
#include <vector>
#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 <n> 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;