B _$@sddlZddlmZddlmZmZmZmZmZm Z m Z m Z ddl m Z ddlmZedZejddd Gd d d eZdS) N)iterkeys)TransformationTransformationFactory ConstraintVarBlock ComponentUIDSortComponentsvalue)Complementarity)Disjunctz pyomo.corezmpec.nlz7Transform a MPEC into a form suitable for the NL writer)doccs4eZdZfddZddZddZddZZS) MPEC4_Transformationcstt|dS)N)superr__init__)self) __class__|jtdtjttfdD]}|t |||t |<q2Wg}xd|j t dttftjdD]H}| } ||x0t t|D] } || } | jsq|| |qWqrW|jd} g| _x,|D]$}| jt|| |tqWdS)NoptionsT)activesort descend_into)rrrzmpec.nl)popmodelcomponent_data_objectsrr deterministicrr appendidZcomponent_objectsr Z parent_blocksortedrrto_common_formZ_transformation_dataZ compl_cuidsrZreclassify_component_type) rinstancekwdsr free_varsZid_listvdataZcobjscobjbdataindexZ_cdataZtdatarrr _apply_to&s0     zMPEC4_Transformation._apply_toc Csi}x"|jtddD]}||t|<qWtdx~|jdtjdD]j}xd|jtdddD]P}tdt|dd t |j d t |j d t |j | t|d d d fqXWqBWtdd S) zJ Summarize the complementarity relations in this problem. T)rzC-------------------- Complementary Relations ----------------------)rrF)rrz %s %s %s_complementarityNz < _vid)rrrprintZblock_data_objectsr rrgetattrstrlowerbodyupperget)rr!Zvmapr$r&r%rrr print_nl_formNsTz"MPEC4_Transformation.print_nl_formcCs||jd}||jd}t|dkr s (