0% found this document useful (0 votes)
41 views13 pages

TP: Optimization Master 1 FMP + CM: Fboumediene@usthb - DZ Faiza - Boumediene@usthb - Edu.dz

The document discusses solving linear programming problems using Matlab. It provides an example of using the linprog function to solve the minimization problem: Min -x1 - 2x2 - x3 Subject to: 2x1 + x2 - x3 ≤ 2 2x1 - x2 + 5x3 ≤ 6 4x1 + x2 + x3 ≤ 6 xi ≥ 0 for i = 1, 2, 3 It also discusses using linprog and graphing to solve other sample linear programming problems. Applications of linear programming to manufacturing problems are presented with an example of maximizing profit by determining the optimal number of two machine parts to produce.

Uploaded by

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

TP: Optimization Master 1 FMP + CM: Fboumediene@usthb - DZ Faiza - Boumediene@usthb - Edu.dz

The document discusses solving linear programming problems using Matlab. It provides an example of using the linprog function to solve the minimization problem: Min -x1 - 2x2 - x3 Subject to: 2x1 + x2 - x3 ≤ 2 2x1 - x2 + 5x3 ≤ 6 4x1 + x2 + x3 ≤ 6 xi ≥ 0 for i = 1, 2, 3 It also discusses using linprog and graphing to solve other sample linear programming problems. Applications of linear programming to manufacturing problems are presented with an example of maximizing profit by determining the optimal number of two machine parts to produce.

Uploaded by

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

University of Science and Technology Houari Boumediene

Faculty of Mechanical Engineering & Process Engineering


Department of Mechanical Construction & Production

TP : Optimization
Master 1 FMP + CM

Pr. F. BOUMEDIENE
Emails:
[email protected]
[email protected]
TP. 2

Linear programming
Matlab help

Linprog: Solve linear programming problems

Linear programming solver


Finds the minimum of a problem specified by

f, x, b, beq, lb, and ub are vectors, and A and Aeq are matrices.

[x,fval] = linprog(f,A,b,Aeq,beq,lb,ub)
Example: Find the solution of the following linear programming problem, using
the simplex method (linprog function of Matlab):

Min f = −x1 − 2x2 − x3


Subject to 2x1 + x2 − x3 ≤ 2
2x1 − x2 + 5x3 ≤ 6
4x1 + x2 + x3 ≤ 6
xi ≥ 0; i = 1, 2, 3
Min ;;
Subject to
Min ;;
Subject to

clc
clear all
C=[-1;-2;-1]; % Linear objective function vector f
A=[2 1 -1; % Matrix for linear inequality constraints
2 -1 5;
4 1 1];
b=[2;6;6]; % Vector for linear inequality constraints
lb=zeros(3,1); % lb Vector of lower bounds
Aeq=[]; % Matrix for linear equality constraints
beq=[]; % beq Vector for linear equality constraints
[x,fval] = linprog(C,A,b,Aeq,beq,lb)
Applications: Solve graphically, and using the “linprog” function, the following linear
programming problems:

Max z = 2x1 + 3x2


Subject to x1 + 3x2 ≤ 6
2x1 + x2 ≤ 4
and x1, x2 ≥ 0

Min z = 3x1 + 4x2


Subject to x1 + 2x2 ≥ 8
3x1 + 3x2 ≥ 15
and x1, x2 ≥ 0

Max z = x1 + 2x2
Subject to x1 + x2 ≥ 4
x1 ≤ 3
and x1, x2 ≥ 0
4

clc 3

clear 2

fplot(@(x) 2-(1/3)*x,[0 5]); 1

hold on
0

Y-axis
-1

fplot(@(x) 4-2*x,[0 5]); -2

fplot(@(x) 1-2/3*x,[0 5],'-.*c') -3

hold off -4

xlabel('X-axis')
-5

-6
ylabel('Y-axis') 0 1 2
X-axis
3 4 5

grid on 1.605

grid minor
1.6

Y-axis
1.595

x =[ 1.2000 ; 1.6000]
fval = 7.2000 (maximum) 1.59

1.585

1.195 1.196 1.197 1.198 1.199 1.2 1.201 1.202 1.203


X-axis
Applications: Solve graphically, and using the “linprog” function, the following linear
programming problems:

Max z = 2x1 + 3x2


x =[ 1.2000 ; 1.6000]
Subject to x1 + 3x2 ≤ 6 fval = 7.2000 (maximum)
2x1 + x2 ≤ 4
and x1, x2 ≥ 0

Min z = 3x1 + 4x2 x=


2
Subject to x1 + 2x2 ≥ 8 3
3x1 + 3x2 ≥ 15 fval = 18

and x1, x2 ≥ 0

Max z = x1 + 2x2
Subject to x1 + x2 ≥ 4 La solution est l’infini

x1 ≤ 3
and x1, x2 ≥ 0
Matlab help

Optimoptions : Create optimization options

options = optimoptions(SolverName,Name,Value)

options = optimoptions(SolverName,Name,Value) returns options with the named


parameters altered with the specified values.

Op = optimoptions(‘linprog’)

Op = optimset(‘linprog’)
Min ;;
Subject to

clc
clear all
close all
C=[-1;-2;-1]; % Linear objective function vector f
A=[2 1 -1; % Matrix for linear inequality constraints
2 -1 5;
4 1 1];
b=[2;6;6]; % Vector for linear inequality constraints
lb=zeros(3,1); % lb Vector of lower bounds
Aeq=[]; % Matrix for linear equality constraints
beq=[]; % beq Vector for linear equality constraints
options = optimoptions('linprog','Algorithm','interior-point','Display','iter')
[x,fval] = linprog(C,A,b,Aeq,beq,lb,[],options)
Example A manufacturing firm produces two machine parts using lathes, milling
machines, and grinding machines. The different machining times required for each
part, the machining times available on different machines, and the profit on each
machine part are given in the following table.

Determine the number of parts I and II to be manufactured per week to maximize


the profit.
SOLUTION :

X: number of machine parts I manufactured per week


y: number of machine parts II manufactured per week
The constraints due to the maximum time limitations on the various machines are given by
10x + 5y ≤ 2500
4x + 10y ≤ 2000
x + 1.5y ≤ 450
x≥0
Since the variables x and y cannot take negative values, we have
y≥0
The total profit is given by f (x, y) = 50x + 100y

Max f (x, y) = 50x + 100y


Subject to 10x + 5y ≤ 2500
4x + 10y ≤ 2000
x + 1.5y ≤ 450
The optimum solution
corresponds to a value of
x∗ = 187.5, y∗ = 125.0
and a profit of $21,875.00.

You might also like