Core Classes
The following are the two core classes documented here:
The remaining classes are the public classes for expressions, which
developers may need to know about. The methods for these classes are not
documented because they are described in the
NumericExpression
class.
Sets with Expression Types
The following sets can be used to develop visitor patterns for Pyomo expressions.

pyomo.core.expr.numvalue.
native_numeric_types
= {<class 'numpy.uint64'>, <class 'numpy.int64'>, <class 'numpy.ndarray'>, <class 'bool'>, <class 'complex'>, <class 'numpy.float16'>, <class 'numpy.float64'>, <class 'float'>, <class 'numpy.uint8'>, <class 'numpy.int8'>, <class 'numpy.float32'>, <class 'numpy.uint16'>, <class 'numpy.int16'>, <class 'int'>, <class 'numpy.uint32'>, <class 'numpy.int32'>} set() > new empty set object set(iterable) > new set object
Build an unordered collection of unique elements.

pyomo.core.expr.numvalue.
native_types
= {<class 'numpy.uint64'>, <class 'numpy.int64'>, <class 'numpy.float64'>, <class 'numpy.uint32'>, <class 'numpy.int32'>, <class 'slice'>, <class 'bool'>, <class 'complex'>, <class 'numpy.float32'>, <class 'numpy.uint16'>, <class 'numpy.int16'>, <class 'numpy.bool_'>, <class 'NoneType'>, <class 'str'>, <class 'numpy.float16'>, <class 'numpy.uint8'>, <class 'numpy.int8'>, <class 'bytes'>, <class 'numpy.ndarray'>, <class 'float'>, <class 'int'>} set() > new empty set object set(iterable) > new set object
Build an unordered collection of unique elements.

pyomo.core.expr.numvalue.
nonpyomo_leaf_types
= {<class 'numpy.uint64'>, <class 'numpy.int64'>, <class 'numpy.float64'>, <class 'numpy.uint32'>, <class 'numpy.int32'>, <class 'slice'>, <class 'bool'>, <class 'complex'>, <class 'numpy.float32'>, <class 'numpy.uint16'>, <class 'numpy.int16'>, <class 'numpy.bool_'>, <class 'NoneType'>, <class 'str'>, <class 'numpy.float16'>, <class 'numpy.uint8'>, <class 'numpy.int8'>, <class 'bytes'>, <class 'numpy.ndarray'>, <class 'float'>, <class 'pyomo.core.expr.numvalue.NonNumericValue'>, <class 'int'>} set() > new empty set object set(iterable) > new set object
Build an unordered collection of unique elements.
NumericValue and NumericExpression

class
pyomo.core.expr.numvalue.
NumericValue
[source] This is the base class for numeric values used in Pyomo.

__abs__
()[source] Absolute value
This method is called when Python processes the statement:
abs(self)

__add__
(other)[source] Binary addition
This method is called when Python processes the statement:
self + other

__bool__
()[source] Coerce the value to a bool
Numeric values can be coerced to bool only if the value / expression is constant. Fixed (but nonconstant) or variable values will raise an exception.
Raises: PyomoException –

__div__
(other)[source] Binary division
This method is called when Python processes the statement:
self / other

__eq__
(other)[source] Equal to operator
This method is called when Python processes the statement:
self == other

__float__
()[source] Coerce the value to a floating point
Numeric values can be coerced to float only if the value / expression is constant. Fixed (but nonconstant) or variable values will raise an exception.
Raises: TypeError –

__ge__
(other)[source] Greater than or equal operator
This method is called when Python processes statements of the form:
self >= other other <= self

__gt__
(other)[source] Greater than operator
This method is called when Python processes statements of the form:
self > other other < self

__hash__
= None

__iadd__
(other)[source] Binary addition
This method is called when Python processes the statement:
self += other

__idiv__
(other)[source] Binary division
This method is called when Python processes the statement:
self /= other

__imul__
(other)[source] Binary multiplication
This method is called when Python processes the statement:
self *= other

__int__
()[source] Coerce the value to an integer
Numeric values can be coerced to int only if the value / expression is constant. Fixed (but nonconstant) or variable values will raise an exception.
Raises: TypeError –

