TP: Optimization Master 1 FMP + CM: Fboumediene@usthb - DZ Faiza - Boumediene@usthb - Edu.dz
TP: Optimization Master 1 FMP + CM: Fboumediene@usthb - DZ Faiza - Boumediene@usthb - Edu.dz
TP : Optimization
Master 1 FMP + CM
Pr. F. BOUMEDIENE
Emails:
[email protected]
[email protected]
TP. 2
Linear programming
Matlab help
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):
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 = x1 + 2x2
Subject to x1 + x2 ≥ 4
x1 ≤ 3
and x1, x2 ≥ 0
4
clc 3
clear 2
hold on
0
Y-axis
-1
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
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
options = optimoptions(SolverName,Name,Value)
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.