Normalize (cpmpy.transformations.normalize)

Normalize a toplevel list, or simplify Boolean expressions.

cpmpy.transformations.normalize.simplify_boolean(lst_of_expr, num_context=False)[source]

Removes boolean constants from all CPMpy expressions. Only resulting boolean constant is literal ‘false’. Boolean constants are promoted to int if in a numerical context, ints are never converted to bool.

Parameters:

list_of_expr – list of CPMpy expressions

cpmpy.transformations.normalize.toplevel_list(cpm_expr, merge_and=True)[source]

Unravels nested lists and top-level AND’s and ensures every element returned is a CPMpy Expression with is_bool() true.

Parameters:
  • cpm_expr – Expression or list of Expressions

  • merge_and – if True then a toplevel ‘and’ will have its arguments merged at top level