46int main(
int argc,
char** argv) {
48 std::string input_ascii_pb;
49 CHECK(!absl::GetFlag(FLAGS_input).empty() &&
50 !absl::GetFlag(FLAGS_output).empty())
51 <<
"--input and --output are required.";
52 operations_research::MPModelProto model_proto;
53 if (absl::GetFlag(FLAGS_input_is_mp_model_request)) {
54 operations_research::MPModelRequest request_proto;
57 model_proto.Swap(request_proto.mutable_model());
62 std::string output_contents;
64 options.
obfuscate = absl::GetFlag(FLAGS_obfuscate);
65 if (absl::EndsWith(absl::GetFlag(FLAGS_output),
".lp")) {
66 output_contents = ExportModelAsLpFormat(model_proto, options).value();
67 }
else if (absl::EndsWith(absl::GetFlag(FLAGS_output),
".mps")) {
68 output_contents = ExportModelAsMpsFormat(model_proto, options).value();
69 }
else if (absl::EndsWith(absl::GetFlag(FLAGS_output),
".pb.txt")) {
70 google::protobuf::io::StringOutputStream stream(&output_contents);
71 CHECK(google::protobuf::TextFormat::PrintToString(model_proto,
74 LOG(FATAL) <<
"Unsupported extension: " << absl::GetFlag(FLAGS_output)
75 <<
" (try: .lp, .mps or .pb.txt)";
79 fprintf(stderr,
"Wrote '%s' successfully\n",
80 absl::GetFlag(FLAGS_output).c_str());
int main(int argc, char **argv)
static const char kUsageStr[]
ABSL_FLAG(std::string, input, "", "REQUIRED: Input file name")
See kUsageStr below, and ./model_exporter.h.