I want to represent the indicator function: $$ \mathbb{1}_{(y=j)}$$
where $y$ is a non negative, integer variable.
My attempt is as follows: define a binary variable: $$ z_j =\begin{cases} 1 \qquad\text{if $y=j$} \\ 0 \qquad\text{otherwise} \end{cases} $$
the model of the indicator function would be:
$$ \sum_{j=0}^{n} z_j = 1 $$ $$ \sum_{j=0}^{n} j \cdot z_j = y $$
where $n$ is an upper bound for $y$.
Actually, this can be conveniently modeled in OPL Cplex (for example) using indicator constraints such as follows:
forall(j in 0..n){
(y == j) == (z[j] == 1);
}
QUESTIONS:
- is my binary-variables-based formulation attempt correct? Do you know better (performance wise) formulations?
- in a hypothetical academic journal paper, is the second formulation (based on indicator constraints) acceptable? If yes, how would you formally express it in the paper in a way that is implementation-independent (that is, in a way that does not depend upon how a specific solver models such a constraint)? Or it is better to provide the more general, binary-variables-based formulation?
Thanks a lot.