SimpleExpressionVisitor
(class from pyomo.core.expr.visitor)
- class pyomo.core.expr.visitor.SimpleExpressionVisitor(*args, **kwargs)[source]
Bases:
objectDEPRECATED.
Note
This class is a customization of the PyUtilib
SimpleVisitorclass that is tailored to efficiently walk Pyomo expression trees. However, this class is not a subclass of the PyUtilibSimpleVisitorclass because all key methods are reimplemented.Deprecated since version 6.9.0: The SimpleExpressionVisitor is deprecated. Please use the StreamBasedExpressionVisitor instead.
- __init__(*args, **kwargs)
DEPRECATED.
Initialize self. See help(type(self)) for accurate signature.
Deprecated since version 6.9.0: The SimpleExpressionVisitor is deprecated. Please use the StreamBasedExpressionVisitor instead.
Methods
__init__(*args, **kwargs)DEPRECATED.
finalize()Return the "final value" of the search.
visit(node)Visit a node in an expression tree and perform some operation on it.
xbfs(node)Breadth-first search of an expression tree, except that leaf nodes are immediately visited.
xbfs_yield_leaves(node)Breadth-first search of an expression tree, except that leaf nodes are immediately visited.
Member Documentation
- finalize()[source]
Return the “final value” of the search.
The default implementation returns
None, because the traditional visitor pattern does not return a value.- Returns:
The final value after the search. Default is
None.
- visit(node)[source]
Visit a node in an expression tree and perform some operation on it.
This method should be over-written by a user that is creating a sub-class.
- Parameters:
node – a node in an expression tree
- Returns:
nothing
- xbfs(node)[source]
Breadth-first search of an expression tree, except that leaf nodes are immediately visited.
Note
This method has the same functionality as the PyUtilib
SimpleVisitor.xbfsmethod. The difference is that this method is tailored to efficiently walk Pyomo expression trees.- Parameters:
node – The root node of the expression tree that is searched.
- Returns:
The return value is determined by the
finalize()function, which may be defined by the user. Defaults toNone.
- xbfs_yield_leaves(node)[source]
Breadth-first search of an expression tree, except that leaf nodes are immediately visited.
Note
This method has the same functionality as the PyUtilib
SimpleVisitor.xbfs_yield_leavesmethod. The difference is that this method is tailored to efficiently walk Pyomo expression trees.- Parameters:
node – The root node of the expression tree that is searched.
- Returns:
The return value is determined by the
finalize()function, which may be defined by the user. Defaults toNone.