B ÔÂ_”sã@s0ddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl m Z ddl m Z mZmZddlmZddlmZmZmZmZmZmZmZmZddlmZmZddlmZm Z ddl!Z"ddl#m$Z$dd l%m&Z&m'Z'dd l(m)Z)e *d ¡Z+ej, -e.¡Z/d Z0d Z1iZ2ej3ej4e j5dfe2d<ej6ej7e j8dfe2d<ej9ej7e j9dfe2d<ej6ej7e j:dfe2d<ej9ej7e j;dfe2d<ej9ej7e j;dfe2d<ej3ejejdfe2d<ej?ejr?r@ÚactionrŠ)Zap_kwdsrA) rr;rKrr r rr rD)rFr8r8r9Úrunddsip_register_options{s@  r­c CsFt ¡}t|ƒ}| ¡tdƒtdƒtƒ}|j}t|ƒdkr¬t|ƒtkrŒxZ|D]0}d|ksft ‚|  d¡\}}|  ¡|j |  ¡<qVWn x|  ¡D]\}}||j |<q–W|j|dd} |j|| |j|j|jd} | j} | `tdƒt| ƒ|jrtdƒ|j ¡|j ¡|j ¡WdQRXtdƒtd t ¡|ƒdS) zR Construct a senario tree manager and solve it with the DDSIP solver. r"z8Running DDSIP solver for stochastic programming problemsrú=T)Úsparse)rFrqr©rªNz!Total execution time=%.2f seconds)rhrZ initializerbr;r«rYÚtypeÚtupler*r%r$rFÚitemsZextract_user_options_to_dictZsolverqr©rªror¨r(ZsnapshotSolutionFromScenariosZpprintSolutionZ pprintCosts) rFÚ start_timerprHr«Zname_valr'rrsZ ddsip_optionsrxror8r8r9Úrunddsip¥sH        r´c Cs\ddl}yt|tddd}Wn$tk r@}z|jSd}~XYnXtt|d|j|j|j dS)Nrr´z5Optimize a stochastic program using the DDSIP solver.)Úprogr>z runddsip: )Z error_labelr¦Z profile_countr–) Z pyomo.environrr­Ú SystemExitÚcoderr´r¦r§r–)ÚargsrcrFZ_excr8r8r9ÚmainØs r¹rHÚ__main__)N)N)Hr†r[ÚsysrhÚshutilÚloggingr–Zpyutilib.subprocessriZpyutilib.servicesZ pyomo.corerZ pyomo.optrrrZ!pyomo.pysp.util.configured_objectrZpyomo.pysp.util.configrrr r r r r rZpyomo.pysp.util.miscrrZpyomo.pysp.scenariotree.managerrrZpyomo.pysp.convert.ddsiprcZpyomo.pysp.embeddedsprZpyomo.pysp.solvers.spsolverrrZ'pyomo.pysp.solvers.spsolvershellcommandrÚ getLoggerr”r\ÚabspathÚ__file__ZthisfilerDZ_firststage_var_suffixrœržZabortedZ userInterruptZstoppedByLimitÚokZmaxEvaluationsZoptimalZ maxTimeLimitZ minStepLengthÚwarningZinvalidProblemZ infeasibleZ unboundedr:r;r­r´r¹Zregister_solverr Úexitr8r8r8r9ÚsŒ  (             4Y *3 "