Typical Linear Programming Problem
This example solves the typical linear programming problem
Load the sc50b.mat
file, which is available when you run this example and 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.
disp(size(A))
30 48
disp(size(Aeq))
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] = ...
linprog(f,A,b,Aeq,beq,lb,ub,options);
LP preprocessing removed 2 inequalities, 16 equalities, 16 variables, and 26 non-zero elements. Iter Time Fval Primal Infeas Dual Infeas 0 0.011 0.000000e+00 0.000000e+00 9.999644e-01 14 0.029 -1.435826e+02 6.556491e+02 0.000000e+00 33 0.031 -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,fval,output.iterations
exitflag = 1
fval = -70
ans = 33
You can also find the objective function value and number of iterations in the iterative display.