Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
lp_parser.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// Parses a the model in "CPLEX LP" format using SCIP.
15//
16// Note that ../../lp_data/lp_parser.h parses ".lp" files in the LPSolve
17// version of the LP format, which is different from the (now) more standard
18// CPLEX version of the LP format. These formats are not compatible. See
19// https://lpsolve.sourceforge.net/5.5/lp-format.htm
20// https://lpsolve.sourceforge.net/5.5/CPLEX-format.htm
21// for a comparison.
22#ifndef OR_TOOLS_MATH_OPT_IO_LP_PARSER_H_
23#define OR_TOOLS_MATH_OPT_IO_LP_PARSER_H_
24
25#include "absl/status/statusor.h"
26#include "absl/strings/string_view.h"
27#include "ortools/math_opt/model.pb.h"
28
30
31// Parses a the model in "CPLEX LP" format.
32//
33// This function creates and destroys local temporary files and thus is not
34// portable.
35//
36// For large models, this will not work on diskless jobs in prod.
37//
38// Warnings:
39// * Only a linear objective and linear constraints are supported. When SCIP is
40// used, indicator constraints are also supported.
41// * The names of indicator constraints are not preserved when using SCIP
42// * The variables may be permuted.
43// * Two sided constraints are not in the LP format. If you round trip a Model
44// Proto with lp_converter.h, the two sided constraints are and rewritten as
45// two one sided constraints with new names.
46//
47// OR-Tools does not have an LP file parser, so we go from LP file to SCIP, then
48// export to MPS, parse the MPS to ModelProto. This is not efficient, but
49// usually still much faster than solving an LP or MIP. Note the SCIP LP parser
50// actually supports SOS and quadratics, but the OR-tools MPS reader does not.
51//
52// It would be preferable to write an LP Parser from scratch and delete this.
53//
54// For more information about the different LP file formats:
55// http://lpsolve.sourceforge.net/5.5/lp-format.htm
56// http://lpsolve.sourceforge.net/5.5/CPLEX-format.htm
57// https://www.ibm.com/docs/en/icos/12.8.0.0?topic=cplex-lp-file-format-algebraic-representation
58// http://www.gurobi.com/documentation/5.1/reference-manual/node871
59absl::StatusOr<ModelProto> ModelProtoFromLp(absl::string_view lp_data);
60
61} // namespace operations_research::math_opt
62
63#endif // OR_TOOLS_MATH_OPT_IO_LP_PARSER_H_
An object oriented wrapper for quadratic constraints in ModelStorage.
Definition gurobi_isv.cc:28
absl::StatusOr< ModelProto > ModelProtoFromLp(const absl::string_view lp_data)
Definition lp_parser.cc:52