Integer Linear programming formulation if then condition I want to create constraints such that I can implement the following condition:

Let A be an integer variable >= 0 with an upper bound of 12

I want to introduce the following variable B also an integer:

if A = 1 then B = 0 else B = A
you can introduce a binary variable z verifying the following constraints :


(A-1) &lt;= 12*z
z&lt;= 0.5*A  
-(1-z)*12 &lt;= B-A &lt;= (1-z)*12
-12*z &lt;= B &lt;= 12*z