mpsread

Read MPS file for LP and MILP optimization data

Syntax

Description

example

problem = mpsread(mpsfile) reads data for linear programming (LP) and mixed-integer linear programming (MILP) problems. It returns the data in a structure that the intlinprog or linprog solvers accept.

    Note:   mpsread does not support semicontinuous constraints or SOS constraints.

Examples

collapse all

Import and Run an MPS File

Load an mps file and solve the problem it describes.

Load the eil33.2.mps file from a public repository. View the problem type.

gunzip('http://miplib.zib.de/download/eil33-2.mps.gz')
problem = mpsread('eil33-2.mps')
problem = 

          f: [4516x1 double]
      Aineq: [0x4516 double]
      bineq: [0x1 double]
        Aeq: [32x4516 double]
        beq: [32x1 double]
         lb: [4516x1 double]
         ub: [4516x1 double]
     intcon: [4516x1 double]
     solver: 'intlinprog'
    options: [1x1 optim.options.Intlinprog]

Notice that problem.intcon is not empty, and problem.solver is 'intlinprog'. The problem is an integer linear programming problem.

Change the options to suppress iterative display and to generate a plot as the solver progresses.

options = optimoptions('intlinprog','Display','final','PlotFcns',@optimplotmilp);
problem.options = options;

Solve the problem by calling intlinprog.

[x,fval,exitflag,output] = intlinprog(problem);
Optimal solution found.

Intlinprog stopped because the objective value is within a gap tolerance of the optimal
value, options.TolGapRel = 0.0001 (the default value). The intcon variables are
integer within tolerance, options.TolInteger = 1e-05 (the default value).

Input Arguments

collapse all

mpsfile — Path to MPS filestring

Path to MPS file, specified as a string. mpsfile should be a file in the MPS format.

Example: 'documents/optimization/milpproblem.mps'

Data Types: char

Output Arguments

collapse all

problem — Problem structurestructure

Problem structure, returned as a structure with fields:

fVector representing objective f'*x
intconVector indicating variables that take integer values (empty for LP, nonempty for MILP)
AineqMatrix in linear inequality constraints Aineq*x  bineq

bineq

Vector in linear inequality constraints Aineq*x  bineq

Aeq

Matrix in linear equality constraints Aeq*x = beq

beq

Vector in linear equality constraints Aeq*x = beq
lbVector of lower bounds
ubVector of upper bounds
solver'intlinprog' (if intcon is nonempty), or 'linprog' (if intcon is empty)

options

Default options, as returned by the command
optimoptions(solver)

mpsread returns problem.Aineq and problem.Aeq as sparse matrices.

See Also

|

Introduced in R2015b

Was this topic helpful?