Engineering Optimization: Theory and Practice, Fourth Edition

(Martin Jones) #1
3.11 MATLAB Solution of LP Problems 157

4 x 1 +x 2 +x 3 ≤ 6
xi≥ 0 ; i= 1 , 2 , 3

SOLUTION

Step 1Express the objective function in the formf (x)=fTx nd identify the vectorsa
xandf as

x=




x 1
x 2
x 3




and f=




− 1

− 2

− 1




Express the constraints in the formAx≤band identify the matrixAand the
vectorbas

A=



2 1− 1

2 −1 5

4 1 1


 and b=




2

6

6




Step 2Use the command for executing linear programming program using simplex
method as indicated below:
clc
clear all
f=[-1;-2;-1];
A=[2 1 - 1;
2 -1 5;
4 1 1];
b=[2;6;6];
lb=zeros(3,1);
Aeq=[];
beq=[];
options = optimset('LargeScale', 'off', 'Simplex', 'on');


  • [x,fval,exitflag,output] = linprog(f,A,b,Aeq,beq,lb,[],[],
    optimset('Display','iter'))


This produces the solution or output as follows:

Optimization terminated.
x=
0
4
2
fval =
-10
exitflag =
1
output =
iterations:3
algorithm: 'medium scale: simplex'
Free download pdf