__ipow__
(other)[source] Binary power
This method is called when Python processes the statement:
self **= other

__isub__
(other)[source] Binary subtraction
This method is called when Python processes the statement:
self = other

__itruediv__
(other)[source] Binary division (when __future__.division is in effect)
This method is called when Python processes the statement:
self /= other

__le__
(other)[source] Less than or equal operator
This method is called when Python processes statements of the form:
self <= other other >= self

__lt__
(other)[source] Less than operator
This method is called when Python processes statements of the form:
self < other other > self

__mul__
(other)[source] Binary multiplication
This method is called when Python processes the statement:
self * other

__pos__
()[source] Positive expression
This method is called when Python processes the statement:
+ self

__pow__
(other)[source] Binary power
This method is called when Python processes the statement:
self ** other

__radd__
(other)[source] Binary addition
This method is called when Python processes the statement:
other + self

__rdiv__
(other)[source] Binary division
This method is called when Python processes the statement:
other / self

__rmul__
(other)[source] Binary multiplication
This method is called when Python processes the statement:
other * self
when other is not a
NumericValue
object.

__rpow__
(other)[source] Binary power
This method is called when Python processes the statement:
other ** self

__rsub__
(other)[source] Binary subtraction
This method is called when Python processes the statement:
other  self

__rtruediv__
(other)[source] Binary division (when __future__.division is in effect)
This method is called when Python processes the statement:
other / self

__sub__
(other)[source] Binary subtraction
This method is called when Python processes the statement:
self  other

__truediv__
(other)[source] Binary division (when __future__.division is in effect)
This method is called when Python processes the statement:
self / other

_compute_polynomial_degree
(values)[source] Compute the polynomial degree of this expression given the degree values of its children.
Parameters: values (list) – A list of values that indicate the degree of the children expression. Returns: None

getname
(fully_qualified=False, name_buffer=None)[source] If this is a component, return the component’s name on the owning block; otherwise return the value converted to a string

is_relational
()[source] DEPRECATED.
Return True if this numeric value represents a relational expression.Deprecated since version 6.4.3: is_relational() is deprecated in favor of is_expression_type(ExpressionType.RELATIONAL)

to_string
(verbose=None, labeler=None, smap=None, compute_values=False)[source] Return a string representation of the expression tree.
Parameters:  verbose (bool) – If
True
, then the string representation consists of nested functions. Otherwise, the string representation is an infix algebraic equation. Defaults toFalse
.  labeler – An object that generates string labels for
nonconstant in the expression tree. Defaults to
None
.  smap – A SymbolMap instance that stores string labels for
nonconstant nodes in the expression tree. Defaults to
None
.  compute_values (bool) – If
True
, then fixed expressions are evaluated and the string representation of the resulting value is returned.
Returns: A string representation for the expression tree.
 verbose (bool) – If


class
pyomo.core.expr.current.
NumericExpression
(args)[source] Bases:
ExpressionBase
,NumericValue
The base class for Pyomo expressions.
This class is used to define nodes in a numeric expression tree.
Parameters: args (list or tuple) – Children of this node. 
PRECEDENCE
= 0 Return the associativity of this operator.
Returns 1 if this operator is lefttoright associative or 1 if it is righttoleft associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

_compute_polynomial_degree
(values)[source] Compute the polynomial degree of this expression given the degree values of its children.
This method is called by the
_PolynomialDegreeVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of values that indicate the degree of the children expression. Returns: A nonnegative integer that is the polynomial degree of the expression, or None
. Default isNone
.

property
args
Return the child nodes
Returns: Sequence containing only the child nodes of this node. The return type depends on the node storage model. Users are not permitted to change the returned data (even for the case of data returned as a list), as that breaks the promise of tree immutability. Return type: list or tuple

create_potentially_variable_object
()[source] DEPRECATED.
Create a potentially variable version of this object.
This method returns an object that is a potentially variable version of the current object. In the simplest case, this simply sets the value of __class__:
self.__class__ = self.__class__.__mro__[1]Note that this method is allowed to modify the current object and return it. But in some cases it may create a new potentially variable object.
 Returns:
 An object that is potentially variable.
