This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Typical Linear Programming Problem

This example shows the solution of a typical linear programming problem. The problem is

minxfTx such that {Axb,Aeqx=beq,x0.

You can load the matrices and vectors A, Aeq, b, beq, f, and the lower bounds lb into the MATLAB® workspace with

load sc50b

The problem in sc50b.mat has 48 variables, 30 inequalities, and 20 equalities.

Use linprog to solve the problem:

options = optimoptions(@linprog,'Algorithm','dual-simplex','Display','iter');
[x,fval,exitflag,output] = ...

Because the iterative display was set using optimoptions, the results displayed are

LP preprocessing removed 2 inequalities, 16 equalities,
16 variables, and 26 non-zero elements.

 Iter      Time            Fval  Primal Infeas    Dual Infeas  
    0     0.001    0.000000e+00   0.000000e+00   1.305023e+00  
    6     0.001   -1.587098e+02   4.008882e+02   0.000000e+00  
   33     0.002   -7.000000e+01   0.000000e+00   0.000000e+00  

Optimal solution found.

The exitflag value is positive, telling you linprog converged. You can also get the final function value in fval and the number of iterations in output.iterations:


exitflag =


fval =


output = 

  struct with fields:

         iterations: 33
    constrviolation: 3.4106e-13
            message: 'Optimal solution found.'
          algorithm: 'dual-simplex'
      firstorderopt: 2.5180e-14
Was this topic helpful?