Decompose Global (cpmpy.transformations.decompose_global)

Decompose global constraints not supported by the solver.

cpmpy.transformations.decompose_global.decompose_global(lst_of_expr, supported={}, supported_reif={})[source]

Deprecated since version 0.9.16: Please use decompose_in_tree() instead.

cpmpy.transformations.decompose_global.decompose_in_tree(lst_of_expr, supported={}, supported_reified={}, _toplevel=None, nested=False, csemap=None)[source]

Decomposes any global constraint not supported by the solver. Accepts a list of CPMpy expressions as input and returns a list of CPMpy expressions.

Parameters:
  • supported – a set of supported global constraints or global functions

  • supported_reified – a set of supported reified global constraints (globals with Boolean return type only)

  • _toplevel – a list of constraints that should be added toplevel, carried as pass by reference to recursive calls

  • nested – if True, new constraints will have been added to the _toplevel list too

Special care taken for unsupported global constraints in reified contexts and for numeric global constraints in a comparison.

Supported numerical global functions remain in the expression tree as is. They can be rewritten using cpmpy.transformations.reification.reify_rewrite() The following bv -> NumExpr <comp> Var/Const can be rewritten as [bv -> IV0 <comp> Var/Const, NumExpr == IV0]. So even if numerical constraints are not supported in reified context, we can rewrite them to non-reified versions if they are total.

cpmpy.transformations.decompose_global.do_decompose(cpm_expr)[source]

Deprecated since version 0.9.13: Please use decompose_in_tree() instead.