Main Content

Typical Linear Programming Problem

This example solves the typical linear programming problem


Load the sc50b.mat file, which contains the matrices and vectors A, Aeq, b, beq, f, and the lower bounds lb.

load sc50b

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

    30    48
    20    48

Set options to use the dual-simplex algorithm and the iterative display.

options = optimoptions(@linprog,'Algorithm','dual-simplex','Display','iter');

The problem has no upper bound, so set ub to [].

ub = [];

Solve the problem by calling linprog.

[x,fval,exitflag,output] = ...
LP preprocessing removed 2 inequalities, 16 equalities,
16 variables, and 26 non-zero elements.

 Iter      Time            Fval  Primal Infeas    Dual Infeas  
    0     0.018    0.000000e+00   0.000000e+00   1.305013e+00  
    8     0.042   -1.587073e+02   3.760622e+02   0.000000e+00  
   33     0.045   -7.000000e+01   0.000000e+00   0.000000e+00  

Optimal solution found.

Examine the exit flag, objective function value at the solution, and number of iterations used by linprog to solve the problem.

exitflag = 1
fval = -70
ans = 33

You can also find the objective function value and number of iterations in the iterative display.