In this example we solve the following sample problem from MATLAB’s documentation page on the linprog function.
Find x that minimizes
f(x) = –5x1 – 4x2 –6x3,
subject to
x1 – x2 + x3 ≤
20
3x1 +
2x2 + 4x3 ≤
42
3x1 +
2x2 ≤ 30
0
≤ x1, 0 ≤ x2,
0 ≤ x3.
First, enter the coefficients:
>> f = [-5; -4; -6]; >> A = [1 -1 1 >> 3 2 4 >> 3 2 0]; >> b = [20; 42; 30]; >> lb = zeros(3,1);
Next, call the Xpress Optimizer linear programming optimization function xprslp.
>> [x,fval,exitflag,output,lambda] = xprslp(f,A,b,'L',lb);
Entering x, lambda.lin, and lambda.lower returns the following results:
x =
0.0000
15.0000
3.0000
lambda.lin =
0
1.5000
0.5000
lambda.lower =
1.0000
0
0