jijzepttools.modeling.replace.expression#
Functions#
|
replace condition using replacer. |
|
recursively replace the jm.Expression following the rules below: |
Module Contents#
- replace_condition(cond: jijzepttools.modeling.utils.type.Expr, replacer: Callable[[jijzepttools.modeling.utils.type.Expr], jijzepttools.modeling.utils.type.Expr], overwrite_cond: Literal['>=', '<=', '=='] | None = None) jijzepttools.modeling.utils.type.Expr #
replace condition using replacer.
- Parameters:
cond (Expr) – condition to be replaced
replacer (tp.Callable[[Expr], Expr]) – replacer
overwrite_cond (tp.Optional[str], optional) – new condition operator. Defaults to None.
- Returns:
replaced condition
- Return type:
Expr
- expand_add(expr: jijzepttools.modeling.utils.type.Expr) jijzepttools.modeling.utils.type.Expr #
recursively replace the jm.Expression following the rules below: $$ (a + b + …) (c + d + …) rightarrow a c + a d + b c + b d + … $$ $$ sum_{…}^{…}(a + b + …) rightarrow sum_{…}^{…}(a) + sum_{…}^{…}(b) + … c * sum_{…}^{…}(a) rightarrow sum_{…}^{…}(c * a) sum_{…}^{…}(a) * c rightarrow sum_{…}^{…}(a * c) $$ :param expr: target expression :type expr: Expr
- Returns:
expanded expression
- Return type:
Expr