Expression utilities (cpmpy.expressions.utils
)
Internal utilities for expression handling.
can it be interpreted as an integer? (incl bool and numpy variants)
is it an int or float? (incl numpy variants)
is it a list or tuple?
is it a list or tuple or numpy array?
recursively flatten arguments into one single list
returns all pairwise combinations of elements in args
returns .value() of Expression, otherwise the variable itself
Internal function: evaluates the textual str_op comparison operator lhs <str_op> rhs
- cpmpy.expressions.utils.all_pairs(args)[source]
returns all pairwise combinations of elements in args
- cpmpy.expressions.utils.argval(a)[source]
returns .value() of Expression, otherwise the variable itself
We check with hasattr instead of isinstance to avoid circular dependency
- cpmpy.expressions.utils.eval_comparison(str_op, lhs, rhs)[source]
Internal function: evaluates the textual str_op comparison operator lhs <str_op> rhs
Valid str_op’s: * ‘==’ * ‘!=’ * ‘>’ * ‘>=’ * ‘<’ * ‘<=’
Especially useful in decomposition and transformation functions that already involve a comparison.
- cpmpy.expressions.utils.get_bounds(expr)[source]
return the bounds of the expression returns appropriately rounded integers
- cpmpy.expressions.utils.is_boolexpr(expr)[source]
is the argument a boolean expression or a boolean value
- cpmpy.expressions.utils.is_false_cst(arg)[source]
is the argument the constant False (can be of type bool, np.bool and BoolVal)