Hi, I am trying to model a problem: if 4.5<=s<=7.3 (s is a continuous variable) then x4=x5=x6=x7=1 else x1=x2=x3=x8=x9=x10=0. xi (1=1...10) are binary variables regarding periods 1 to 10. in fact, I want to make all x variables within time periods int(4.5) and int(7.3) get 1 others zero. (int is floor function eg int(5.1)=5, int(9.8)=9, int(3)=3)


asked 17 Feb '13, 16:15

hesam%20eivazy's gravatar image

hesam eivazy
accept rate: 0%

I am wondering how would be the most efficient (least # of binary variables) while bounds of s (L, U) are known, 7.3 and 4.5 are not known (they are two continuous variables). I mean if a<=s<=b then x(i)=1 every i<=ceiling (b) and floor (a)<=i else x(i)=0 a and b are two continuous variables thanks

(19 Feb '13, 11:46) hesam eivazy

I believe my answer does the job for you.

(19 Feb '13, 11:58) Marco Luebbecke ♦

Assume that \(L\) and \(U\) are known lower/upper bounds for \(s\) (so that \(L\le s \le U\)). Define three new binary variables \(y_1, y_2, y_3\) and add the constraints \( Ly_{1}+4.5y_{2}+7.3y_{3} \le s\le 4.5y_{1}+7.3y_{2}+Uy_{3}\) and \(y_{1}+y_{2}+y_{3} = 1\). Now constrain \(x_i\ge y_2\) for \(i=4,\dots,7\) and \(x_i\le 1-y_2\) for \(i\in\{1,2,3,8,9,10\}\).


answered 17 Feb '13, 17:53

Paul%20Rubin's gravatar image

Paul Rubin ♦♦
accept rate: 19%

edited 17 Feb '13, 17:55


Seems like Paul's last constraint should be $$x_i \le y_2$$ instead of $$x_i \le 1 - y_2$$.

(18 Feb '13, 18:11) Rob Pratt

@Rob: Don't think so. \(y_2 = 1\) if \(4.5\le s \le 7.3\), in which case you want \(x_i = 0\) for \(i\in \{1,2,3,8,9,10\}\). Your change would let those \(x_i\) equal 1.

(18 Feb '13, 18:15) Paul Rubin ♦♦

OK, then the OP's "else" should instead be "and"

(18 Feb '13, 18:18) Rob Pratt

Good point. Maybe I misread the question. If he does mean else (and means \(x_4,\dots,x_7\) are unrestricted for \(s\notin [4.5,7.3]\) and the other \(x_i\) are unrestricted for \(x\in [4.5,7.3]\), then you're right: the last constraint should be \(x_i\le y_2\).

(18 Feb '13, 18:37) Paul Rubin ♦♦

If s=7.3, wouldn't it also be possible that y3=1 too??

(07 Oct '14, 11:26) hfahad108

Yes. Avoiding that in practice requires ruling out values between 7.3 and \(7.3 + \epsilon\) for some small \(\epsilon >0\) (but not too small - needs to be larger than rounding error).

(07 Oct '14, 16:16) Paul Rubin ♦♦

@Paul ... Many Thanks for your reply I am also wondering what will limit x_i to 0 if y_2 is 0 ? as x_i =1 is also >= y_2

(07 Oct '14, 21:00) hfahad108

I think the last comment under my answer covers that. There is/was some confusion about what the original poster meant.

(08 Oct '14, 09:44) Paul Rubin ♦♦
showing 5 of 8 show 3 more comments

@hesameivazy, were you looking for something more general? With @paul's \(L\) and \(U\), you may need \(x_{i}\leq s/i\), \(x_{i}\leq (U-s)/(U-i)\), \(x_{i}\geq i/s\)


answered 18 Feb '13, 15:55

Marco%20Luebbecke's gravatar image

Marco Luebbecke ♦
accept rate: 16%

Yes I am looking for a more general formulation.

(19 Feb '13, 11:40) hesam eivazy
Your answer
toggle preview

Follow this question

By Email:

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



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



Asked: 17 Feb '13, 16:15

Seen: 3,818 times

Last updated: 11 Oct '14, 12:50

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