Adding a constraint to "linprog" matlab example
조회 수: 1 (최근 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
댓글 수: 0
답변 (1개)
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!