Be careful when using a third-party API to write a model file
Many users call the Gurobi solver through third-party APIs like JuMP.jl, CVXPY, or Pyomo. Such tools may not provide a way to write an MPS model file to disk. Even if the interface is able to write an MPS file, the model file is likely constructed by the third-party API, not Gurobi's internal file-writer. As a result, the generated MPS model file will almost certainly not match the model stored internally by Gurobi.
Use Gurobi to write a model file
When using third-party solver interfaces, you can direct Gurobi to write an MPS file by setting the GURO_PAR_DUMP parameter to 1.
If you are not sure how to pass parameters to the third-party API or if the API doesn't allow you to set this parameter, you can use a Gurobi environment file. This involves creating a text file named gurobi.env in the current working directory for your application (the directory where you launch the process). The gurobi.env file should contain the following line:
GURO_PAR_DUMP 1When the optimization starts, the solver generates the following files in the current working directory: gurobi.mps, gurobi.prm, and gurobi.attr. To understand what information these files contain please refer to File Formats in our reference manual
To anonymize the names of variables and constraints in files, you can additionally add the line:
IGNORENAMES 1 to the gurobi.env file.
Limitations
- The generated files are overwritten by the most recent optimization run.
-
The GURO_PAR_DUMP parameter is not supported with Gurobi Instant Cloud or Compute Server. However, you can specify a value for the ResultFile parameter in the gurobi.env file instead:
ResultFile model.mps
Further information
- How do I set parameters in Gurobi?
- Switching to Gurobi: Exporting MPS Files
- How do I upload or send files to Gurobi Support?
- How do I export a model from Gurobi?
- What are the differences between LP and MPS file formats?
- How do I get similar performance from Gurobi based on parameters tuned for another solver?