import an MPS data file
ImportMPS(filename, maxm, maxn, lowbnd, upbnd, opts)
string; name of the MPS(X) data file
(optional) maximal number of linear constraints to allow
(optional) maximal number of variables to allow
(optional) value to use for lower bound on variables
(optional) value to use for upper bound on variables
(optional) equations of the form option=value where option is one of objectivename, rhsname, rangename or boundsname; specify options for the ImportMPS command
The Optimization[ImportMPS] command imports a linear program (LP) or mixed integer linear program (MILP) from a standard MPS(X) data file. The results are an expression sequence, part of which is a combined Matrix and Vector representation of the LP or MILP. This form of the problem may be sent directly to the linear programming solver Optimization[LPSolve], using the Matrix-form representation described in Optimization[LPSolve] (MatrixForm).
The first parameter filename is the name or location of the MPS(X) data file, as a string. The ImportMPS command looks first for filename as an absolute location reference, and if not found looks second for filename as a relative location reference. ImportMPS respects the current working directory, as supported by the currentdir command, for a relative location reference.
The second parameter maxm is a limit on how many linear constraint equations may be read from the data file. The default value for maxm is 50.
The third parameter maxn is a limit on how many variables may be read from the data file. The default value for maxn is 50.
The fourth parameter lowbnd is a floating-point value which sets the lower bound to use when none is given in any bounds section of the MPS data file. The default value is -1.0e21 . Another common choice for lowbnd is 0.0, for a problem in which only non-negative values for the variables are to be allowed.
The fifth parameter upbnd is a floating-point value that sets the upper bound to use when none is given in any bounds section of the MPS data file. The default value is 1.0e21 .
The second to fifth parameters are positionally optional, in the following sense. The first integer in the parameter sequence will be taken as maxm and the second as maxn. The first floating-point value in the parameter sequence will be taken as lowbnd and the second as upbnd.
The opts argument can contain one or more of the options shown below.
objectivename=objname -- Use the objective function with name objname where objname is a string. The default value of objname is the empty string, in which case, the first objective function detected in the data file will be used.
rhsname=RHSname -- Use the right-hand-side definition with name RHSname where RHSname is a string. The default value of RHSname is the empty string, in which case, the first right-hand-side definition detected in the data file will be used.
rangename=rngname -- Use the range definition with name rngname, where rngname is a string. The default value of rngname is the empty string, in which case, the first range detected in the data file will be used.
boundsname=bndname -- Use the bounds definition with name bndname, where bndname is a string. The default value of bndname is the empty string, in which case, the first set of bounds detected in the data file will be used.
In the most general case, the returned result is an expression sequence: sprob, cvec, A, b, Aeq, beq, bl, bu, x, intvar, where the individual items in the sequence are described below. For a description of the Matrix form of representation of an LP, see Optimization[LPSolve] (MatrixForm) or Optimization/MatrixForm.
The object sprob is a string containing the problem name found in the data file.
The object cvec is a Vector specifying the coefficients of the linear objective function.
The object A is a Matrix specifying the coefficients of the left hand side of the inequality constraints.
The object b is a Vector specifying the coefficients of the right hand side of the inequality constraints.
The object Aeq is a Matrix specifying the coefficients of the left hand side of the equality constraints.
The object beq is a Vector specifying the coefficients of the right hand side of the equality constraints.
The object bl is a Vector of length n specifying lower bounds for the n variables.
The object bu is a Vector of length n specifying upper bounds for the n variables.
The object x is a Vector of length n that may serve as an initial point.
The object intvar is a Vector of length n that denotes which variables must take on strictly integer values. The ith variable attains only integer values if intvar[i] has value 1, and is a continuous variable otherwise.
Although parameters maxm and maxn are optional, ImportMPS will issue an error if it detects more variables or linear constraints in the MPS data file than are allowed by these options.
The following example shows the basic usage of ImportMPS, taking 0.0 and 1.0e21 as the lower and upper bounds, respectively, on the variables.
data ≔ OptimizationImportMPS⁡example01.mps,0.0,1.0⁢1021:
ifnops⁡data=7thensprob,cvec,A,b,bl,bu,x ≔ dataelsesprob,cvec,A,b,Aeq,beq,bl,bu,x ≔ dataend if:sol ≔ Optimization:-LPSolve⁡cvec,A,b,bl,bu
[ 4. ]
[ 0. ]
sol := [92.5000000000000, [ ]]
[ 2. ]
MPSX Mathematical programming system. Program Number 5734 XM4. New York: IBM Trade Corporation, 1971.
Download Help Document
What kind of issue would you like to report? (Optional)