cant use linprog for maximize
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ivan
am 6 Dez. 2014
Bearbeitet: John D'Errico
am 6 Dez. 2014
I have my function fx= -0.818x1 + 0.241x2 + 4.737x3 + 0.2x4 + 0.483x5 - 0.02x6 + 0.06x7. And I have some constrains: 1. fx cant be larger than 100
2. 22=<x1=<40
3. 52=<x2=<80
4. 3.5=<x3=<5.9
5. 12=<x4=<22
6. 105=<x5=<150
7. 300=<x6=<700
8. 800=<x7=<1200
9. x4+x3=21
10. x5-x2=50
Please, show me the code of this optimization.
0 Kommentare
Akzeptierte Antwort
John D'Errico
am 6 Dez. 2014
Isn't this basically the same question you asked before? You have added a couple of equality constraints only.
I won't even bother to copy over the rest of your code from your last question. Just pass in these additional two variables now into linprog (where you previously passed in [] as placeholders when you had no equality constraints.)
Aeq = [0 0 1 1 0 0 0;0 -1 0 0 1 0 0];
beq = [21;50];
2 Kommentare
John D'Errico
am 6 Dez. 2014
Bearbeitet: John D'Errico
am 6 Dez. 2014
READ THE HELP!!!!!!! I'll paste in the relevant lines...
min f'*x subject to: A*x <= b
x
You changed the sign of f, ONLY because you wanted to maximize the function, not minimize. That changes nothing else though.
However, if you pass in -A and -b, then do you think that you will actually be trying to solve the problem
-A*x <= -b
which is equivalent to
A*x >= b
It seems to me that would not be solving the problem you have posed.
READ THE HELP! THINK!
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!