I have a huge mps file and would like to get the associated MIP model, i.e., the objective, constraint, and bounds. Is there any tools that could get that?
Asked
Active
Viewed 609 times
2 Answers
9
You can use PuLp's import and export functions (this is Python).
For example, the following snippet shows you how to import an mps file and print the corresponding MIP:
var1, prob1 = LpProblem.fromMPS("test.mps")
var1
# {'x': x, 'y': y, 'z': z}
prob1
# test_export_dict_MIP:
# MINIMIZE
# 1*x + 4*y + 9*z + 0
# SUBJECT TO
# c1: x + y <= 5
# c2: x + z >= 10
# c3: - y + z = 7.5
# VARIABLES
# x <= 4 Continuous
# -1 <= y <= 1 Continuous
# 0 <= z Integer
Kuifje
- 13,324
- 1
- 23
- 56
-
Thanks for the quick response! – Afshin Oroojlooy Sep 20 '21 at 14:59
6
Virtually any IP solver can do this for you (Cplex/Gurobi/Xpress/...). The general approach would be to:
- Import the MPS file into the solver
- Export the model in LP format
Note that the above can be accomplished, either programmatically, or through a command-line interface that most solvers provide. As per example, in Cplex you could simply use the Interactive optimizer:
> read my_mip_model.mps
> write my_mip_model.lp
Gurobi and Xpress have similar capabilities (command line syntax is slightly different).
Joris Kinable
- 3,451
- 8
- 19
-
1@Afshin Oroojlooy, additionally, by using SCIP's interactive shell you are being able to translate that into a specific algebraic language such as GAMS. Then it would be converted to others like AMPL, etc. The command-line codes are: read -> write -> problem -> "modelname".lp,gms,mps, ...; – A.Omidi Sep 20 '21 at 19:52
-
Thanks for the tips. I converted the mps file with
pulp, but still it is so huge and I cannot figure out what the constraint mean for that instant. Is it possible to get an compact version like those that we use to pass a huge model by reading coefficients from a file? like the syntax that we use in GAMS, Ample, etc.? – Afshin Oroojlooy Sep 21 '21 at 00:21 -
-
That is impossible. How should you for instance deduce the underlying meaning of x+y<=1 without knowing the context of the model. – ErlingMOSEK Sep 21 '21 at 10:23
-
@ErlingMOSEK, I mean actually by SCIP is that in the first step converting the MPS file into the corresponding GAMS format. In the next step translating the converted GAMS format into your favorite format like AMPL by specific GAMS option
convert. I try this and it works. Would you say please, why is it impossible? – A.Omidi Sep 21 '21 at 11:54 -
@ErlingMOSEK, ah, maybe I miss something. In this procedure, there is no compacting method and it translates the original model without any changing/compacting in the coefficient matrices. – A.Omidi Sep 21 '21 at 11:59
-
1