# If s<= j <= s+d, F=1 otherwise F=0

 0 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 23 Apr '13, 14:54 sbeleidy 1●1●2 accept rate: 0% I think that more details would be welcome in order to be able to help you ;) I guess that start is a variable and duration a 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 ? (23 Apr '13, 16:18) Renaud 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 (23 Apr '13, 16:41) sbeleidy 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? (23 Apr '13, 17:02) ShahinG

 1 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 24 Apr '13, 03:38 jfpuget 2.5k●3●10 accept rate: 8%
 0 Choose bigM big enough in comparison others variables j, j+d bigM = 10000; S = {0,1} j - bigM*S <= s j - bigM*S >= s +d answered 28 Apr '13, 14:53 x3d0 201●2●4●12 accept rate: 0% S = 0 is infeasible with your formulation (28 Apr '13, 19:40) jfpuget
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags: