Expression utilities (cpmpy.expressions.utils)
Internal utilities for expression handling.
List of functions
- nosignatures:
is_bool is_int is_num is_false_cst is_true_cst is_boolexpr is_pure_list is_any_list is_transition flatlist all_pairs argval argvals eval_comparison get_bounds
- 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.get_nonneg_args(args, condition=None)[source]
Replace arguments with negative lowerbound with their nonnegative counterpart :param - args: list of expressions :param - condition: list of boolean expressions, indicating whether the argument is present or not (e.g., optional tasks)
- cpmpy.expressions.utils.implies(expr, other)[source]
Like
implies(), but also safe to use for non-expressions
- cpmpy.expressions.utils.is_any_list(arg) TypeGuard[list | tuple | ndarray][source]
Is it a list or tuple or numpy array?
- 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)
- cpmpy.expressions.utils.is_int(arg)[source]
Can it be interpreted as an integer? (incl bool and numpy variants)