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?


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")
# {'x': x, 'y': y, 'z': z}
# test_export_dict_MIP:
# 1*x + 4*y + 9*z + 0
# c1: x + y <= 5
# c2: x + z >= 10
# c3: - y + z = 7.5
# x <= 4 Continuous
# -1 <= y <= 1 Continuous
# 0 <= z Integer
  • $\begingroup$ Thanks for the quick response! $\endgroup$ Sep 20 '21 at 14:59

Virtually any IP solver can do this for you (Cplex/Gurobi/Xpress/...). The general approach would be to:

  1. Import the MPS file into the solver
  2. 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).

  • 1
    $\begingroup$ @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, ...; $\endgroup$
    – A.Omidi
    Sep 20 '21 at 19:52
  • $\begingroup$ 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.? $\endgroup$ Sep 21 '21 at 0:21
  • $\begingroup$ As far as I know it is possible. $\endgroup$
    – A.Omidi
    Sep 21 '21 at 2:53
  • $\begingroup$ That is impossible. How should you for instance deduce the underlying meaning of x+y<=1 without knowing the context of the model. $\endgroup$ Sep 21 '21 at 10:23
  • 1
    $\begingroup$ That is precisely my point. $\endgroup$ Sep 22 '21 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.