Dual problem and primal problem unbounded linear programming
Hello,
I need some help please to solve this problem I have . I have solved a max. problem , the primal problem , by using linprog.
After this , I have done the dual problem of the primal. After this proccess, I don’t get the result that I should get , because the values of F0 should be the same in both cases(if I am not wrong).
I am sending the illustrated problem and code below. I hope someone can give me a help.
thank you !
Max 300π₯1 + 400π₯2
π₯1 + π₯2 β€ 320
4π₯1 + 5π₯2 β€ 510
2π₯1 + 3π₯2 β€ 430
3π₯1 + π₯2 β€ 300
π₯1,π₯2 β₯ 0
The Dual Problem
Min 320π¦1 + 510π¦2 + 430π¦3 + 300π¦4
π¦1 + 4π¦2 + 2π¦3 + 3π¦4 β₯ 300
4π¦1 + 5π¦2 + 3π¦3 + π¦4 β₯ 400
π¦1,π¦2,π¦3,π¦4 β₯ 0
Matlab Code:
%Primary Problem
%Ax<=b
%coefficients of A
A = [1 4; 4 5; 2 3; 3 1];
%coefficients of B
b = [320 510 430 300];
%coefficients of the objective function
f = [300 400];
%The maximation of the linear function using the matlab linear
%programming function
[x0,F0] = linprog(-f,A,b,[],[],[0 0])
% disp(‘x0 = ‘)
% disp(x0);
%——————————————————————
%Dual problem
%coefficients of AT
AT = [1 4 2 3;
4 5 3 1];
%coefficients of u
u = [300 400];
g = [320 510 430 300];
%setting a lower bounder
lb = zeros(1,4);
%setting an upper bounder
ub=[];
[u0,F0] = linprog(g,-AT,-u,[],[],lb,ub)
% disp(‘u0 = ‘);
% disp(u0);
%So,1st and 2nd constrains of the primary problem are active
%because u0 = [9.0909
% 72.7273
% 0
% 0]
%Solutions of Primary problem throug the dual problem
syms x1 x2
eqns = [x1 + x2 == 320, 4*x1 + 5*x2 == 510];
S = solve(eqns,[x1 x2]);
b = [S.x1 S.x2];
disp(‘Values of x ‘)
disp(b);
duality_gap = [x0(1)-u0(1); x0(2)-u0(2)]Hello,
I need some help please to solve this problem I have . I have solved a max. problem , the primal problem , by using linprog.
After this , I have done the dual problem of the primal. After this proccess, I don’t get the result that I should get , because the values of F0 should be the same in both cases(if I am not wrong).
I am sending the illustrated problem and code below. I hope someone can give me a help.
thank you !
Max 300π₯1 + 400π₯2
π₯1 + π₯2 β€ 320
4π₯1 + 5π₯2 β€ 510
2π₯1 + 3π₯2 β€ 430
3π₯1 + π₯2 β€ 300
π₯1,π₯2 β₯ 0
The Dual Problem
Min 320π¦1 + 510π¦2 + 430π¦3 + 300π¦4
π¦1 + 4π¦2 + 2π¦3 + 3π¦4 β₯ 300
4π¦1 + 5π¦2 + 3π¦3 + π¦4 β₯ 400
π¦1,π¦2,π¦3,π¦4 β₯ 0
Matlab Code:
%Primary Problem
%Ax<=b
%coefficients of A
A = [1 4; 4 5; 2 3; 3 1];
%coefficients of B
b = [320 510 430 300];
%coefficients of the objective function
f = [300 400];
%The maximation of the linear function using the matlab linear
%programming function
[x0,F0] = linprog(-f,A,b,[],[],[0 0])
% disp(‘x0 = ‘)
% disp(x0);
%——————————————————————
%Dual problem
%coefficients of AT
AT = [1 4 2 3;
4 5 3 1];
%coefficients of u
u = [300 400];
g = [320 510 430 300];
%setting a lower bounder
lb = zeros(1,4);
%setting an upper bounder
ub=[];
[u0,F0] = linprog(g,-AT,-u,[],[],lb,ub)
% disp(‘u0 = ‘);
% disp(u0);
%So,1st and 2nd constrains of the primary problem are active
%because u0 = [9.0909
% 72.7273
% 0
% 0]
%Solutions of Primary problem throug the dual problem
syms x1 x2
eqns = [x1 + x2 == 320, 4*x1 + 5*x2 == 510];
S = solve(eqns,[x1 x2]);
b = [S.x1 S.x2];
disp(‘Values of x ‘)
disp(b);
duality_gap = [x0(1)-u0(1); x0(2)-u0(2)]Β Hello,
I need some help please to solve this problem I have . I have solved a max. problem , the primal problem , by using linprog.
After this , I have done the dual problem of the primal. After this proccess, I don’t get the result that I should get , because the values of F0 should be the same in both cases(if I am not wrong).
I am sending the illustrated problem and code below. I hope someone can give me a help.
thank you !
Max 300π₯1 + 400π₯2
π₯1 + π₯2 β€ 320
4π₯1 + 5π₯2 β€ 510
2π₯1 + 3π₯2 β€ 430
3π₯1 + π₯2 β€ 300
π₯1,π₯2 β₯ 0
The Dual Problem
Min 320π¦1 + 510π¦2 + 430π¦3 + 300π¦4
π¦1 + 4π¦2 + 2π¦3 + 3π¦4 β₯ 300
4π¦1 + 5π¦2 + 3π¦3 + π¦4 β₯ 400
π¦1,π¦2,π¦3,π¦4 β₯ 0
Matlab Code:
%Primary Problem
%Ax<=b
%coefficients of A
A = [1 4; 4 5; 2 3; 3 1];
%coefficients of B
b = [320 510 430 300];
%coefficients of the objective function
f = [300 400];
%The maximation of the linear function using the matlab linear
%programming function
[x0,F0] = linprog(-f,A,b,[],[],[0 0])
% disp(‘x0 = ‘)
% disp(x0);
%——————————————————————
%Dual problem
%coefficients of AT
AT = [1 4 2 3;
4 5 3 1];
%coefficients of u
u = [300 400];
g = [320 510 430 300];
%setting a lower bounder
lb = zeros(1,4);
%setting an upper bounder
ub=[];
[u0,F0] = linprog(g,-AT,-u,[],[],lb,ub)
% disp(‘u0 = ‘);
% disp(u0);
%So,1st and 2nd constrains of the primary problem are active
%because u0 = [9.0909
% 72.7273
% 0
% 0]
%Solutions of Primary problem throug the dual problem
syms x1 x2
eqns = [x1 + x2 == 320, 4*x1 + 5*x2 == 510];
S = solve(eqns,[x1 x2]);
b = [S.x1 S.x2];
disp(‘Values of x ‘)
disp(b);
duality_gap = [x0(1)-u0(1); x0(2)-u0(2)]Β optimization, linprogΒ MATLAB Answers β New Questions
β