Typical Linear Programming Problem - MATLAB & Simulink (original) (raw)

This example solves the typical linear programming problem

minxfTxsuchthat{A⋅x≤b,Aeq⋅x=beq,x≥0.

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.

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

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 [].

Solve the problem by calling linprog.

[x,fval,exitflag,output] = ... linprog(f,A,b,Aeq,beq,lb,ub,options);

Running HiGHS 1.7.1: Copyright (c) 2024 HiGHS under MIT licence terms 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 19 rows, 19 cols, 61 nonzeros 0s 15 rows, 15 cols, 65 nonzeros 0s 15 rows, 15 cols, 65 nonzeros 0s Presolve : Reductions: rows 15(-35); columns 15(-33); elements 65(-53) Solving the presolved LP Using EKK dual simplex solver - serial Iteration Objective Infeasibilities num(sum) 0 -8.6188168580e-01 Ph1: 10(11.7103); Du: 1(0.861882) 0s 16 -7.0000000000e+01 Pr: 0(0) 0s Solving the original LP from the solution after postsolve Model status : Optimal Simplex iterations: 16 Objective value : -7.0000000000e+01 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

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