When I want to use the modulo function in my linear model, I get the following error: “Constraint programming constraints cannot be used in combination with real valued variables, only with integer valued variables, element valued variables and activities.”. In my constraint I calculate the modulo of (x_{zht}*(t-1), Z) where Z is a parameter and I have used the function Ord to calculate the first part of the modulo, so x_{zht}*(Ord(t)-1).

Also, I have tried making the indices a subset of Integers and label it as numeric, but then the model does not give any solution anymore (even when I turn the modulo constraint off). How can I make the constraints containing the modulo function in my linear model work?

**Best answer by Marcel Hunting**

Hi

There is way the reformulate the modulo function as follows. Assume **r = mod(x,Z)**. Then you can reformulate this as:

x = y*Z + r

r <= Z - eps

r >= 0

y integer

Here **eps **is a parameter representing a positive value close to 0, e.g., 1e-4. If **Z** is integer then **eps **can be 1.

You need a new integer variable **y**. If your model was a LP before then it becomes a MIP.