B _@sVddlZddlZddlZddlmZmZmZej j j dddGdddej j Z dS)N)TransformationFactoryVarSet bilevel_bqpz,Global solver for bilevel quadratic problems)docc@s,eZdZddZddZddZddZd S) BILEVEL_Solver4cKs$d|d<tjjj|f|d|_dS)NrtypeT)pyomoopt OptSolver__init__Z _metasolver)selfkwdsrA/tmp/pip-unpacked-wheel-d4p3hk07/pyomo/bilevel/plugins/solver4.pyr szBILEVEL_Solver4.__init__cOs$|d|_tjjj|f||dS)Nr) _instancer r r _presolve)r argsrrrrrs zBILEVEL_Solver4._presolvec Cst}|jjsd|_n |jj|_td}||jtd}||jtd}|j|j|jd|jdtd}||jtd}|j|jdd|jj}|sd }t j |.}g|_ |j |j|j|j|jd d d WdQRXt}|||_|jjdj|j}x>|jd d D]*\}}t|ts$t|ts$|q$W|jjdj|jtjjt |d dt |dddS)Nizbilevel.linear_mpeczmpec.simple_disjunctionzgdp.bigmbigM)rz gdp.bilineari"ZglpkF)teeZ timelimitZsymbolic_solver_labelsZ keepfiles)activeZ_rc_log)rclog)!timeoptionsrZ_bigMrZapply_torgetsolverr r SolverFactoryresultsappendZsolve_teeZ _timelimit wall_timeZ_transformation_dataZ submodel_cuidZfind_componentZ component_mapitems isinstancerractivateZ block_cuidZ deactivatepyutilibmiscZBunchgetattr) r start_timeZxfrmrr Z stop_timeZsubmodelnamedatarrr _apply_solversB      zBILEVEL_Solver4._apply_solvercCstj}|j}|jj|_|j|_g}x.|j D]$}t |jdddk r.| |jj q.Wt |dkrlt||_ tjjj|_|j}|jj|_|jjj|_|jjj|_|jjj|_|jjj|_|jjj|_|jjj|_|jj|d|_|S)Ncpu_timer)r r Z SolverResultsrrZ subsolverr*r"Zwallclock_timerr(r r-lensumZTerminationConditionZoptimalZtermination_conditionZproblemrZ statisticsZnumber_of_constraintsZnumber_of_variablesZnumber_of_binary_variablesZnumber_of_integer_variablesZnumber_of_continuous_variablesZnumber_of_objectivesZ solutionsZstore_to)r rZsolvZcpu_resZprobrrr _postsolveis,             zBILEVEL_Solver4._postsolveN)__name__ __module__ __qualname__r rr,r1rrrrrsKr)rZ pyutilib.miscr&Z pyomo.optr Z pyomo.corerrrr rregisterr rrrrr s