Get variables from expressions (cpmpy.transformations.get_variables)

Getting and printing variables in the model or expression.

Variables are ordered by appearance, e.g. first encountered first.

cpmpy.transformations.get_variables.get_variables(expr, collect=None)[source]

Get variables of an expression

Parameters:
  • expr – Expression or list of expressions

  • collect – optional set, variables will be added to this set of given

cpmpy.transformations.get_variables.get_variables_model(model)[source]

Get variables of a model (constraints and objective)

This is a separate function because we can not import Model without a circular dependency…

cpmpy.transformations.get_variables.print_variables(expr_or_model)[source]

Print variables and their domains

Parameters:

expr_or_model – can be an expression or a model

cpmpy.transformations.get_variables.vars_expr(expr)[source]