Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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);

Risposta accettata

Steven Lord
Steven Lord il 4 Mag 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 Commenti
Steven Lord
Steven Lord il 4 Mag 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.)

Accedi per commentare.

Più risposte (1)

Torsten
Torsten il 4 Mag 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 Commenti
Dalia ElNakib
Dalia ElNakib il 4 Mag 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 il 4 Mag 2023
Modificato: Dalia ElNakib il 4 Mag 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.

Accedi per commentare.

Categorie

Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by