Deprecated since version 6.4.3: The implicit recasting of a “not potentially variable” expression node to a potentially variable one is no longer supported (this violates that immutability promise for Pyomo5 expression trees).

nargs
()[source] Returns the number of child nodes.
Note
Individual expression nodes may use different internal storage schemes, so it is imperative that developers use this method and not assume the existence of a particular attribute!
Returns: int Return type: A nonnegative integer that is the number of child nodes.

Other Public Classes

class
pyomo.core.expr.current.
NegationExpression
(args)[source] Bases:
NumericExpression
Negation expressions:
 x

PRECEDENCE
= 4 Return the associativity of this operator.
Returns 1 if this operator is lefttoright associative or 1 if it is righttoleft associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

_apply_operation
(result)[source] Compute the values of this node given the values of its children.
This method is called by the
_EvaluationVisitor
class. It must be overwritten by expression classes to customize this logic.Note
This method applies the logical operation of the operator to the arguments. It does not evaluate the arguments in the process, but assumes that they have been previously evaluated. But note that if this class contains auxiliary data (e.g. like the numeric coefficients in the
LinearExpression
class) then those values must be evaluated as part of this function call. An uninitialized parameter value encountered during the execution of this method is considered an error.Parameters: values (list) – A list of values that indicate the value of the children expressions. Returns: A floating point value for this expression.

_compute_polynomial_degree
(result)[source] Compute the polynomial degree of this expression given the degree values of its children.
This method is called by the
_PolynomialDegreeVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of values that indicate the degree of the children expression. Returns: A nonnegative integer that is the polynomial degree of the expression, or None
. Default isNone
.

_to_string
(values, verbose, smap)[source] Construct a string representation for this node, using the string representations of its children.
This method is called by the
_ToStringVisitor
class. It must must be defined in subclasses.Parameters: Returns: A string representation for this node.

getname
(*args, **kwds)[source] Return the text name of a function associated with this expression object.
In general, no arguments are passed to this function.
Parameters:  *arg – a variable length list of arguments
 **kwds – keyword arguments
Returns: A string name for the function.

nargs
()[source] Returns the number of child nodes.
Note
Individual expression nodes may use different internal storage schemes, so it is imperative that developers use this method and not assume the existence of a particular attribute!
Returns: int Return type: A nonnegative integer that is the number of child nodes.


class
pyomo.core.expr.current.
ExternalFunctionExpression
(args, fcn=None)[source] Bases:
NumericExpression
External function expressions
Example:
model = ConcreteModel() model.a = Var() model.f = ExternalFunction(library='foo.so', function='bar') expr = model.f(model.a)
Parameters:  args (tuple) – children of this node
 fcn – a class that defines this external function

_apply_operation
(result)[source] Compute the values of this node given the values of its children.
This method is called by the
_EvaluationVisitor
class. It must be overwritten by expression classes to customize this logic.Note
This method applies the logical operation of the operator to the arguments. It does not evaluate the arguments in the process, but assumes that they have been previously evaluated. But note that if this class contains auxiliary data (e.g. like the numeric coefficients in the
LinearExpression
class) then those values must be evaluated as part of this function call. An uninitialized parameter value encountered during the execution of this method is considered an error.Parameters: values (list) – A list of values that indicate the value of the children expressions. Returns: A floating point value for this expression.

_compute_polynomial_degree
(result)[source] Compute the polynomial degree of this expression given the degree values of its children.
This method is called by the
_PolynomialDegreeVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of values that indicate the degree of the children expression. Returns: A nonnegative integer that is the polynomial degree of the expression, or None
. Default isNone
.

_fcn

_to_string
(values, verbose, smap)[source] Construct a string representation for this node, using the string representations of its children.
This method is called by the
_ToStringVisitor
class. It must must be defined in subclasses.Parameters: Returns: A string representation for this node.

