OR-Tools  9.6
quadratic_program_io.h
Go to the documentation of this file.
1 // Copyright 2010-2022 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #ifndef PDLP_QUADRATIC_PROGRAM_IO_H_
15 #define PDLP_QUADRATIC_PROGRAM_IO_H_
16 
17 #include <cstdint>
18 #include <string>
19 #include <vector>
20 
21 #include "absl/container/flat_hash_map.h"
22 #include "absl/status/status.h"
24 
25 namespace operations_research::pdlp {
26 
27 // Reads a quadratic program, determining the type based on the filename's
28 // suffix:
29 // *.mps, *.mps.gz, *.mps.bz2 -> `ReadMpsLinearProgramOrDie`
30 // *.pb, *.textproto, *.json, *.json.gz -> `ReadMPModelProtoFileOrDie`
31 // otherwise CHECK-fails.
32 QuadraticProgram ReadQuadraticProgramOrDie(const std::string& filename,
33  bool include_names = false);
34 
35 QuadraticProgram ReadMpsLinearProgramOrDie(const std::string& lp_file,
36  bool include_names = false);
37 // The input may be `MPModelProto` in text format, binary format, or JSON,
38 // possibly gzipped.
39 QuadraticProgram ReadMPModelProtoFileOrDie(
40  const std::string& mpmodel_proto_file, bool include_names = false);
41 
42 // NOTE: This will fail if `linear_program` is actually a quadratic program
43 // (that is, has a non-empty quadratic objective term).
44 absl::Status WriteLinearProgramToMps(const QuadraticProgram& linear_program,
45  const std::string& mps_file);
47  const QuadraticProgram& quadratic_program,
48  const std::string& mpmodel_proto_file);
49 
50 } // namespace operations_research::pdlp
51 #endif // PDLP_QUADRATIC_PROGRAM_IO_H_
absl::Status WriteQuadraticProgramToMPModelProto(const QuadraticProgram &quadratic_program, const std::string &mpmodel_proto_file)
absl::Status WriteLinearProgramToMps(const QuadraticProgram &linear_program, const std::string &mps_file)
QuadraticProgram ReadMPModelProtoFileOrDie(const std::string &mpmodel_proto_file, bool include_names)
QuadraticProgram ReadQuadraticProgramOrDie(const std::string &filename, bool include_names)
QuadraticProgram ReadMpsLinearProgramOrDie(const std::string &lp_file, bool include_names)