Try our new documentation site (beta).


write ( filename )

This method is the general entry point for writing model data to a file. It can be used to write optimization models, IIS submodels, solutions, basis vectors, MIP start vectors, or parameter settings. The type of file is determined by the file suffix. File formats are described in the File Format section.

Note that writing a model to a file will process all pending model modifications. However, writing other model information (solutions, bases, etc.) will not.


filename: Name of the file to write. The file type is encoded in the file name suffix. Valid suffixes for writing the model itself are .mps, .rew, .lp, or .rlp. An IIS can be written by using an .ilp suffix. Use .sol for a solution file, .mst for a MIP start, .hnt for MIP hints, .bas for a basis file, or .prm for a parameter file. The suffix may optionally be followed by .gz, .bz2, or .7z, which produces a compressed result.

Example usage:


Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.