0
$\begingroup$

I am currently working on my modeling skill and I wanted to try to find a linear constraint, that models a binary variable in a specific way. The new binary variable $\gamma_i$ should take the value $1$ if $\epsilon_i=5$ and the value $0$ if $0\le \epsilon_i<5$ holds.

This is my approach so far:

$$\gamma_{i}\ge \epsilon_{i}-4\ge 0~~~~\forall i\in I\\ \gamma_{i}\in \{0,1\} \\ \epsilon_i \in \{0,\ldots,5\} $$

Would such a formulation be correct?

$\endgroup$

3 Answers 3

1
$\begingroup$

Take the contrapositive, and impose a big-M constraint.

The first implication yields $$ \epsilon_i = 5 \implies \gamma_i = 1 \\ \gamma_i = 0 \implies \epsilon_i \le 4 \\ \epsilon_i - 4 \le (5-4) \gamma_i \\ \epsilon_i - 4 \le \gamma_i $$

The second implication yields $$ \epsilon_i \le 4 \implies \gamma_i = 0 \\ \gamma_i = 1 \implies \epsilon_i \ge 5 \\ 5 - \epsilon_i \le (5-0) (1-\gamma_i) \\ \epsilon_i \ge 5\gamma_i \\ $$

Combining these yields $$5\gamma_i \le \epsilon_i \le 4 + \gamma_i,$$ which you could also have derived via $$5\gamma_i + 0(1-\gamma_i) \le \epsilon_i \le 5\gamma_i + 4(1-\gamma_i).$$

$\endgroup$
1
  • $\begingroup$ If some answer satisfies you, please mark it as accepted. $\endgroup$ Commented May 29, 2023 at 22:11
0
$\begingroup$

No. Your first inequality has $\epsilon_i-4\ge0$, so $\epsilon_i \ge 4$ which is just false.

Simplest general approach is to just draw the points in x y coordinates, draw a bounding triangle and then compute the formulae for those lines.

$\endgroup$
1
  • $\begingroup$ Thank you for your answer. Would this also work? $\gamma_i\le 1-(5-\epsilon_i)/M$ $\endgroup$ Commented May 26, 2023 at 13:56
0
$\begingroup$

(1) Would such a formulation be correct ?
It is wrong.
When RHS is 1 , LHS $γ_i$ must be 1 , which is ok.
When RHS is 0 or lesser , LHS $γ_i$ could be 0 or 1 , which is not ok.
To make it 0 , we have to include additional calculations , Eg1 : We might say , take minimum value which satisfies the Criteria , thus 0 is minimum of 0 & 1 , Eg2 : We might say , always try to use 0 , when it is not satisfying the Criteria , then use 1.
These alternatives will make it Correct , though unnecessarily Complicated.

(2) Should we use such a formulation in general ?
There is not much Simplicity & it is non-intuitive.
(2A) Simplicity : We should use $Sign(\cdots)$ ( which will give -1 , 0 & +1 ) & make the Choice using that.
(2B) Intuitive : We should use Comparisons $<,=,>$ ( which will give true & false ) & make the Choice using that.

Eg3 : $γ_i = (1+Sign(ϵ_i-4.5))/2$
Eg4 : $γ_i = 1 \text{ if } (ϵ_i=5) \text{ else } 0$

These 2 formulations are Correct & Simple & have clarity.

ADDENDUM :
In response to OP query about using in linear Programming.

We can tweak the Criteria & Examples to avoid $Sign(\cdot)$ & use the Comparisons list in (2B) & make suitable linear Programming formulations.
We can shift $ϵ_i$ by $4.5$ & we can scale $γ_i$ by $4.5$ which will give unique Solutions to the Criteria.
Example 5 :

$γ_i-4.5 \le ϵ_i \tag{5X}$
$γ_i \ge 4.5ϵ_i \tag{5Y}$

We can see that when $γ_i=1,2,3,4$ :
$ϵ_i=0,1$ (not unique) by (5X)
$ϵ_i=0$ by (5Y)
Hence $ϵ_i=0$ (unique) , over-all.

We can then see that when $γ_i=5$ :
$ϵ_i=1$ by (5X)
$ϵ_i=0,1$ (not unique) by (5Y)
Hence $ϵ_i=1$ (unique) , over-all.

Exactly what we want !

$\endgroup$
5
  • $\begingroup$ Thank you for your answer. Would this also work? $\gamma _i\le 1-(5-\epsilon_i)/M$ $\endgroup$ Commented May 26, 2023 at 11:48
  • $\begingroup$ (A) That too will not work , having the Same Issue : (1) When Variable should be 0 , it will be 0 : OK (2) When Variable should be 1 , it could even be 0 , which still satisfies the given Criteria : Not OK. (B) What is that M ? No matter what it is , the Criteria will not work ! $\endgroup$ Commented May 26, 2023 at 15:51
  • $\begingroup$ Thanks. Can a formulation with a Sign operator being used for a linear program? $\endgroup$ Commented May 28, 2023 at 6:43
  • $\begingroup$ I have updated that Answer with linear Programming formulation. $\endgroup$ Commented May 29, 2023 at 5:02
  • $\begingroup$ When shifting & scaling , I used the arbitrary Constant $4.5$ which is mid-way between $4$ & $5$ , though other Choices will work. I could shift by $4.1$ & scale by $4.9$ with almost no change here. $\endgroup$ Commented May 29, 2023 at 11:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.