Linearizing a nonlinear constraint for use in intlinprog
Show older comments
Hello Everyone,
I'm setting up an integer linear program using the "Problem-based approach". I have several constraints of the form:

Where:
x: is a binary decision variable, defined using "optimvar".
y: is a continious variable, defined using "optimexpr"
C: a constant real number.
I have tried to resolve this by creating an extra optimization expression "z" and then describing the product in several linear constraints as shown below.
constr1 = z <= M* x; % M is a big M constant
constr2 = z <= y; % y is an optimexpr described elsewhere in the code
constr3 = z >= y - M*(1- x);
constr4 = z >=0;
constr5 = z <= C;
However, when I apply it, and use the function "show" to chek on the constraints, this is what I get:
" Constraint with all zero coefficients"
Could someone point me to what I'm missing here?
3 Comments
However, when I apply it, and use the function "show" to chek on the constraints, this is what I get:
Well, you wouldn't have been able to examine a constraint using show(). You would need showconstr() for that...
I also don't understand why you would be using optimexpr to create y. Isn't y an independent variable? If so, you should use optimvar to create y as well.
Hatim Mala
on 28 Nov 2020
Matt J
on 28 Nov 2020
Well, I suggest attaching a .mat file containing x,y,z,C so that we can try to reproduce what you're seeing.
Answers (0)
Categories
Find more on Linear Least Squares 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!