Change proto to/from file API to use absl::StatusOr; add reader/writer proto_file to model_builder

This commit is contained in:
Laurent Perron
2023-11-20 16:13:18 +01:00
parent 72f274f844
commit 2913419570
2 changed files with 23 additions and 1 deletions

View File

@@ -69,7 +69,7 @@ void WriteSolveLog(const std::string& solve_log_file, const SolveLog& log) {
<< solve_log_file << ". Expected .textproto, .pb, or .json";
}
QCHECK(WriteProtoToFile(solve_log_file, log, write_format, /*gzipped=*/false,
/*append_extension_to_file_name=*/false));
/*append_extension_to_file_name=*/false).ok());
}
void Solve(const std::string& input, const std::string& params_str,

22
patches/scip-v804.patch Normal file
View File

@@ -0,0 +1,22 @@
diff --git a/src/lpi/lpi_glop.cpp b/src/lpi/lpi_glop.cpp
index 2471778a8f..17fd1e8c34 100644
--- a/src/lpi/lpi_glop.cpp
+++ b/src/lpi/lpi_glop.cpp
@@ -3190,7 +3190,7 @@ SCIP_RETCODE SCIPlpiReadLP(
const std::string filespec(fname);
MPModelProto proto;
- if ( ! ReadFileToProto(filespec, &proto) )
+ if ( ! ReadFileToProto(filespec, &proto).ok() )
{
SCIPerrorMessage("Could not read <%s>\n", fname);
return SCIP_READERROR;
@@ -3214,7 +3214,7 @@ SCIP_RETCODE SCIPlpiWriteLP(
MPModelProto proto;
LinearProgramToMPModelProto(*lpi->linear_program, &proto);
const std::string filespec(fname);
- if ( ! WriteProtoToFile(filespec, proto, operations_research::ProtoWriteFormat::kProtoText, true) )
+ if ( ! WriteProtoToFile(filespec, proto, operations_research::ProtoWriteFormat::kProtoText, true).ok() )
{
SCIPerrorMessage("Could not write <%s>\n", fname);
return SCIP_READERROR;