Adding a constraint to "linprog" matlab example
Afficher commentaires plus anciens
HI, I'm working on the following example from matlab:
Find x that minimizes
f(x) = –5x1 – 4x2 –6x3,
subject to
x1 – x2 + x3 ≤ 20
3x1 + 2x2 + 4x3 ≤ 42
3x1 + 2x2 ≤ 30
0 ≤ x1, 0 ≤ x2, 0 ≤ x3.
First, enter the coefficients
f = [-5; -4; -6];
A = [1 -1 1
3 2 4
3 2 0];
b = [20; 42; 30];
lb = zeros(3,1);
Next, call a linear programming routine.
[x,fval,exitflag,output,lambda] = linprog(f,A,b,[],[],lb);
Here's my question: Iwould like to ad a new constraint:
x1= a+ b
x2= c+ d
x3= c+ e
The new constraint would be
14 ≤ a, 14 ≤ b, 14 ≤ c, 14 ≤ d
This mean that the previous answer:
x =
0.0000
15.0000
3.0000
Would not be ok since C=18 which is >14 in that case(meaning that linproog need to take into account the sum of A,B,C,D when he propose a solution for X)
Any Idea?
Thank you
Réponses (1)
It's just a linear change of variables. If you make the substitutions
x1= a+ b
x2= c+ d
x3= c+ e
in your original constraint inequalities (and objective function), you will get a new linear program in terms of a new unknown vector [a,b,c,d,e]. You can also add any further constraints on [a,b,c,d,e]that you like.
2 commentaires
Gimpy
le 14 Août 2014
Once you've transformed the linear program as I described above and solved for a,b,c,d,e you can recover the corresponding xi using the transformation equations,
x1= a+ b
x2= c+ d
x3= c+ e
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!