Constraining binary integer variables with indicator constraints

I guess I cannot turn my constraint around

No.

The trick is to find constraint(s) that have an equivalent truth-table. For example
z <=> x[1] - x[2] == -1, where x, z are binary, is equivalent to

@constraint(model, x[1] - x[2] - 2 * (1 - z) <= -1)

and (!x[1] && x[2]) => {z == 1} is equivalent to

@constraint(model, z >= -x[1] + x[2])

The MOSEK Modeling Cookbook (9 Mixed integer optimization — MOSEK Modeling Cookbook 3.3.0) has a number of helpful examples.

2 Likes