how can i solve this with linprog command?
Afficher commentaires plus anciens
Hey there, need some help with the linprog command. im trying to solve this
max =(7x1+7x2+6x3+9x4)
4x1+5x2+3x3+3x4<=30000
2x1+1.5x2+3x3+3x4<=22000
x1,x2,x3,x4<=0
i tried this:
f = [7 7 6 9];
A = [4 5 3 3;2 1.5 3 3];
b = [30000 22000];
lb = [0 0 0 0];
x = linprog(f,A,b,[],[],lb)
Réponses (1)
John D'Errico
le 6 Sep 2016
I'm confused. If you want to see:
x1,x2,x3,x4<=0
then why in the name of god and little green apples would you set a LOWER bound of all zeros?
lb = [0 0 0 0];
To me, this seems like a problem for an UPPER bound, not a lower bound.
Yes, I know that you are thinking you want to maximize. That is NOT the way to do it.
Instead, you need to negate the objective function.
f = -[7 7 6 9];
A = [4 5 3 3;2 1.5 3 3];
b = [30000;22000];
lb = [];
ub = [0 0 0 0]
x = linprog(f,A,b,[],[],lb,ub)
Optimization terminated.
x =
-4.5475e-13
0
0
0
It should be no surprise at all that the solution which MAXIMIZES f'*x for non-positive x is essentially x=zeros(4,1).
2 commentaires
Alvaro Vuyk
le 6 Sep 2016
John D'Errico
le 6 Sep 2016
Modifié(e) : John D'Errico
le 6 Sep 2016
So then what is the problem?
f = -[7 7 6 9];
lb = [0 0 0 0];
x = linprog(f,A,b,[],[],lb,[])
Optimization terminated.
x =
2.4596e-06
2285.7
7.0595e-06
6190.5
You maximize using a minimization tool by negating the objective.
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!