Conditional Binary

Problems with modeling
Post Reply
Posts: 7
Joined: 1 year ago

Conditional Binary

Post by Omi » 1 year ago

How to code Binary Variable?
Y(I,t) 1 if ∑j T(j,I,t) + Z(I,t) >= 1,
0 Otherwise.

Thank you.

User avatar
Posts: 136
Joined: 4 years ago
Location: Fairfax, VA

Re: Conditional Binary

Post by dirkse » 1 year ago


To paraphrase your question, you ask "How can I have a condition iff a binary variable is 1", e.g. for a binary y

expression >= 1 implies y = 1
expression < 1 implies y = 0

This doesn't work well. Strict inequalities are not part of optimization for several reasons, e.g.:

http://yetanothermathprogrammingconsult ... ation.html

Instead, we go the other direction: if y = 1, we turn a constraint on, otherwise it isn't on, i.e. it is relaxed.

expression >= 1 - M * (1-y)

It's important to choose the M large enough so that expression >= 1 - M is satisfied for any feasible point, but no larger than necessary.


Post Reply