Effacer les filtres
Effacer les filtres

How to run please this example perfectly to get optimal solution .. Thank you

1 vue (au cours des 30 derniers jours)
f = [0 ; - 10 ; 0 ; - 6; - 20] ;
A = [1 0 0 0 0 ;
0 1 0 0 0 ;
0 0 1 0 0 ;
0 0 0 1 0 ;
0 0 0 0 1] ;
B = [4 ; 3 ; 3 ; 2 ; 2] ;
Aeq = [1 - 1 - 1 0 0 ; 0 0 1 - 1 - 1] ;
beq = [0; 0; 0; 0; 0];
lb = zeros (5, 1) ;
ub = zeros (5, 1) ;
x = linprog(f,A,B,Aeq,beq,lb,ub)
[x,fval] = linprog(f,A,Aeq,beq,lb,ub);

Réponse acceptée

Steven Lord
Steven Lord le 4 Mai 2023
lb = zeros (5, 1) ;
ub = zeros (5, 1) ;
So based on the way you've constructed the bounds, all the elements of your solution have to be greater than or equal to 0 and less than or equal to 0. The only possible solution that satisfies both sets of bounds is zeros(5, 1).
Are you sure that ub shouldn't be something like ones(5, 1)?
  7 commentaires
Steven Lord
Steven Lord le 4 Mai 2023
Yes, I saw that. I would have expected them also to appear in the "Therefore, the problem can be posed as the following linear program:" section as inequalities like the last three bound constraints. But due to a lack of space on the page I wonder if students solving the problem could overlook the last two equations (which I assumed appeared after the diagram on page 262.)
Dalia ElNakib
Dalia ElNakib le 6 Mai 2023
Many Thanks for your clarifications.
Really appreciate your efforts.

Connectez-vous pour commenter.

Plus de réponses (1)

Torsten
Torsten le 4 Mai 2023
f = [0 ; -10 ; 0 ; -6; -20] ;
A = [1 0 0 0 0 ;
0 1 0 0 0 ;
0 0 1 0 0 ;
0 0 0 1 0 ;
0 0 0 0 1] ;
B = [4 ; 3 ; 3 ; 2 ; 2] ;
Aeq = [1 -1 -1 0 0 ; 0 0 1 -1 -1] ;
beq = [0; 0];
lb = zeros (5, 1) ;
ub = zeros (5, 1) ;
[x,fval] = linprog(f,A,B,Aeq,beq,lb,ub)
Optimal solution found.
x = 5×1
0 0 0 0 0
fval = 0
  2 commentaires
Dalia ElNakib
Dalia ElNakib le 4 Mai 2023
f = [0 ; -10 ; 0 ; -6; -20] ;
A = [1 0 0 0 0 ;
0 1 0 0 0 ;
0 0 1 0 0 ;
0 0 0 1 0 ;
0 0 0 0 1] ;
B = [4 ; 3 ; 3 ; 2 ; 2] ;
Aeq = [1 -1 -1 0 0 ; 0 0 1 -1 -1] ;
beq = [0; 0];
lb = zeros (5, 1) ;
ub = ones(5, 1);
[x,fval] = linprog(f,A,B,Aeq,beq,lb,ub);
Optimal solution found.
Dalia ElNakib
Dalia ElNakib le 4 Mai 2023
Modifié(e) : Dalia ElNakib le 4 Mai 2023
Thank you so much
Both work to ge the optimal solution
Either:
lb = zeros (5, 1) ;
ub = zeros (5, 1) ;
Or
lb = zeros (5, 1) ;
ub = ones (5, 1) ;
f = [0 ; -10 ; 0 ; -6; -20] ;
A = [1 0 0 0 0 ;
0 1 0 0 0 ;
0 0 1 0 0 ;
0 0 0 1 0 ;
0 0 0 0 1] ;
B = [4 ; 3 ; 3 ; 2 ; 2] ;
Aeq = [1 -1 -1 0 0 ; 0 0 1 -1 -1] ;
beq = [0; 0];
lb = zeros (5, 1) ;
ub = zeros(5, 1);
[x,fval] = linprog(f,A,B,Aeq,beq,lb,ub);
Optimal solution found.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with Optimization Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by