B _@sddlZddlmZddlmZddlmZmZmZm Z m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZddZedZejd d d Gd d d eZdS)N) iteritems) deprecated) TransformationTransformationFactoryVar Constraint ObjectiveSetminimizeNonNegativeRealsNonPositiveRealsRealsBlockModel ConcreteModel)collect_linear_termscCsdS)Nrrr9/tmp/pip-unpacked-wheel-d4p3hk07/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_mapritems RuntimeError_dualize) rinstancekwdsrZbnamernamedataZ instance_rrr _create_using8s    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],)r rtypetuplejoinmapstrsetattr)r&ndxvZv_name)_varsdualrrgetvarhs   z7LinearDual_PyomoTransformation._dualize..getvarc3s*|]"\}}||f ||VqdS)Nr).0r&r0)b_coefr4rr ysz:LinearDual_PyomoTransformation._dualize..)exprZsensec3s(|] \}}||f||VqdS)Nr)r5r&r0)r6r4rrr7{srgel)r8z%s[%s]r)ZlbZub)N)r isinstancerrrZ constructr rsumorZcoefvarr0rr*r+r,r-r.r/r domainr r )rrZunfixedAZc_rhsZc_senseZd_senseZvnamesZcnamesZv_domaincnamer0Ztermsr8Ztermr9cZc_namer&rAr1flagr)r2r6r3r4rr#OsL $"     (  z'LinearDual_PyomoTransformation._dualize)__name__ __module__ __qualname__rrr(r# __classcell__rr)rrr+s r)loggingsixrZpyomo.common.deprecationrZpyomo.core.baserrrrrr r r r r rrrZpyomo.duality.collectrr getLoggerloggerregisterrrrrr s  <