B u `E$@sddlZddlZddlmZddlZddlmZddl m Z m Z m Z m Z ddlZe ddfddZedfd d Zdejfd d ZdS) N) ComponentMap) NumericValue)ICategorizedObject _no_ctype_convert_ctype_convert_descend_intoTc #sf|dks t|dk r|jsdSt||}t|tksL|j|ksL|jjrR|V|jr`|sddSx| D]}|j}|js|dks|jr|tks||kr|Vqn|jrxt |||dD] }|VqWqn|jr,fdd}x|t |||dD]6}|js|Vqx t |||dD] }|VqWqWqn|tks>||krnxt ||dD] }|VqNWqnWdS)a A generator that yields each object in the storage tree (including the root object) using a preorder traversal. Args: node: The root object. ctype: Indicates the category of components to include. The default value indicates that all categories should be included. active (:const:`True`/:const:`None`): Controls whether or not to filter the iteration to include only the active part of the storage tree. The default is :const:`True`. Setting this keyword to :const:`None` 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 )NTN)ctypeactivedescendcs|jr dS|SdS)NF)_is_heterogeneous_container)Zobj_)r 5/tmp/pip-unpacked-wheel-n62dbgi3/pyomo/kernel/util.pydescend_isz$preorder_traversal..descend_)r r ) AssertionErrorr rgetrrrr _is_containerchildrenpreorder_traversal) noderr r childZ child_ctypeobjritemr )r r rsb          rc Kst|f|}t}yt|Wntk r4|SXxN|D]F}|j}|j||j}||k rv|||j|||<q<||||<qszpprint..z%s: %s(active=%s, size=%s) z%s: %s(active=%s, ctype=%s) ), isinstancerrwriter(r_pprint_pprintr __class____name__rpyomocorekernelvariableZ IVariabler valueZlbZubZ domain_typeZfixedstale constraintZ IConstraintexprZ objectiveZ IObjectiveZ expressionZ IExpressionZ parameterZ IParameterZsosZISOSlevelzip variablesweightssuffixZISuffixr!lenr)rr&r'rZclsnamecr r r r0s|     "  $  r0)sysr0r/Zpyomo.common.collectionsrZ pyomo.corer3Zpyomo.core.expr.numvaluerZpyomo.core.kernel.baserrrrrrr(r"stdoutr r r r  s   j /