-1
$\begingroup$

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

$\endgroup$
4

1 Answer 1

0
$\begingroup$

you can introduce a binary variable z verifying the following constraints :

  • (A-1) <= 12*z

  • z<= 0.5*A

  • -(1-z)*12 <= B-A <= (1-z)*12

  • -12*z <= B <= 12*z

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.