Linear Programming With geq constraints
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Harel Harel Shattenstein
il 16 Apr 2019
Modificato: Torsten
il 16 Apr 2019
I have the following problem:
Max z=4x_1+3x_2
s.t
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/214228/image.png)
Is the following code is correct? as it is geq and not leq:
z = [-4 -3];
A = [-2 -3; 3 -2;0 -2; -2 -1];
b = [-6 -3 -5 -4];
lb = [0 0];
ub = [];
linprog(z,A,b,ub,ub,lb,ub)
0 Commenti
Risposta accettata
John D'Errico
il 16 Apr 2019
Modificato: John D'Errico
il 16 Apr 2019
You switch the sign of a constraint simply by multiplying everything by -1. I thought that was like elementary school math. Did they change something, and put that into graduate level math classes now? ;-)
But this question is confusing.
Reading the help for linprog, we see this:
X = linprog(f,A,b) attempts to solve the linear programming problem:
min f'*x subject to: A*x <= b
So linprog assumes constraints of the form A*x<=b. And that is exactly what your problem formulation states. <= is a LESS THAN OR EQUAL to inequality, NOT GE. The only GE constraints here are the lower bounds.
So it seems you have switched the signs on those inequalties for no good reason.
However, it IS true that linprog is a MINIMIZER, and your question states that you need to maximize z.
Max z=4x_1+3x_2
As such, you did do the correct thing, and switched the signs on z.
0 Commenti
Più risposte (1)
Torsten
il 16 Apr 2019
Modificato: Torsten
il 16 Apr 2019
You will have to invert the signs of all the elements in A and b.
And call linprog as
xopt = linprog(z,A,b,[],[],lb)
And I don't understand why you talk about geq constraints. The constraints in your above problem formulation are leq constraints.
0 Commenti
Vedere anche
Categorie
Scopri di più su Linear Programming and Mixed-Integer Linear Programming 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!