create_node_with_local_data
(args, classtype=None)[source] Construct a node using given arguments.
This method provides a consistent interface for constructing a node, which is used in tree visitor scripts. In the simplest case, this simply returns:
self.__class__(args)
But in general this creates an expression object using local data as well as arguments that represent the child nodes.
Parameters: args (list) – A list of child nodes for the new expression object Returns: A new expression object with the same type as the current class.

getname
(*args, **kwds)[source] Return the text name of a function associated with this expression object.
In general, no arguments are passed to this function.
Parameters:  *arg – a variable length list of arguments
 **kwds – keyword arguments
Returns: A string name for the function.

nargs
()[source] Returns the number of child nodes.
Note
Individual expression nodes may use different internal storage schemes, so it is imperative that developers use this method and not assume the existence of a particular attribute!
Returns: int Return type: A nonnegative integer that is the number of child nodes.

class
pyomo.core.expr.current.
ProductExpression
(args)[source] Bases:
NumericExpression
Product expressions:
x*y

PRECEDENCE
= 4 Return the associativity of this operator.
Returns 1 if this operator is lefttoright associative or 1 if it is righttoleft associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

_apply_operation
(result)[source] Compute the values of this node given the values of its children.
This method is called by the
_EvaluationVisitor
class. It must be overwritten by expression classes to customize this logic.Note
This method applies the logical operation of the operator to the arguments. It does not evaluate the arguments in the process, but assumes that they have been previously evaluated. But note that if this class contains auxiliary data (e.g. like the numeric coefficients in the
LinearExpression
class) then those values must be evaluated as part of this function call. An uninitialized parameter value encountered during the execution of this method is considered an error.Parameters: values (list) – A list of values that indicate the value of the children expressions. Returns: A floating point value for this expression.

_compute_polynomial_degree
(result)[source] Compute the polynomial degree of this expression given the degree values of its children.
This method is called by the
_PolynomialDegreeVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of values that indicate the degree of the children expression. Returns: A nonnegative integer that is the polynomial degree of the expression, or None
. Default isNone
.

_is_fixed
(args)[source] Compute whether this expression is fixed given the fixed values of its children.
This method is called by the
_IsFixedVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of boolean values that indicate whether the children of this expression are fixed Returns: A boolean that is True
if the fixed values of the children are allTrue
.


class
pyomo.core.expr.current.
DivisionExpression
(args)[source] Bases:
NumericExpression
Division expressions:
x/y

PRECEDENCE
= 4 Return the associativity of this operator.
Returns 1 if this operator is lefttoright associative or 1 if it is righttoleft associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

_apply_operation
(result)[source] Compute the values of this node given the values of its children.
This method is called by the
_EvaluationVisitor
class. It must be overwritten by expression classes to customize this logic.Note
This method applies the logical operation of the operator to the arguments. It does not evaluate the arguments in the process, but assumes that they have been previously evaluated. But note that if this class contains auxiliary data (e.g. like the numeric coefficients in the
LinearExpression
class) then those values must be evaluated as part of this function call. An uninitialized parameter value encountered during the execution of this method is considered an error.Parameters: values (list) – A list of values that indicate the value of the children expressions. Returns: A floating point value for this expression.

_compute_polynomial_degree
(result)[source] Compute the polynomial degree of this expression given the degree values of its children.
This method is called by the
_PolynomialDegreeVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of values that indicate the degree of the children expression. Returns: A nonnegative integer that is the polynomial degree of the expression, or None
. Default isNone
.


class
pyomo.core.expr.current.
InequalityExpression
(args, strict)[source] Bases:
RelationalExpression
Inequality expressions, which define lessthan or lessthanorequal relations:
x < y x <= y
Parameters: 
PRECEDENCE
= 9 Return the associativity of this operator.
Returns 1 if this operator is lefttoright associative or 1 if it is righttoleft associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

_apply_operation
(result)[source] Compute the values of this node given the values of its children.
This method is called by the
_EvaluationVisitor
class. It must be overwritten by expression classes to customize this logic.Note
This method applies the logical operation of the operator to the arguments. It does not evaluate the arguments in the process, but assumes that they have been previously evaluated. But note that if this class contains auxiliary data (e.g. like the numeric coefficients in the
LinearExpression
class) then those values must be evaluated as part of this function call. An uninitialized parameter value encountered during the execution of this method is considered an error.Parameters: values (list) – A list of values that indicate the value of the children expressions. Returns: A floating point value for this expression.

