Suppose I have a large line segment and within that segment, a small interval[LB, UB] is chosen. Let T be a binary variable which is 1 within that small interval, 0 otherwise. This can be expressed in conditional statements as follows:
if (t < LB or t > UB) {T=0; }
if (LB <= t <= UB){ T=1; }
Here, LB, UB and t are integer variables. Please help me to formulate the same in Integer Linear Programming.
You can do this in two parts.
First, create a variable $p$ that is $0$ when $t<LB$ and is $1$ when $t>LB$.
Do this by adding these constraints:
Constraint 1: $t-LB<1000000p$
Constraint 2: $LB-t<1000000(1-p)$
The number $10000000$ is just an arbitrarily large number that is larger in magnitude than anything else you could get for $t$.
As an example of when $t<LB$, let $t=10$ and let $LB=15$.
Then Constraint 1 becomes: $-5<1000000p \Rightarrow p>-0.000005$
and Constraint 2 becomes: $5<1000000(1-p) \Rightarrow 5<1000000-1000000p \Rightarrow 1000000p<999995 \Rightarrow p<0.999995$
As $p$ is an integer, this sets $p=0$
For an example of when $t>LB$, let $t=20$ and let $LB=15$.
Then Constraint 1 becomes: $5<1000000p \Rightarrow p>0.000005$
and Constraint 2 becomes: $-5<1000000(1-p) \Rightarrow -5<1000000-1000000p \Rightarrow 1000000p<1000005 \Rightarrow p<1.000005$
As $p$ is an integer, this sets $p=1$
Similarly create a variable $q$ that is $0$ when $t<UB$ and is $1$ when $t>UB$.
Do this by adding these constraints:
Constraint 3: $t-UB<1000000q$
Constraint 4: $UB-t<1000000(1-q)$
Finally, set $T=p-q$ and you have the problem solved.