decompose_term

(function from pyomo.core.expr.numeric_expr)

pyomo.core.expr.numeric_expr.decompose_term(expr)[source]

A function that returns a tuple consisting of (1) a flag indicating whether the expression is linear, and (2) a list of tuples that represents the terms in the linear expression.

Parameters:

expr (expression) – The root node of an expression tree

Returns:

A tuple with the form (flag, list). If flag is False, then a nonlinear term has been found, and list is None. Otherwise, list is a list of tuples: (coef, value). If value is None, then this represents a constant term with value coef. Otherwise, value is a variable object, and coef is the numeric coefficient.