Variable f coeffficient depends on x for linprog

조회 수: 1 (최근 30일)
Ahmet Dogan
Ahmet Dogan 2022년 5월 4일
댓글: Torsten 2022년 5월 27일
I have a minimization problem and I wonder that if i can solve the problem with linprog or how can i solve within matlab framework?
E.g. f= [f(1) f(2)]; x = linprog(f,A,b,Aeq,beq);
In that problem i have variable f coefficient depend on x value. f(1)=0, if x(1)<0 / f(1)=50, if x(1)>0 .
How can i solve this minimization problem?
  댓글 수: 5
Ahmet Dogan
Ahmet Dogan 2022년 5월 27일
편집: Ahmet Dogan 2022년 5월 27일
Thank you for your helps in advance. I just solved the problem using nonlinear inequality constraints as follows;
x(1)+x(2) >= 250
x(1)+x(2)+x(3) >= 250
....
x(1)+x(2)+x(3)+...+x(71)>=250
x(1)+x(2) <= 1000
x(1)+x(2)+x(3) <= 1000
.....
x(1)+x(2)+x(3)+...+x(71) <= 1000
x(1)+x(2)+x(3)+y(1)+y(2)+y(3)+...x(71)+y(72)=1000
Following constarints provide that only positive values are added to cost function while positive and negative values can be used for constraints.
x(1)*x(37)=0; at less one of the variables should be zero.
....
x(36)*x(72)=0;
lb=[0] ub=[250] for x(1)....x(36)
lb=[-250] ub=[0] for x(37)....x(72)
c = [x(1)*x(37);
(x(2)*x(38);
. . .
x(36)*x(72);
];
f_con = [0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.27 0.27 0.27 0.29 0.29 0.29 0.29 0.30 0.30 0.30 0.30 0.30 0.30 0.30 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.27 0.27];
fobj= x(1)*f_con(1)+ ...+x(36)*f_con(36)
Torsten
Torsten 2022년 5월 27일
Sorry, but I don't see the equivalence of your original problem and the one you write above.
Even if they were: I don't understand why you choose such a complicated non-linear reformulation. The linear approach I suggested is simple and elegant if your f-vector only has non-negative entries.

댓글을 달려면 로그인하십시오.

답변 (2개)

Bruno Luong
Bruno Luong 2022년 5월 4일
Solve 2 problems
f= [0 f2]; x = linprog(f,A,b,Aeq,beq,lb1,up1); with lb1 = -inf(size(x)), up1 = zeros(size(x));
g= [50 f2]; x = linprog(g,A,b,Aeq,beq,lb2,up2); with lb2 = zeros(size(x)), up2 = inf(size(x));
Then pick the best solution
  댓글 수: 2
Ahmet Dogan
Ahmet Dogan 2022년 5월 4일
편집: Torsten 2022년 5월 4일
Thank you for the answer but I had simplified the question. In my main problem, I have 36 x variables with equality and inequality constraints.
Some of my inequality constraints
x(1)+x(2)>250
x(1)+x(2)+x(3)>250
....
x(1)+x(2)+x(3)+...x(35)>250
x(1)+x(2)<1000
x(1)+x(2)+x(3)<1000
.....
x(1)+x(2)+x(3)+...x(35)<1000
Equality constraints
x(1)+x(2)+x(3)+...x(36)=1000
lb=-250
ub=250
f_con=[0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.27 0.27 0.27 0.29 0.29 0.29 0.29 0.30 0.30 0.30 0.30 0.30 0.30 0.30 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.26 0.27 0.27];
f(i)=f_con(i) if x(i)>0
f(i)=0 if x(i)<0
According to that some of x variables should be less than zero and some of them should be greter than zero. So, I think I need a combined solution.
Alan Weiss
Alan Weiss 2022년 5월 4일
I think that you can do what you want using binary indicator variables for each condition as described in Integer and Logical Modeling. This involves creating new binary variables and new constraints based on the Big-M formulation, and then using intlinprog to solve the resulting problem.
Alan Weiss
MATLAB mathematical toolbox documentation

댓글을 달려면 로그인하십시오.


Torsten
Torsten 2022년 5월 4일
According to that some of x variables should be less than zero and some of them should be greter than zero. So, I think I need a combined solution.
Add new variables
y(i) (i=1,...,36)
and constraints
y(i) >= x(i)
y(i) >= 0
and define the objective as
f_con*y
For the interpretation:
y(i) = max(x(i),0)
  댓글 수: 4
Torsten
Torsten 2022년 5월 7일
편집: Torsten 2022년 5월 7일
My reformulation would be:
min: y1 - y2
x1 + x2 = 1
y1 >= x1
y2 >= x2
y1 >= 0
y2 >= 0
This problem is also unbounded :
y1 = 0, y2 = +Inf, x1 = 0, x2 = 1
But I didn't think in depth if this reformulation is always correct if f has negative components.
Maybe one can find a counterexample.
Bruno Luong
Bruno Luong 2022년 5월 7일
편집: Bruno Luong 2022년 5월 7일
I guess you get an idea, if I change A and b to
A = (-1,0)
b = 10;
(x >= -10 if you will) and keep the rest identical,
now your problem is unbounded and the original problem is not. Fact is the halfspace { x1 <= 0 } won't be capture by you refomulation by working on other half-space halfspace { x1 >= 0 } alone.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver-Based Optimization Problem Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by