What I'm trying to do is iterate over an index j and if j is between start and start+duration I want my flag variable to be 1, otherwise it is 0. Suggestions?
asked
sbeleidy |

You must first understand how to state the following: b = 1 if and only if x >= 0 Let's note this b = (x >= 0) where b is a binary variable and x a floating point variable. The main issue is the discontinuity at x = 0. In what follows b is unconstrained at the discontinuity M b >= x M (1-b) >= -x Then you express b1 = (j >= start) b2 = (j <= start + duration) F = b1 & b2 The latter is a classical one: F >= b1 + b2 -1 F <= b1 F <= b2 Depending on how F is used elsewhere you can get rid of some constraints.
answered
jfpuget |

I think that more details would be welcome in order to be able to help you ;)

I guess that

startis a variable anddurationa constant, am I right ?When you say that F=1 if and only if start <= j <= start+duration I guess that you mean $$F_j$$ ?

Can you tell us what is the function of the variables F in your model ?

I actually figured out how to do it. Here's the solution for those who care about this:

F_ij ≥ 1 - M1 * a_ij - M2 * b_ij

a_ij ≥ S_ij -j

b_ij ≤ S_ij + D - j

Seems unclear to me.

let S_ij=3 S_ij+D = 5 and j =4 then a_{ij} >= 3-4=-1 b_{ij} >= 5-4=+1

and eventually F_ij ≥ 1 - M1 * -1 - M2 * 1

so what is the added value of this set of contraints?