Linearizing a nonlinear constraint for use in intlinprog

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.
Hey Matt,
Thanks for your help!
1. I am actually using: write(Prob.Constraints.constr2) which creates a .txt file containing the constraint formula. Still I get "Constraint with all zero coefficients".
2. y is not an independent variable, y itself depends on a linear combination of other decision variables. Hence the use of "optimexpr".
Well, I suggest attaching a .mat file containing x,y,z,C so that we can try to reproduce what you're seeing.

Sign in to comment.

Answers (0)

Products

Release

R2019b

Asked:

on 27 Nov 2020

Commented:

on 28 Nov 2020

Community Treasure Hunt

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

Start Hunting!