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
This problem in sc50b.mat has 48 variables,
30 inequalities, and 20 equalities.
Use linprog to solve the
problem:
options = optimoptions(@linprog,'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
Residuals: Primal Dual Duality Total
Infeas Infeas Gap Rel
A*x-b A'*y+z-f x'*z Error
---------------------------------------------------
Iter 0: 1.50e+03 2.19e+01 1.91e+04 1.00e+02
Iter 1: 1.15e+02 3.16e-15 3.62e+03 9.90e-01
Iter 2: 9.79e-13 2.62e-15 4.32e+02 9.48e-01
Iter 3: 3.49e-12 5.93e-15 7.78e+01 6.88e-01
Iter 4: 4.86e-11 8.35e-16 2.38e+01 2.69e-01
Iter 5: 2.18e-10 3.39e-16 5.05e+00 6.89e-02
Iter 6: 1.05e-10 9.55e-17 1.64e-01 2.34e-03
Iter 7: 9.43e-12 1.51e-16 1.09e-05 1.55e-07
Iter 8: 1.11e-12 1.68e-16 1.09e-11 1.52e-13
Optimization terminated.For this problem, the interior-point linear programming algorithm
quickly reduces the scaled residuals below the default tolerance of 1e-08.
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.0000
output =
iterations: 8
algorithm: 'interior-point-legacy'
cgiterations: 0
message: 'Optimization terminated.'
constrviolation: 4.8317e-13
firstorderopt: 2.7908e-13