This example shows the solution of a typical linear programming problem. The problem is
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] = ...
linprog(f,A,b,Aeq,beq,lb,[],options);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
exitflag =
1
fval =
-70
output =
struct with fields:
iterations: 33
constrviolation: 3.4106e-13
message: 'Optimal solution found.'
algorithm: 'dual-simplex'
firstorderopt: 2.5180e-14