_strict

_to_string
(values, verbose, smap)[source] Construct a string representation for this node, using the string representations of its children.
This method is called by the
_ToStringVisitor
class. It must must be defined in subclasses.Parameters: Returns: A string representation for this node.

create_node_with_local_data
(args)[source] Construct a node using given arguments.
This method provides a consistent interface for constructing a node, which is used in tree visitor scripts. In the simplest case, this simply returns:
self.__class__(args)
But in general this creates an expression object using local data as well as arguments that represent the child nodes.
Parameters: args (list) – A list of child nodes for the new expression object Returns: A new expression object with the same type as the current class.

nargs
()[source] Returns the number of child nodes.
Note
Individual expression nodes may use different internal storage schemes, so it is imperative that developers use this method and not assume the existence of a particular attribute!
Returns: int Return type: A nonnegative integer that is the number of child nodes.

property
strict


class
pyomo.core.expr.current.
EqualityExpression
(args)[source] Bases:
RelationalExpression
Equality expression:
x == y

PRECEDENCE
= 9 Return the associativity of this operator.
Returns 1 if this operator is lefttoright associative or 1 if it is righttoleft associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

_apply_operation
(result)[source] Compute the values of this node given the values of its children.
This method is called by the
_EvaluationVisitor
class. It must be overwritten by expression classes to customize this logic.Note
This method applies the logical operation of the operator to the arguments. It does not evaluate the arguments in the process, but assumes that they have been previously evaluated. But note that if this class contains auxiliary data (e.g. like the numeric coefficients in the
LinearExpression
class) then those values must be evaluated as part of this function call. An uninitialized parameter value encountered during the execution of this method is considered an error.Parameters: values (list) – A list of values that indicate the value of the children expressions. Returns: A floating point value for this expression.

_to_string
(values, verbose, smap)[source] Construct a string representation for this node, using the string representations of its children.
This method is called by the
_ToStringVisitor
class. It must must be defined in subclasses.Parameters: Returns: A string representation for this node.

nargs
()[source] Returns the number of child nodes.
Note
Individual expression nodes may use different internal storage schemes, so it is imperative that developers use this method and not assume the existence of a particular attribute!
Returns: int Return type: A nonnegative integer that is the number of child nodes.


class
pyomo.core.expr.current.
SumExpression
(args)[source] Bases:
SumExpressionBase
Sum expression:
x + y
Parameters: args (list) – Children nodes 
PRECEDENCE
= 6 Return the associativity of this operator.
Returns 1 if this operator is lefttoright associative or 1 if it is righttoleft associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

_nargs

property
args
Return the child nodes
Returns: Sequence containing only the child nodes of this node. The return type depends on the node storage model. Users are not permitted to change the returned data (even for the case of data returned as a list), as that breaks the promise of tree immutability. Return type: list or tuple

create_node_with_local_data
(args, classtype=None)[source] Construct a node using given arguments.
This method provides a consistent interface for constructing a node, which is used in tree visitor scripts. In the simplest case, this simply returns:
self.__class__(args)
But in general this creates an expression object using local data as well as arguments that represent the child nodes.
Parameters: args (list) – A list of child nodes for the new expression object Returns: A new expression object with the same type as the current class.

nargs
()[source] Returns the number of child nodes.
Note
Individual expression nodes may use different internal storage schemes, so it is imperative that developers use this method and not assume the existence of a particular attribute!
Returns: int Return type: A nonnegative integer that is the number of child nodes.


class
pyomo.core.expr.current.
GetItemExpression
(args)[source] Bases:
NumericExpression
Expression to call
__getitem__()
on the base object.
PRECEDENCE
= 1 Return the associativity of this operator.
Returns 1 if this operator is lefttoright associative or 1 if it is righttoleft associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

