How can I write the following statement as a constraint?

66 Views Asked by At

I have the following condition:

  • If $x = 0$ and $c=0$ then $z=1$.
  • If $x>0$ and $c=1$ then $z = 1$.
  • If $x>0$ and $c=0$ then $z = 0$.

I find the constraint $x(1-c) \geqslant 1-z$, but it misses the last point.

EDIT

The variables $z$ and $c$ are binary variables.

1

There are 1 best solutions below

0
On BEST ANSWER

$$z=-sgn(x)+sgn(c)+1$$ does the job.