Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
quadratic_program_io.h
Go to the documentation of this file.
1// Copyright 2010-2024 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"
23#include "absl/status/statusor.h"
25
27
28// Reads a quadratic program, determining the type based on the filename's
29// suffix:
30// *.mps, *.mps.gz, *.mps.bz2 -> `ReadMpsLinearProgramOrDie`
31// *.pb, *.textproto, *.json, *.json.gz -> `ReadMPModelProtoFileOrDie`
32// otherwise CHECK-fails.
33QuadraticProgram ReadQuadraticProgramOrDie(const std::string& filename,
34 bool include_names = false);
35
36QuadraticProgram ReadMpsLinearProgramOrDie(const std::string& lp_file,
37 bool include_names = false);
38
39absl::StatusOr<QuadraticProgram> ReadMpsLinearProgram(
40 const std::string& lp_file, bool include_names = false);
41
42// The input may be `MPModelProto` in text format, binary format, or JSON,
43// possibly gzipped.
44QuadraticProgram ReadMPModelProtoFileOrDie(
45 const std::string& mpmodel_proto_file, bool include_names = false);
46
47// NOTE: This will fail if `linear_program` is actually a quadratic program
48// (that is, has a non-empty quadratic objective term).
49absl::Status WriteLinearProgramToMps(const QuadraticProgram& linear_program,
50 const std::string& mps_file);
52 const QuadraticProgram& quadratic_program,
53 const std::string& mpmodel_proto_file);
54
55} // namespace operations_research::pdlp
56#endif // PDLP_QUADRATIC_PROGRAM_IO_H_
Validation utilities for solvers.proto.
QuadraticProgram ReadMPModelProtoFileOrDie(const std::string &mpmodel_proto_file, bool include_names)
QuadraticProgram ReadQuadraticProgramOrDie(const std::string &filename, bool include_names)
absl::Status WriteLinearProgramToMps(const QuadraticProgram &linear_program, const std::string &mps_file)
QuadraticProgram ReadMpsLinearProgramOrDie(const std::string &lp_file, bool include_names)
absl::Status WriteQuadraticProgramToMPModelProto(const QuadraticProgram &quadratic_program, const std::string &mpmodel_proto_file)
absl::StatusOr< QuadraticProgram > ReadMpsLinearProgram(const std::string &lp_file, bool include_names)