0
$\begingroup$

According to this link binary variables - absolute values the formula of some binary variables like absolute value is :

y = | x1 - x2| for two variables x1, x2 with 0 ≤ xi ≤ U

Introduce binary variables d1, d2 to mean

d1 : 1 if x1 - x2 is the positive value d2 : 1 if x2 - x1 is the positive value

MIP formulation

0 ≤ xi ≤ U [1.i]

0 ≤ y - (x1-x2) ≤ 2 · U · d2 [2]

0 ≤ y - (x2-x1) ≤ 2 · U · d1 [3]

d1 + d2 = 1 [4]

Notice the bolded numbers, what do these 2s represent? Do they represent the value range? Aren't the value range is only from 0 to 1?

Sorry, I'm totally new to this.

$\endgroup$

1 Answer 1

1
$\begingroup$

That's just basic inequalities, there is no trick.

  • if $d_1 = 1$, then $d_2 = 0$, and $y = x_1 - x_2$. That means that: $$y - (x_1 - x_2) = 0 \leqslant 2 \times U \times d_2 = 0$$
  • if $d_1 = 0$, then $d_2 = 0$, and $y = x_2 - x_1$. That means that: $$y - (x_1 - x_2) = 2x_2 - 2x_1 \leqslant 2\times U - 2\times 0 = 2\times U \times d_2$$

Same thing for the other inequality.

$\endgroup$
9
  • $\begingroup$ According to the link, it said "Binary decision variables take value 0 or 1". The values can only be from 0 to 1. What do these 2s represent? I'm sorry, I have a very limited background in maths $\endgroup$
    – SnoopyKid
    Mar 17 at 11:46
  • $\begingroup$ $d_1$ and $d_2$ take values in $\{0,1\}$. Those are the binary decision variables. $\endgroup$
    – Nathaniel
    Mar 17 at 11:50
  • $\begingroup$ Ok, thanks. So, those 2s in y−(x1−x2)=0⩽2×U×d2=0 and y−(x1−x2)=2x2−2x1⩽2×U−2×0=2×U×d2 represent 1? $\endgroup$
    – SnoopyKid
    Mar 17 at 15:19
  • $\begingroup$ What are you saying? Those 2's are representing 2, not 1… This is $2 = 1 + 1$, because there is two occurrences of $x_1$ and $x_2$. Honestly, I don't even understand what is the problem. $x + x = 2x$, and this $2$ is not $1$. $\endgroup$
    – Nathaniel
    Mar 17 at 15:46
  • $\begingroup$ Oh sorry for that, so the value range is still 0 to 1? Not 0 to 2? My problem is that because it is binary variables which strictly involved only 0 and 1, so my initial thought is that there cannot be number 2 in there. But only 0 and 1 $\endgroup$
    – SnoopyKid
    Mar 17 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.