[go: up one dir, main page]

0% found this document useful (0 votes)
96 views6 pages

Linear Programming With Matlab: Z 150x 175x 150x 175x

The document describes using the Matlab function LINPROG to solve linear programming problems. LINPROG can minimize an objective function subject to inequality and equality constraints. Two examples are provided, where LINPROG is used to find the optimal solution for problems involving minimizing/maximizing objectives subject to multiple constraints. The inputs and outputs of LINPROG are defined, and the solutions obtained from Matlab are verified with graphical representations of the problems.

Uploaded by

suquillop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views6 pages

Linear Programming With Matlab: Z 150x 175x 150x 175x

The document describes using the Matlab function LINPROG to solve linear programming problems. LINPROG can minimize an objective function subject to inequality and equality constraints. Two examples are provided, where LINPROG is used to find the optimal solution for problems involving minimizing/maximizing objectives subject to multiple constraints. The inputs and outputs of LINPROG are defined, and the solutions obtained from Matlab are verified with graphical representations of the problems.

Uploaded by

suquillop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Chapter 8

Linear Programming with Matlab

The Matlab function LINPROG can be used to solve a linear programming problem with the
following syntax (help LINPROG):

X=LINPROG(f, A, b) solves the linear programming problem:

min f'*x subject to: A*x <= b

X=LINPROG(f, A, b, Aeq, beq) solves the problem above while additionally satisfying the
equality constraints Aeq*x = beq.

X=LINPROG(f, A, b, Aeq, beq, LB, UB) defines a set of lower and upper bounds on the
design variables, X, so that the solution is in the range LB <= X <= UB. Use empty matrices
for LB and UB if no bounds exist. Set LB(i) = -Inf if X(i) is unbounded below; set UB(i) =
Inf if X(i) is unbounded above.

Since LINPROG minimizes an objective function, the example 3.2-1 is reformulated as

Minimize z = − 150x1 − 175x2

Note: Maximizing (150x1 + 175x2) is equivalent to minimizing (− 150x1 − 175x2)

Subject to

7x1 + 11x2 ≤ 77 (material constraint)


10x1 + 8x2 ≤ 80 (time constraint)
x1 ≤ 9 (storage constraint of regular heating gas)
x2 ≤ 6 (storage constraint of premium heating gas)
x1 , x2 ≥ 0 (positive production constraint)

The coefficient vector f for the objective function is

 − 150
f=  
 − 175

The matrix coefficient A for the inequality constraints is

 7 11
A=  
10 8 

8-9
The right hand vector b for the inequality constraints is

77
b=  
80

Since there are no equality constraints in this example, Aeq and beq are zeros.

0 0  0
Aeq =   and beq =  
0 0  0

The lower and upper bounds vectors are given by

 0 9 
LB =   and UB = 6
 0  

The following Matlab statements are used to solve this linear programming problem.

Matlab Example -----------------------------------------------------

% Example 8.3-1
f=[-150;-175];
A=[7 11;10 8];
b=[77;80];
Aeq=[0 0;0 0];
beq=[0;0];
LB=[0;0];UB=[9;6];
x=linprog(f,A,b,Aeq,beq,LB,UB)

>> e3d2d1
Optimization terminated successfully.
x=
4.8889
3.8889
-------------------------------------------------------------------------------------------------------------
Example 8.3-2 ----------------------------------------------------------------------------------
Solve the following linear programming problem using Matlab LINPROG

Maximize y = x1 + 2x2

Subject to

2x1 + x2 ≤ 10
x1 + x2 ≤ 6
− x1 + x2 ≤ 2
− 2x1 + x2 ≤ 1
x1 , x2 ≥ 0

8-10
Solution ------------------------------------------------------------------------------------------

The problem is reformulated using slack variable S1, S2, S3, and S4

Minimize y = − x1 − 2x2

Subject to

2x1 + x2 + S1 = 10
x1 + x2 + S2 = 6
− x1 + x2 + S3 = 2
− 2x1 + x2 + S4 = 1
x1, x2, S1, S2, S3, and S4 ≥ 0

The arguments for the Matlab command X=LINPROG(f, A, b, Aeq, beq, LB, UB) are given
as
 − 1  2 1 1 0 0 0 10  0 ∞
 − 2  1 1 0 1 0 0 6  0 ∞
         
 0  − 1 1 0 0 1 0 2  0 ∞
f =   , A = 0, b = 0, Aeq =   , beq =   , LB =   , UB =  
 0  − 2 1 0 0 0 1 2  0 ∞
 0  0 0 0 0 0 0 0  0 ∞
         
 0  0 0 0 0 0 0 0  0 ∞

The following Matlab statements are used to solve this linear programming problem.

Matlab Example -----------------------------------------------------

% Example 8.3-2
f=[-1;-2;0;0;0;0];
A=zeros(6,6);
b=zeros(6,1);
Aeq=[2 1 1 0 0 0;1 1 0 1 0 0; -1 1 0 0 1 0;-2 1 0 0 0 1;0 0 0 0 0 0;0 0 0 0 0 0];
beq=[10;6;2;1;0;0];
LB=[0;0;0;0;0;0];UB=[inf;inf;inf;inf;inf;inf];
x=linprog(f,A,b,Aeq,beq,LB,UB)

>> e8d3d2
Optimization terminated successfully.
x=
2.0000
4.0000
2.0000
0.0000
0.0000
1.0000
------------------------------------------------------------------------------

8-11
The solution from the Matlab program is

x1 = 2

x2 = 4

S1 = 2

S2 = 0

S3 = 0

S4 = 1

This solution is verified with the graphical solution shown in Figure 8.3-2. The vertex D is
the basic feasible solution obtained graphically.

x2 2x1 + x2 = 10
-2x1 + x2 = 1
8
-x1 + x2 = 2

4
D
C
E
Feasible
Region x 1 + x2 = 6
B
A
4 F 8 x
1
Figure 8.3-2 Geometric representation of the linear programming problem.

The problem can also be reformulated using only one slack variable S1

Minimize y = − x1 − 2x2

Subject to

2x1 + x2 + S1 = 10
x1 + x2 ≤ 6
− x1 + x2 ≤ 2
− 2x1 + x2 ≤ 1
x1, x2, and S1≥ 0

8-12
Consider the Matlab command X=LINPROG(f, A, b, Aeq, beq, LB, UB). The coefficient
vector f for the objective function is

 − 1
f =  − 2
 
 0 

The matrix coefficient A for the inequality constraints is

 1 1 0
A =  − 1 1 0
 
 − 2 1 0

The right hand vector b for the inequality constraints is

 6
b =  2
 
1

The equality constraints Aeq and beq are given as

 2 1 1 10
Aeq = 0 0 0 and beq = 0
   
0 0 0  0 

The lower and upper bounds vectors are given by

 0 ∞
LB = 0 and UB = ∞
   
0 ∞

The following Matlab statements are used to solve this linear programming problem.

% Example 8.3-2b
f=[-1;-2;0];
A=[1 1 0;-1 1 0;-2 1 0];
b=[6;2;1];
Aeq=[2 1 1; 0 0 0;0 0 0];
beq=[10;0;0];
LB=[0;0;0];UB=[inf;inf;inf];
x=linprog(f,A,b,Aeq,beq,LB,UB)

>> e8d3d2b

8-13
Optimization terminated successfully.
x=
2.0000
4.0000
2.0000

The solution from the Matlab program is

x1 = 2

x2 = 4

S1 = 2

------------------------------------------------------------------------------------------------------

8-14

You might also like