To see a broader comparison of Gurobi vs. open-source solvers, please visit our open-source solvers page. To see some more information on switching to Gurobi from other commercial solvers, please visit our switching to Gurobi page.
Exporting MPS files is easier than you may think. We are also happy to assist you both in exporting your models and, if you wish, both benchmarking your models using Gurobi and recommending specific parameter settings for Gurobi that will give you the best performance. Click on any of the above tabs to see solver-specific instructions for exporting MPS files. Once you have exported your model, simply email us at help@gurobi.com and we will enable your account for uploads so you can conveniently and confidentially send it to us for benchmarking. If you have any questions, please also feel free to contact us at help@gurobi.com.
Please refer to the following common issues we encounter and their corresponding workarounds.
Command Line, C / C++ and Python
Overview: | If you are using COIN from the command line you could use the export parameter to export your model to an MPS file. |
Instructions: | To enter the command line mode, use:
#> ∼/Cbc-2.8.12/build/bin/cbc – You should get the prompt “Coin:”. After building the model interactively, issuing the following command: export model.mps will export the model to an MPS file. |
Instructions: | Insert
solver.writeMps(“model”,”mps”,0.0); after you have built your model and right before the call of the optimization routine. Note: Change the third argument 0.0 to -1.0 if you want to maximize, to 1.0 if you want to minimize or 0.0 if the solver should decide. |
Example: |
OsiClpSolverInterface solver; CbcModel model(solver); // the model is built here solver.writeMps(“model”,”mps”,0.0); model.branchAndBound(); Note: While you modify your model with methods from the class CbcModel, the writeMps method is a function of the OsiClpSolverInterface class. After saving the file, compiling your code and executing it, the MPS file with the chosen name will be located in your current directory. It is automatically compressed and is now named i.e. “model.mps.gz”. |
Instructions: | Insert
s.writeMps(“model.mps”,0,2,0) after you have built your model and right before the call of the optimization routine. |
Example: |
s = CyClpSimplex() // the model is built here s.writeMps(“model.mps”,0,2,1.0) s.primal() Note: Choose 1.0 for minimization or -1.0 for maximization as fourth argument. After saving the file and calling the python interpreter, the MPS file with the chosen name will be located in your current directory. |
Command Line, C / C++, Python, Java and MATLAB
Instructions: | After you have build your model write:
write model.mps Note: If your MPS file is too large to be sent easily, CPLEX can compress it directly if you append .gz after the filename, i.e. “model.mps.gz”. If you want to anonymize the variable and constraint names append the file ending .rew instead of .mps. |
Instructions: | Insert
status = CPXwriteprob(env, lp, “model.mps”, NULL); after you have built your model and right before the call of the optimization routine. |
Example: |
lp = CPXcreateprob(env, &status, probname); // the model is built here status = CPXwriteprob(env, lp, “model.mps”, NULL); status = CPXmipopt(env, lp); Note: If your MPS file is too large to be sent easily, CPLEX can compress it directly if you append .gz after the filename, i.e. “model.mps.gz”. If you want to anonymize the variable and constraint names append the file ending .rew instead of .mps. After saving the file, compiling your code and executing it, the MPS file with the chosen name will be located in your current directory. |
Instructions: | Insert
cplex.exportModel(“model.mps”); after you have built your model and right before the call of the optimization routine. |
Example: |
IloCplex cplex(env); // the model is built here cplex.exportModel(“model.mps”); IloCplex cplex(env); Note: If your MPS file is too large to be sent easily, CPLEX can compress it directly if you append .gz after the filename, i.e. “model.mps.gz”. If you want to anonymize the variable and constraint names append the file ending .rew instead of .mps. After saving the file, compiling your code and executing it, the MPS file with the chosen name will be located in your current directory. |
Instructions: | Insert
cpx.write(“model.mps”) after you have built your model and right before the call of the optimization routine. |
Example: |
import cplex cpx = cplex.Cplex() // the model is built here cpx.write(“model.mps”); cpx.solve() Note: If your MPS file is too large to be sent easily, CPLEX can compress it directly if you append .gz after the filename, i.e. “model.mps.gz”. If you want to anonymize the variable and constraint names append the file ending .rew instead of .mps. After saving the file and calling the python interpreter, the MPS file with the chosen name will be located in your current directory. |
Instructions: | Insert
cplex.exportModel(“model.mps”); after you have built your model and right before the call of the optimization routine. |
Example: |
IloCplex cplex = new IloCplex(); // the model is built here cplex.exportModel(“model.mps”); cplex.solve() Note: If your MPS file is too large to be sent easily, CPLEX can compress it directly if you append .gz after the filename, i.e. “model.mps.gz”. If you want to anonymize the variable and constraint names append the file ending .rew instead of .mps. After saving the file, compiling your code and executing it, the MPS file with the chosen name will be located in your current directory. |
Instructions: | Insert
cplex.writeModel(‘model.mps’); after you have built your model and right before the call of the optimization routine. |
Example: |
cplex = Cplex(); // the model is built here cplex.writeModel(‘model.mps’); cplex.solve(); Note: If your MPS file is too large to be sent easily, CPLEX can compress it directly if you append .gz after the filename, i.e. “model.mps.gz”. If you want to anonymize the variable and constraint names append the file ending .rew instead of .mps. After saving the file and calling the Matlab interpreter, the MPS file with the chosen name will be located in your current directory. |
Command Line, C / C++, Python, Java and MATLAB Note on lp_solve: In MPS files, lp_solve may write binary variables as unbounded general integers. Thus, before writing an MPS file from lp_solve, explicitly set an upper bound of 1 for all binary variables.
Instructions: | If you are using lp_solve through the command line you could either send us directly your lp-file or in case you use a program to output your model and pipe it into lp_solve you could use the –wmps parameter of lp_solve:
generate_model_program | lpsolve -wmps model.mps |
Instructions: | Insert
write_mps(lp, “model.mps”); after you have built your model and right before the call of the optimization routine. |
Example: |
set_obj_fn(lp, row) write_mps(lp, “model.mps”); solve(lp); After saving the file, compiling your code and executing it, the MPS file with the chosen name will be located in your current directory. |
Instructions: | Insert
lpsolve(‘write_mps’, lp, ‘model.mps’) after you have built your model and right before the call of the optimization routine. |
Example: |
lpsolve(‘add_constraint’, lp, [12.68, 0, 0.08, 0.9], GE, 4) lpsolve(‘write_mps’, lp, ‘model.mps’) lpsolve(‘solve’, lp) After saving the file and calling the python interpreter, the MPS file with the chosen name will be located in your current directory. |
Instructions: | Insert
problem.writeMps(“model.mps”); after you have built your model and right before the call of the optimization routine. |
Example: |
problem.strAddConstraint(“1 2 1 4”, LpSolve.EQ, 8); problem.writeMps(“model.mps”); problem.solve(); After saving the file, compiling your code and executing it, the MPS file with the chosen name will be located in your current directory. |
Instructions: | Insert
mxlpsolve(‘write_mps’, lp, ‘model.mps’); after you have built your model and right before the call of the optimization routine. |
Example: |
mxlpsolve(‘add_constraint’, lp, [12.68, 0, 0.08, 0.9], 2, 4); mxlpsolve(‘write_mps’, lp, ‘model.mps’); mxlpsolve(‘solve’, lp) After saving the file and calling the Matlab interpreter, the MPS file with the chosen name will be located in your current directory. |
Command Line and C / C++
Overview: | Creating MPS file from a GNU MathProg file (*.mod file) with the command line tool of GLPK (glpsol) |
Instructions: | Open the command line and change to the directory, where the *.mod file is located. Execute the following command (you need to replace problem.mod with the name of your file)
glpsol –model “problem.mod” –wmps “model.mps” Replacing “model.mps” with “model.mps.gz” will again result in a compressed file. After the execution of the command the (compressed) MPS file with the chosen name is located in your current directory. |
Instructions: | Insert
glp_write_mps(lp, GLP_MPS_DECK, NULL, “model.mps”); after you have built your model and right before the call of the optimization routine. |
Example: |
glp_load_matrix(lp, 9, ia, ja, ar); glp_write_mps(lp, GLP_MPS_DECK, NULL, “model.mps”); glp_simplex(lp, NULL); Note: If your MPS file is too large to be sent easily, glpk can compress it directly if you append .gz after the filename, i.e. “model.mps.gz”. After saving the file, compiling your code and executing it, the (compressed) MPS file with the chosen name will be located in your current directory. |
Command Line and C
Instructions: | After you have built your model write:
write problem model.mps To anonymize a model, use the following code instead: write genproblem model.mps |
Instructions: | Insert:
SCIPwriteOrigProblem(scip, “model.mps”, NULL, 0); after you have built your model and right before the call of the optimization routine. If you want to anonymize the variable and constraint names, pass a “1” as last parameter to SCIPwriteOrigProblem() instead. |
GUROBI NEWSLETTER
Latest news and releases
Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.
Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.