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's gravatar image

sbeleidy
112
accept rate: 0%

edited 23 Apr '13, 14:55

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

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.

link

answered 24 Apr '13, 03:38

jfpuget's gravatar image

jfpuget
2.5k310
accept rate: 8%

edited 24 Apr '13, 20:47

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

link

answered 28 Apr '13, 14:53

x3d0's gravatar image

x3d0
2012412
accept rate: 0%

S = 0 is infeasible with your formulation

(28 Apr '13, 19:40) jfpuget
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • 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:

×101

Asked: 23 Apr '13, 14:54

Seen: 6,786 times

Last updated: 29 Apr '13, 04:40

OR-Exchange! Your site for questions, answers, and announcements about operations research.