BinaryBooleanExpression
(class from pyomo.core.expr.logical_expr
)
- class pyomo.core.expr.logical_expr.BinaryBooleanExpression(args)[source]
Bases:
BooleanExpression
Abstract class for binary logical expressions.
- __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.
equivalent_to
(other)Construct an EquivalenceExpression between this BooleanValue and its operand.
getname
(*args, **kwds)Return the text name of a function associated with this expression object.
implies
(other)Construct an ImplicationExpression using method "implies"
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 Logical value is an indexed object
Return True if this class is a Pyomo Boolean object.
Return
True
if this object is a named expression.Boolean values are not numeric.
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
land
(other)Construct an AndExpression (Logical And) between this BooleanValue and other.
lor
(other)Construct an OrExpression (Logical OR) between this BooleanValue and other.
nargs
()Return the number of argument the expression has
size
()Return the number of nodes in the expression tree.
to_string
([verbose, labeler, smap, ...])Return a string representation of the expression tree.
xor
(other)Construct an XorExpression using method "xor"
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.
- equivalent_to(other)
Construct an EquivalenceExpression between this BooleanValue and its operand.
- 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.
- implies(other)
Construct an ImplicationExpression using method “implies”
- 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 Logical 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()
Boolean values are not numeric.
- 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 Logical 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
- land(other)
Construct an AndExpression (Logical And) between this BooleanValue and other.
- lor(other)
Construct an OrExpression (Logical OR) between this BooleanValue and other.
- 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.
- xor(other)
Construct an XorExpression using method “xor”
- PRECEDENCE = 0
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
- Returns: Either a list or tuple (depending on the node storage
model) containing only the child nodes of this node