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

Matt J
Matt J 2020년 11월 28일
편집: Matt J 2020년 11월 28일
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.

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

답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 11월 27일

댓글:

2020년 11월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by