Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

TP en

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Exemple de Minimisation du polycopi� Matlab (en anglais).

Page 1 Le mod�le :
Page 3 & 4 : exemple de minimisation d'un probl�me lin�aire.

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

f = [-5; -4; -6]


A = [1 -1 1
3 2 4
3 2 0];
b = [20; 42; 30];
lb = zeros(3,1);

[x,fval,exitflag,output,lambda] = linprog(f,A,b,[],[],lb)

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

Remarque:
lb = zeros(3,1) est �quivalent � lb = [0; 0;0]

zeros(3,1) : cr�e une matrice de 3 lignes et une colonne remplie de


z�ros.

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

f = [-5; -4; -6]


A = [1 -1 1
3 2 4
3 2 0];
b = [20; 42; 30];
lb = [0; 0;0];

[x,fval,exitflag,output,lambda] = linprog(f,A,b,[],[],lb)

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

Exercice 1 : En s'appuyant sur le mod�le de la commande : linprog


de Matlab, ex�cuter

Z = X1 + 2*X2 + 3*X3 + 4*X4 + 5*X5 + 6*X6 -----> Max ;

5*X1 + 3*X2 + 2*X3 + 4*X4 + 5*X5 + 1*X6 = 2;


0*X1 - 1*X2 + 2*X3 + 1*X4 + 4*X5 + 5*X6 = 2;
2*X1 + 4*X2 + 4*X3 + 5*X4 + 1*X5 + 5*X6 = 3;
6*X1 + 5*X2 + 4*X3 + 3*X4 + 2*X5 + 1*X6 = 4;

(-2 <= x1 <= 2);


(-3 <= x2 <=3)
(-4 <= x3 <=4);
(-5 <= x4 <= 5);
(-6 <= x5 <= 6);
(-7 <= x6 <= 7);
Solution :
-------------------------------------
Max f(x) = - Min -f(x)
x dans D x dans D
-----------------------------------------------------------------------------------
------

f = [ -1 ; -2 ; -3; -4; -5 ; -6 ]

A = [5 3 2 4 5 1
0 -1 2 1 4 5
2 4 4 5 1 5
6 5 4 3 2 1 ];
b = [2; 2; 3 ; 4 ];
lb = [-2; -3; -4 ; -5;-6 ;-7 ];
ub = [2; 3; 4 ; 5;6 ;7 ];
[x,fval,exitflag,output,lambda] = linprog(f,[],[],A ,b,lb,ub)

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

Exercice 2 : En s'appuyant sur le mod�le de la commande : linprog


de Matlab, ex�cuter

Z = X1 + 3*X2 + 5*X3 + 1*X4 + 4*X5 ------> Min;

1*X1 + 1*X2 - 1*X3 + 1*X4 + 0*X5 = 1;


2*X1 + 0*X2 + 4*X3 + 2*X4 + 1*X5 = 7;
1*X1 + 6*X2 + 1*X3 + 0*X4 + 2*X5 = 19;

(0 <= x1 <=2);
(0 <= x2 <=2);
(0 <= x3 <=3);
(0 <= x4 <=3);
(0 <=x5 <= 4);

solution
-----------------------------------------------------------------------------------
----

f = [ 1 ; 3 ; 5; 1; 4 ]

A = [1 1 -1 1 0
2 0 4 2 1
1 6 1 0 2 ];

b = [1 ; 7; 19 ];

lb = [ 0 ; 0 ; 0 ; 0 ; 0 ];
ub = [2; 2; 3 ; 3;4 ];

[x,fval,exitflag,output,lambda] = linprog(f,[],[],A ,b,lb,ub)


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

Exercice 3 : En s'appuyant sur le mod�le de la commande : linprog


de Matlab, ex�cuter

Z = 2*X1 + X2 -----> MIN ;

-2*X1 + 1*X2 <= 1;


1*X1 + 1*X2 <= 3;
0*X1 + 1*X2 <= 2;

X1 >=0; X2 >=0;

solution
-----------------------------------------------------------------------------------
----
f = [ 2; 1]
A = [-2 1
1 1
0 1 ];
b = [1; 3; 2];
lb = zeros(2,1);

[x,fval] = linprog(f,A ,b,[],[],lb)

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

Exercice 4 : En s'appuyant sur le mod�le de la commande : linprog


de Matlab, ex�cuter

Z = 2*X1 + X2 -----> MIN ;

-2*X1 + 1*X2 + 1*X3 + 0*X4 + 0*X5 = 1;


1*X1 + 1*X2 + 0*X3 + 1*X4 + 0*X5 = 3;
0*X1 + 1*X2 + 0*X3 + 0*X4 + 1*X5 = 2;

X1 >=0; X2 >=0; X3 >=0; X4 >=0; X5 >=0;

solution
-------------------------------------------------------------------------------

f = [ 2; 1;0;0;0]
A = [-2 1 1 0 0
1 1 0 1 0
0 1 0 0 1];
b = [1; 3; 2];
lb = zeros(5,1);

[x,fval,exitflag,output,lambda] = linprog(f,[],[],A ,b,lb)

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

You might also like