Adding a constraint to "linprog" matlab example

2 次查看(过去 30 天)
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

回答(1 个)

Matt J
Matt J 2014-8-14
编辑:Matt J 2014-8-14
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 个评论
Gimpy
Gimpy 2014-8-14
sorry it's not clear. The answer I'm looking for is the xi but I want it to satisfy my new condition. In that case I don't know how to specify my new constraint.
Matt J
Matt J 2014-8-14
编辑:Matt J 2014-8-14
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by