jijzepttools.modeling.extract.expression#

Functions#

extract(→ List[jijzepttools.modeling.utils.type.Expr])

extract element that matches the pattern

get_add_terms(...)

get terms from expression

get_mul_terms(...)

get terms from expression

get_var(→ jijzepttools.modeling.utils.type.Expr)

get variable from variable dictionary

extract_element_without_belong_to(...)

extract elements without

Module Contents#

extract(expr: jijzepttools.modeling.utils.type.Expr, pattern: Callable[[jijzepttools.modeling.utils.type.Expr], bool]) List[jijzepttools.modeling.utils.type.Expr]#

extract element that matches the pattern

Parameters:
  • expr (Expr) – expression

  • pattern (tp.Callable[[Expr], bool]) – condition

Returns:

extracted elements

Return type:

tp.List[Expr]

get_add_terms(expr: jijzepttools.modeling.utils.type.Expr) List[jijzepttools.modeling.utils.type.Expr]#

get terms from expression For example, if the input is a+b+c, this function returns [a, b, c]. Unlike jm.AddOp.terms, this function returns decomposed terms. For example, if the input is (a+b)+(c+d), this function returns [a, b, c, d] whereas jm.AddOp.terms returns [(a+b), (c+d)].

Parameters:

expr (Expr) – expression

Returns:

terms

Return type:

tp.List[Expr]

get_mul_terms(expr: jijzepttools.modeling.utils.type.Expr) List[jijzepttools.modeling.utils.type.Expr]#

get terms from expression For example, if the input is a*b*c, this function returns [a, b, c]. Unlike jm.MulOp.terms, this function returns decomposed terms. For example, if the input is (a*b)*(c*d), this function returns [a, b, c, d] whereas jm.MulOp.terms returns [(a*b), (c*d)].

Parameters:

expr (Expr) – expression

Returns:

terms

Return type:

tp.List[Expr]

get_var(var_dict: Dict[Any, jijmodeling.Subscript | jijmodeling.Placeholder | jijzepttools.modeling.utils.type.DecisionVar], var_name: str, *indices: Any) jijzepttools.modeling.utils.type.Expr#

get variable from variable dictionary This function returns a variable from variable dictionary. If the variable is not in the dictionary, this function returns jm.NumberLit(0).

Parameters:
  • var_dict (tp.Dict[tp.Any, Expr]) – variable dictionary

  • var_name (str) – variable name

  • *indices (tp.Any) – indices of the variable

Returns:

variable

Return type:

Expr

extract_element_without_belong_to(expr: jijzepttools.modeling.utils.type.Expr) List[jijmodeling.Element]#

extract elements without This function extracts elements without belong_to from expression.

Parameters:

expr (Expr) – expression

Returns:

elements without belong_to

Return type:

tp.List[jm.Element]