Variable f coeffficient depends on x for linprog
2 views (last 30 days)
Show older comments
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 Comments
Torsten
on 27 May 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.
Answers (2)
Bruno Luong
on 4 May 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 Comments
Alan Weiss
on 4 May 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
Torsten
on 4 May 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 Comments
Torsten
on 7 May 2022
Edited: Torsten
on 7 May 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
on 7 May 2022
Edited: Bruno Luong
on 7 May 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.
See Also
Categories
Find more on Solver-Based Optimization Problem Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!