diff --git a/ortools/linear_solver/BUILD.bazel b/ortools/linear_solver/BUILD.bazel index 85e3bdfd88..2a89981456 100644 --- a/ortools/linear_solver/BUILD.bazel +++ b/ortools/linear_solver/BUILD.bazel @@ -230,6 +230,7 @@ cc_library( cc_binary( name = "solve", srcs = ["solve.cc"], + defines = ["USE_LP_PARSER"], deps = [ ":linear_solver", ":linear_solver_cc_proto", diff --git a/ortools/linear_solver/proto_solver/scip_proto_solver.cc b/ortools/linear_solver/proto_solver/scip_proto_solver.cc index ea8fc8aa6c..dd036ea517 100644 --- a/ortools/linear_solver/proto_solver/scip_proto_solver.cc +++ b/ortools/linear_solver/proto_solver/scip_proto_solver.cc @@ -442,11 +442,11 @@ absl::Status AddMinMaxConstraint(const MPGeneralConstraintProto& gen_cst, vars = {scip_resultant_var}; vals = {1}; if (gen_cst.has_min_constraint()) { - RETURN_IF_ERROR(add_lin_constraint(absl::StrCat("_ineq_constant"), - -kInfinity, minmax.constant())); + RETURN_IF_ERROR( + add_lin_constraint("_ineq_constant", -kInfinity, minmax.constant())); } else { - RETURN_IF_ERROR(add_lin_constraint(absl::StrCat("_ineq_constant"), - minmax.constant(), kInfinity)); + RETURN_IF_ERROR( + add_lin_constraint("_ineq_constant", minmax.constant(), kInfinity)); } } for (SCIP_CONS* scip_cons : cons) { diff --git a/ortools/linear_solver/solve.cc b/ortools/linear_solver/solve.cc index 187d451eb5..89a108af72 100644 --- a/ortools/linear_solver/solve.cc +++ b/ortools/linear_solver/solve.cc @@ -133,11 +133,15 @@ MPModelRequest ReadMipModel(const std::string& input) { MPModelRequest request_proto; MPModelProto model_proto; if (absl::EndsWith(input, ".lp")) { +#if defined(USE_LP_PARSER) std::string data; CHECK_OK(file::GetContents(input, &data, file::Defaults())); absl::StatusOr result = ModelProtoFromLpFormat(data); CHECK_OK(result); model_proto = std::move(result).value(); +#else // !defined(USE_LP_PARSER) + LOG(FATAL) << "Support for parsing LP format is not compiled in."; +#endif // !defined(USE_LP_PARSER) } else if (absl::EndsWith(input, ".mps") || absl::EndsWith(input, ".mps.gz")) { QCHECK_OK(glop::MPSReader().ParseFile(input, &model_proto))