_apply_operation
(result)[source] Compute the values of this node given the values of its children.
This method is called by the
_EvaluationVisitor
class. It must be overwritten by expression classes to customize this logic.Note
This method applies the logical operation of the operator to the arguments. It does not evaluate the arguments in the process, but assumes that they have been previously evaluated. But note that if this class contains auxiliary data (e.g. like the numeric coefficients in the
LinearExpression
class) then those values must be evaluated as part of this function call. An uninitialized parameter value encountered during the execution of this method is considered an error.Parameters: values (list) – A list of values that indicate the value of the children expressions. Returns: A floating point value for this expression.

_args_

_compute_polynomial_degree
(result)[source] Compute the polynomial degree of this expression given the degree values of its children.
This method is called by the
_PolynomialDegreeVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of values that indicate the degree of the children expression. Returns: A nonnegative integer that is the polynomial degree of the expression, or None
. Default isNone
.

_is_fixed
(values)[source] Compute whether this expression is fixed given the fixed values of its children.
This method is called by the
_IsFixedVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of boolean values that indicate whether the children of this expression are fixed Returns: A boolean that is True
if the fixed values of the children are allTrue
.

_to_string
(values, verbose, smap)[source] Construct a string representation for this node, using the string representations of its children.
This method is called by the
_ToStringVisitor
class. It must must be defined in subclasses.Parameters: Returns: A string representation for this node.

getname
(*args, **kwds)[source] Return the text name of a function associated with this expression object.
In general, no arguments are passed to this function.
Parameters:  *arg – a variable length list of arguments
 **kwds – keyword arguments
Returns: A string name for the function.

is_potentially_variable
()[source] Return
True
if this expression might represent a variable expression.This method returns
True
when (a) the expression tree contains one or more variables, or (b) the expression tree contains a named expression. In both cases, the expression cannot be treated as constant since (a) the variables may not be fixed, or (b) the named expressions may be changed at a later time to include nonfixed variables.Returns: A boolean. Defaults to True
for expressions.

nargs
()[source] Returns the number of child nodes.
Note
Individual expression nodes may use different internal storage schemes, so it is imperative that developers use this method and not assume the existence of a particular attribute!
Returns: int Return type: A nonnegative integer that is the number of child nodes.


class
pyomo.core.expr.current.
Expr_ifExpression
(IF_=None, THEN_=None, ELSE_=None)[source] Bases:
NumericExpression
A logical ifthenelse expression:
Expr_if(IF_=x, THEN_=y, ELSE_=z)
Parameters:  IF (expression) – A relational expression
 THEN (expression) – An expression that is used if
IF_
is true.  ELSE (expression) – An expression that is used if
IF_
is false.

PRECEDENCE
= None Return the associativity of this operator.
Returns 1 if this operator is lefttoright associative or 1 if it is righttoleft associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

_apply_operation
(result)[source] Compute the values of this node given the values of its children.
This method is called by the
_EvaluationVisitor
class. It must be overwritten by expression classes to customize this logic.Note
This method applies the logical operation of the operator to the arguments. It does not evaluate the arguments in the process, but assumes that they have been previously evaluated. But note that if this class contains auxiliary data (e.g. like the numeric coefficients in the
LinearExpression
class) then those values must be evaluated as part of this function call. An uninitialized parameter value encountered during the execution of this method is considered an error.Parameters: values (list) – A list of values that indicate the value of the children expressions. Returns: A floating point value for this expression.

_compute_polynomial_degree
(result)[source] Compute the polynomial degree of this expression given the degree values of its children.
This method is called by the
_PolynomialDegreeVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of values that indicate the degree of the children expression. Returns: A nonnegative integer that is the polynomial degree of the expression, or None
. Default isNone
.

_else

_if

_is_fixed
(args)[source] Compute whether this expression is fixed given the fixed values of its children.
This method is called by the
_IsFixedVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of boolean values that indicate whether the children of this expression are fixed Returns: A boolean that is True
if the fixed values of the children are allTrue
.

_then

_to_string
(values, verbose, smap)[source] Construct a string representation for this node, using the string representations of its children.
This method is called by the
_ToStringVisitor
class. It must must be defined in subclasses.Parameters: Returns: A string representation for this node.

