Typical Linear Programming Problem
R2026bThis 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 sc50bThe 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);Running HiGHS 1.14.0: Copyright (c) 2026 under MIT licence terms
LP has 50 rows; 48 cols; 118 nonzeros
Coefficient ranges:
Matrix [3e-01, 3e+00]
Cost [1e+00, 1e+00]
Bound [0e+00, 0e+00]
RHS [3e+02, 3e+02]
Presolving model
37 rows, 37 cols, 93 nonzeros 0s
21 rows, 21 cols, 63 nonzeros 0s
16 rows, 16 cols, 58 nonzeros 0s
Dependent equations search running on 2 equations with time limit of 1000.00s
Dependent equations search removed 0 rows and 0 nonzeros in 0.00s (limit = 1000.00s)
14 rows, 14 cols, 63 nonzeros 0s
Presolve reductions: rows 14(-36); columns 14(-34); nonzeros 63(-55)
Solving the presolved LP
Using dual simplex solver
Iteration Objective Infeasibilities num(sum)
0 -8.6188182450e-01 Ph1: 10(13.6343); Du: 1(0.861882) 0.0s
17 -7.0000000000e+01 Pr: 0(0) 0.0s
Performed postsolve
Solving the original LP from the solution after postsolve
Model status : Optimal
Simplex iterations: 17
Objective value : -7.0000000000e+01
P-D objective error : 0.0000000000e+00
HiGHS run time : 0.01
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.0000
ans = 17
You can also find the objective function value and number of iterations in the iterative display.