I would like to know is it possible to read an LP/MPS file into the Pyomo software and solve the problem? If so, how can I do that?


According to this link on Pyomo forum from 2016 about LP files, and this one from 2018 about MPS file, this functionality doesn't exist yet. To quote from the first link:

LP files are “flat” representations of a model, and there really hasn’t been a strong motivation to import that into a structured system like Pyomo. It’s not impossible to write an LP file reader, but none exist (nor are any under development).

| improve this answer | |


  • Pyomo has PyLPSolve, a wrapper for the open source LP solver lpsolve, listed on the Pyomo Python Optimisation Tools webpage. The webpage "Introduction to lp_solve" says that lpsolve itself is written in C and that along with an "External Language Interface" and "API" it reads LP and MPS format files. See the Introduction and FAQ.

  • PuLP also appears to read LP and MPS files. From the PuLP GitHub webpage:

    "PuLP is an LP modeler written in Python. PuLP can generate MPS or LP files and call GLPK, COIN CLP/CBC, CPLEX, and GUROBI to solve linear problems.". The default solver is CBC.

  • PySP (a Modeling Extension for Pyomo) can convert Pyomo format to SMPS:

    "Generating SMPS Input Files From PySP Models

    This document explains how to convert a PySP model into a set of files representing the SMPS format for stochastic linear programs. Conversion can be performed through the command line by invoking the SMPS converter using the command python -m pyomo.pysp.convert.smps. This command is available starting with Pyomo version 5.1. Prior to version 5.1, the same functionality was available via the command pysp2smps (starting at Pyomo version 4.2).

    SMPS is a standard for expressing stochastic mathematical programs that is based on the ancient MPS format for linear programs, which is matrix-based. Modern algebraic modeling languages such as Pyomo offer a lot of flexibility so it is a challenge to take models expressed in Pyomo/PySP and force them into SMPS format. The conversions can be inefficient and error prone because Pyomo allows flexible expressions and model construction so the resulting matrix may not be the same for each set of input data. We provide tools for conversion to SMPS because some researchers have tools that read SMPS and exploit its limitations on problem structure; however, the user should be aware that the conversion is not always possible.".

  • GNU Octave is open source software and like Matlab it has a function called mpsread.

Some information about the MPS file format is contained at miplib3, Gurobi, the MOSEK Python API manual, and the Wolfram Language and System Documentation Center.

| improve this answer | |

Your Answer

