read()

read ( filename, env=defaultEnv )

Read a model from a file.

Arguments:

filename: Name of file containing model. Note that the type of the file is encoded in the file name suffix. Valid suffixes are .mps, .rew, .lp, .rlp, .ilp, or .opb. The files can be compressed, so additional suffixes of .gz, .bz2, .zip, or .7z are accepted. The file name may contain * or ? wildcards. No file is read when no wildcard match is found. If more than one match is found, this routine will attempt to read the first matching file.

env: Environment in which to create the model. Creating your environment (using the Env constructor) gives you more control over Gurobi licensing, but it can make your program more complex. Use the default environment unless you know that you need to control your own environments.

Return value:

Model object containing the model that was read from the input file.

Example usage:

  m = read("afiro.mps")
  m.optimize()

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.

Search