Adding a constraint to "linprog" matlab example

조회 수: 1 (최근 30일)
Gimpy
Gimpy 2014년 8월 14일
편집: Matt J 2014년 8월 14일
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