Division expression examples
Both integer division and floating-point division expressions can be modeled in arithmetic expressions.
Both integer division and floating-point division can be modeled in arithmetic expressions. To clarify the distinction between integer division and floating-point division of decision variables in constraints, consider these brief examples.
Let x be a decision variable
that can assume the value 9:
In the C++ API,
IloIntVar x(env, 9, 9, "x");In the Java™ API,
IloIntVar x = cp.intVar(9, 9);In the C# API,
IIntVar x = cp.IntVar(9, 9);
Then integer division with IloDiv,
or IloCP.div or CP.Div of x divided by 10 results in the value 0 (zero).
Consequently, a constraint stating "
IloDiv(x, 10) == 0" is true.In contrast, a constraint stating "
IloDiv(x, 10) >= 0.5" is false.
However, floating-point division with operator/, or IloCP.quot or CP.Quot of x divided by
10 results in the value 0.9.
Consequently, a constraint stating "
x/10 == 0" is false.A constraint stating "
x/10 >= 0.5" is true.