getname
(*args, **kwds)[source] Return the text name of a function associated with this expression object.
In general, no arguments are passed to this function.
Parameters:  *arg – a variable length list of arguments
 **kwds – keyword arguments
Returns: A string name for the function.

is_potentially_variable
()[source] Return
True
if this expression might represent a variable expression.This method returns
True
when (a) the expression tree contains one or more variables, or (b) the expression tree contains a named expression. In both cases, the expression cannot be treated as constant since (a) the variables may not be fixed, or (b) the named expressions may be changed at a later time to include nonfixed variables.Returns: A boolean. Defaults to True
for expressions.

nargs
()[source] Returns the number of child nodes.
Note
Individual expression nodes may use different internal storage schemes, so it is imperative that developers use this method and not assume the existence of a particular attribute!
Returns: int Return type: A nonnegative integer that is the number of child nodes.

class
pyomo.core.expr.current.
UnaryFunctionExpression
(args, name=None, fcn=None)[source] Bases:
NumericExpression
An expression object used to define intrinsic functions (e.g. sin, cos, tan).
Parameters:  args (tuple) – Children nodes
 name (string) – The function name
 fcn – The function that is used to evaluate this expression

PRECEDENCE
= None Return the associativity of this operator.
Returns 1 if this operator is lefttoright associative or 1 if it is righttoleft associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

_apply_operation
(result)[source] Compute the values of this node given the values of its children.
This method is called by the
_EvaluationVisitor
class. It must be overwritten by expression classes to customize this logic.Note
This method applies the logical operation of the operator to the arguments. It does not evaluate the arguments in the process, but assumes that they have been previously evaluated. But note that if this class contains auxiliary data (e.g. like the numeric coefficients in the
LinearExpression
class) then those values must be evaluated as part of this function call. An uninitialized parameter value encountered during the execution of this method is considered an error.Parameters: values (list) – A list of values that indicate the value of the children expressions. Returns: A floating point value for this expression.

_compute_polynomial_degree
(result)[source] Compute the polynomial degree of this expression given the degree values of its children.
This method is called by the
_PolynomialDegreeVisitor
class. It can be overwritten by expression classes to customize this logic.Parameters: values (list) – A list of values that indicate the degree of the children expression. Returns: A nonnegative integer that is the polynomial degree of the expression, or None
. Default isNone
.

_fcn

_name

_to_string
(values, verbose, smap)[source] Construct a string representation for this node, using the string representations of its children.
This method is called by the
_ToStringVisitor
class. It must must be defined in subclasses.Parameters: Returns: A string representation for this node.

create_node_with_local_data
(args, classtype=None)[source] Construct a node using given arguments.
This method provides a consistent interface for constructing a node, which is used in tree visitor scripts. In the simplest case, this simply returns:
self.__class__(args)
But in general this creates an expression object using local data as well as arguments that represent the child nodes.
Parameters: args (list) – A list of child nodes for the new expression object Returns: A new expression object with the same type as the current class.

getname
(*args, **kwds)[source] Return the text name of a function associated with this expression object.
In general, no arguments are passed to this function.
Parameters:  *arg – a variable length list of arguments
 **kwds – keyword arguments
Returns: A string name for the function.

nargs
()[source] Returns the number of child nodes.
Note
Individual expression nodes may use different internal storage schemes, so it is imperative that developers use this method and not assume the existence of a particular attribute!
Returns: int Return type: A nonnegative integer that is the number of child nodes.

class
pyomo.core.expr.current.
AbsExpression
(arg)[source] Bases:
UnaryFunctionExpression
An expression object for the
abs()
function.Parameters: args (tuple) – Children nodes 
create_node_with_local_data
(args, classtype=None)[source] Construct a node using given arguments.
This method provides a consistent interface for constructing a node, which is used in tree visitor scripts. In the simplest case, this simply returns:
self.__class__(args)
But in general this creates an expression object using local data as well as arguments that represent the child nodes.
Parameters: args (list) – A list of child nodes for the new expression object Returns: A new expression object with the same type as the current class.
