0

I want to add a constraint that a variable should be divisible by a particular integer. I tried using mod operator but it cannot be used with variables:

s.t. c1 x1 mod 10 = 0

I get the following error:

operand preceding mod has invalid type

How to resolve it?

1 Answer 1

0

This is actually surprisingly easy.

Your constraint:

 x mod 10 = 0

is equivalent to

 x = 10 * n where n is an integer

So the recipe is: add an integer variable n and add the linear constraint:

 x = 10 * n
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.