I am trying to create a binary variable ($z$) within a linear model which 'switches' on only when another variable ($d$) becomes greater than zero.
I have had some success using the following two constraints (where $M_l$ and $M_u$ are lower and upper bounds of $d$):
$$zM_u \ge d$$
$$\left(z-1\right)M_l \le d$$
This seems to work for values less than zero ($z$ gets set to zero) and for values greater than zero ($z$ gets set to one). However it doesn't properly constrain $z$ when $d$ is zero, arbitrarily setting it to either 0 or 1.
Is there some way I can change (or replace) these inequalities to force the constraint I want?