# Convert MPS file to the associated MIP model

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")
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

• Thanks for the quick response! 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).

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