Decompose Global (cpmpy.transformations.decompose_global)

Decompose any global constraint not supported by the solver.

cpmpy.transformations.decompose_global.decompose_global(lst_of_expr, supported={}, supported_reif={})[source]
cpmpy.transformations.decompose_global.decompose_in_tree(lst_of_expr, supported={}, supported_reified={}, _toplevel=None, nested=False)[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,

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

  • 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

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]