B u `R@sddlZddlmZddlmZddlmZmZmZm Z m Z m Z m Z m Z mZmZmZmZddlmZddZedZejd d d Gd d d eZdS)N) iteritems) deprecated) TransformationTransformationFactoryVar Constraint ObjectiveminimizeNonNegativeRealsNonPositiveRealsRealsBlockModel ConcreteModel)collect_linear_termscCsdS)Nrrr9/tmp/pip-unpacked-wheel-n62dbgi3/pyomo/duality/plugins.pyloadsrz pyomo.corezduality.linear_dualzDualize a linear model)doccs<eZdZedddfddZddZgfdd ZZS) LinearDual_PyomoTransformationa7Use of the pyomo.duality package is deprecated. There are known bugs in pyomo.duality, and we do not recommend the use of this code. Development of dualization capabilities has been shifted to the Pyomo Adversarial Optimization (PAO) library. Please contact William Hart for further details (wehart@sandia.gov).z5.6.2)versioncstt|dS)N)superr__init__)self) __class__rrr,sz'LinearDual_PyomoTransformation.__init__c Ksx|di}|dd}d}|dkr*|}n,x*|jtddD]\}}||kr>|}q>W|dkrjtd|||}|S)NoptionsblockT)activezMissing block: )popgetZ component_mapr items RuntimeError_dualize) rinstancekwdsrZbnamernamedataZ instance_rrr _create_using6s    z,LinearDual_PyomoTransformation._create_usingc sNt||\}}}}}}} t|tr,tntidfdd |tkrzttfddD|d_ n"ttfddD|d_ x|D]} x t || D]\} } d} x$| D]}| |j |j |j 7} qW| | f|krd || | f<|| | fd kr0| || | fdk}n<|| | fd krX| || | fdk}n| || | fdk}t|d }| dkr| }n8t| tkrd | dtt| f}nd | t| f}t||qWxvt | D]j\\}} }|| }t| tko| ddkp| ddk}|dkr(t|_n|dkr:t|_nt|_qWqWS)z. Generate the dual of a block Ncs~||fd}|dkrzt}|dkr,|}n6t|tkrRd|dtt|f}nd|t|f}t|||||f<|S)Nz%s[%s],)rrtypetuplejoinmapstrsetattr)r%ndxvZv_name)_varsdualrrgetvarfs   z7LinearDual_PyomoTransformation._dualize..getvarc3s*|]"\}}||f ||VqdS)Nr).0r%r/)b_coefr3rr wsz:LinearDual_PyomoTransformation._dualize..)exprZsensec3s(|] \}}||f||VqdS)Nr)r4r%r/)r5r3rrr6ysrgel)r7z%s[%s]r(ZlbZub)N)r isinstancerrr Z constructr rsumorZcoefvarr/rr)r*r+r,r-r.r domainr r )rrZunfixedAZc_rhsZc_senseZd_senseZvnamesZcnamesZv_domaincnamer/Ztermsr7Ztermr8cZc_namer%r@r0flagr)r1r5r2r3rr"MsL $"     (  z'LinearDual_PyomoTransformation._dualize)__name__ __module__ __qualname__rrr'r" __classcell__rr)rrr)s r)loggingsixrZpyomo.common.deprecationrZpyomo.core.baserrrrrr r r r r rrZpyomo.duality.collectrr getLoggerloggerregisterrrrrr s  8