NPV_Numeric_GetAttrExpression
(class from pyomo.core.expr.template_expr
)
- class pyomo.core.expr.template_expr.NPV_Numeric_GetAttrExpression(args=())[source]
Bases:
Numeric_NPV_Mixin
,Numeric_GetAttrExpression
- __init__(args)
Methods
__init__
(args)arg
(i)Return the i-th child node.
clone
([substitute])Return a clone of the expression tree.
create_node_with_local_data
(args[, classtype])Construct a node using given arguments.
DEPRECATED.
getname
(*args, **kwds)Return the text name of a function associated with this expression object.
Return True if this class is a Pyomo component
Return True if this expression is an atomic constant
is_expression_type
([expression_system])Return
True
if this object is an expression.is_fixed
()Return
True
if this expression contains no free variables.Return True if this numeric value is an indexed object
Return True if this class is a Pyomo Boolean object.
Return
True
if this object is a named expression.Return True if this class is a Pyomo numeric object
Return False unless this class is a parameter object
Return
True
if this expression might represent a variable expression.Return True if this object is a reference.
DEPRECATED.
Return False unless this class is a variable object
nargs
()Returns the number of child nodes.
Return the polynomial degree of the expression.
potentially_variable_base_class
()size
()Return the number of nodes in the expression tree.
to_string
([verbose, labeler, smap, ...])Return a string representation of the expression tree.
Attributes
Return the associativity of this operator.
Return the child nodes
local_name
name
Member Documentation
- arg(i)
Return the i-th child node.
- Parameters:
i (int) – Index of the child argument to return
Returns (The i-th child node.)
- clone(substitute=None)
Return a clone of the expression tree.
Note
This method does not clone the leaves of the tree, which are numeric constants and variables. It only clones the interior nodes, and expression leaf nodes like
_MutableLinearExpression
. However, named expressions are treated like leaves, and they are not cloned.- Parameters:
substitute (dict) – a dictionary that maps object ids to clone objects generated earlier during the cloning process.
- Returns:
A new expression tree.
- create_node_with_local_data(args, classtype=None)
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 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.
- create_potentially_variable_object()
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 the immutability promise for Pyomo5 expression trees).
- getname(*args, **kwds)
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_component_type()
Return True if this class is a Pyomo component
- is_constant()
Return True if this expression is an atomic constant
This method contrasts with the is_fixed() method. This method returns True if the expression is an atomic constant, that is it is composed exclusively of constants and immutable parameters. NumericValue objects returning is_constant() == True may be simplified to their numeric value at any point without warning.
Note: This defaults to False, but gets redefined in sub-classes.
- is_expression_type(expression_system=None)
Return
True
if this object is an expression.This method obviously returns
True
for this class, but it is included in other classes within Pyomo that are not expressions, which allows for a check for expressions without evaluating the class type.- Returns:
A boolean.
- is_fixed()
Return
True
if this expression contains no free variables.- Returns:
A boolean.
- is_indexed()
Return True if this numeric value is an indexed object
- is_logical_type()
Return True if this class is a Pyomo Boolean object.
Boolean objects include constants, variables, or logical expressions.
- is_named_expression_type()
Return
True
if this object is a named expression.This method returns
False
for this class, and it is included in other classes within Pyomo that are not named expressions, which allows for a check for named expressions without evaluating the class type.- Returns:
A boolean.
- is_numeric_type()
Return True if this class is a Pyomo numeric object
- is_parameter_type()
Return False unless this class is a parameter object
- is_potentially_variable()
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 non-fixed variables.- Returns:
A boolean. Defaults to
True
for expressions.
- is_reference()
Return True if this object is a reference.
- is_relational()
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)
- is_variable_type()
Return False unless this class is a variable object
- nargs()
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.
- polynomial_degree()
Return the polynomial degree of the expression.
- Returns:
A non-negative integer that is the polynomial degree if the expression is polynomial, or
None
otherwise.
- size()
Return the number of nodes in the expression tree.
- Returns:
A nonnegative integer that is the number of interior and leaf nodes in the expression tree.
- to_string(verbose=None, labeler=None, smap=None, compute_values=False)
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 algebraic (infix notation) equation. Defaults toFalse
.labeler – An object that generates string labels for variables in the expression tree. Defaults to
None
.smap – If specified, this
SymbolMap
is used to cache labels for variables.(bool) (compute_values) – If
True
, then parameters and fixed variables are evaluated before the expression string is generated. Default isFalse
.Returns – A string representation for the expression tree.
- PRECEDENCE = 1
Return the associativity of this operator.
Returns 1 if this operator is left-to-right associative or -1 if it is right-to-left 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).
- property args
Return the child nodes