Comparison (cpmpy.transformations.comparison)

Transformations regarding Comparison constraints (originally). Now, it is regarding numeric expressions in general, including nested ones.

Let with <op> one of == or !=,<,<=,>,>= Numeric expressions in Flat Normal Form are of the kind

  • NumExpr <op> IV

  • BoolVar == NumExpr <op> IV

  • BoolVar -> NumExpr <op> IV

  • NumExpr <op> IV -> BoolVar

The NumExpr can be a sum, wsum or global function with a non-bool return type.

This file implements:
  • only_numexpr_equality(): transforms NumExpr <op> IV (also reified) to (NumExpr == A) & (A <op> IV) if not supported

cpmpy.transformations.comparison.only_numexpr_equality(constraints, supported=frozenset({}))[source]

transforms NumExpr <op> IV to (NumExpr == A) & (A <op> IV) if not supported also for the reified uses of NumExpr

Parameters:

supported – a (frozen)set of expression names that supports all comparisons in the solver