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) Thanks asked 17 Feb '13, 16:15 hesameivazy 
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 1y_2\) for \(i\in\{1,2,3,8,9,10\}\). answered 17 Feb '13, 17:53 Paul Rubin ♦ 1
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
1
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 ♦

@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 (Us)/(Ui)\), \(x_{i}\geq i/s\) answered 18 Feb '13, 15:55 Marco Luebbecke ♦ Yes I am looking for a more general formulation.
(19 Feb '13, 11:40)
hesameivazy

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
I believe my answer does the job for you.