Variable f coeffficient depends on x for linprog

2 visualizaciones (últimos 30 días)
Ahmet Dogan
Ahmet Dogan el 4 de Mayo de 2022
Comentada: Torsten el 27 de Mayo de 2022
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 comentarios
Ahmet Dogan
Ahmet Dogan el 27 de Mayo de 2022
Editada: Ahmet Dogan el 27 de Mayo de 2022
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 el 27 de Mayo de 2022
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.

Iniciar sesión para comentar.

Respuestas (2)

Bruno Luong
Bruno Luong el 4 de Mayo de 2022
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 comentarios
Ahmet Dogan
Ahmet Dogan el 4 de Mayo de 2022
Editada: Torsten el 4 de Mayo de 2022
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 el 4 de Mayo de 2022
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

Iniciar sesión para comentar.


Torsten
Torsten el 4 de Mayo de 2022
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 comentarios
Torsten
Torsten el 7 de Mayo de 2022
Editada: Torsten el 7 de Mayo de 2022
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 el 7 de Mayo de 2022
Editada: Bruno Luong el 7 de Mayo de 2022
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Solver-Based Optimization Problem Setup en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by