Skip to content

Commit

Permalink
specify the modulo convention in python CP-SAT
Browse files Browse the repository at this point in the history
  • Loading branch information
lperron committed Jul 23, 2024
1 parent 905770c commit d0ed31d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ortools/sat/python/cp_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,19 @@ def add_abs_equality(self, target: LinearExprT, expr: LinearExprT) -> Constraint
def add_modulo_equality(
self, target: LinearExprT, expr: LinearExprT, mod: LinearExprT
) -> Constraint:
"""Adds `target = expr % mod`."""
"""Adds `target = expr % mod.
It uses the C convention, that is the result is the remainder of the
integral divisiion rounded towards 0.
Args:
target: the target expression.
expr: the expression to compute the modulo of.
mod: the modulus expression.
Returns:
A `Constraint` object.
"""
ct = Constraint(self)
model_ct = self.__model.constraints[ct.index]
model_ct.int_mod.exprs.append(self.parse_linear_expression(expr))
Expand Down

0 comments on commit d0ed31d

Please sign in to comment.