preorder_traversal
(function from pyomo.kernel.util
)
- pyomo.kernel.util.preorder_traversal(node, ctype=<class 'pyomo.core.kernel.base._no_ctype'>, active=True, descend=True)[source]
A generator that yields each object in the storage tree (including the root object) using a preorder traversal.
- Parameters:
node – The root object.
ctype – Indicates the category of components to include. The default value indicates that all categories should be included.
active (
True
/None
) – Controls whether or not to filter the iteration to include only the active part of the storage tree. The default isTrue
. Setting this keyword toNone
causes the active status of objects to be ignored.descend (bool, function) – Controls if a container object should be descended into during the traversal. When a function is supplied, each container object will be passed into it and the return value will indicate if the traversal continues into children of the container. Default is True, which is equivalent to lambda x: True.
- Returns:
iterator of objects in the storage tree, including the root object