(class from pyomo.core.expr.visitor)
pyomo.core.expr.visitor
Bases: object
object
Note
This class is a customization of the PyUtilib ValueVisitor class that is tailored to efficiently walk Pyomo expression trees. However, this class is not a subclass of the PyUtilib ValueVisitor class because all key methods are reimplemented.
ValueVisitor
Methods
__init__()
__init__
dfs_postorder_stack(node)
dfs_postorder_stack
Perform a depth-first search in postorder using a stack implementation.
finalize(ans)
finalize
This method defines the return value for the search methods in this class.
visit(node, values)
visit
Visit a node in a tree and compute its value using the values of its children.
visiting_potential_leaf(node)
visiting_potential_leaf
Visit a node and return its value if it is a leaf.
Member Documentation
This method has the same functionality as the PyUtilib ValueVisitor.dfs_postorder_stack method. The difference is that this method is tailored to efficiently walk Pyomo expression trees.
ValueVisitor.dfs_postorder_stack
node – The root node of the expression tree that is searched.
The return value is determined by the finalize() function, which may be defined by the user.
finalize()
The default implementation returns the value of the initial node (aka the root node), because this visitor pattern computes and returns value for each node to enable the computation of this value.
ans – The final value computed by the search method.
The final value after the search. Defaults to simply returning ans.
ans
This method should be over-written by a user that is creating a sub-class.
node – a node in a tree
values – a list of values of this node’s children
The value for this node, which is computed using values
values
This method needs to be over-written for a specific visitor application.
(flag, value). If flag is False, then the node is not a leaf and value is None. Otherwise, value is the computed value for this node.
(flag, value)
flag
value
None
A tuple