B _S@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl ZddlZedZddZddZeejjjded d d d d dZddZddZddZddZddZddZddZddZdd Z d!d"Z!e!ejjjd#e d$d%d&Z"dS)'N)Optionsz pyomo.solverscCs(|jdddddd|jddd d dS) Nz--listsummary store_trueFz/List the commands that are installed with Pyomo)destactiondefaulthelpcommand*z$The command and command-line options)nargsr) add_argument)parserr?/tmp/pip-unpacked-wheel-d4p3hk07/pyomo/scripting/driver_help.pysetup_command_parser"s rcCstjtjtjtj}|jrtdtdtdx.t t |dD]}tdtj |qNWtdt |j dkrtddSt |j dkrtdd Stj||j dstd ||j dd Stjj|d|j d d dS) Nz@The following commands are installed in the Pyomo bin directory:z@----------------------------------------------------------------r  rz'WARNING: ignoring command specificationz ERROR: no command specifiedz( ERROR: the command '%s' does not existT)tee)ospathdirnameabspathsys executableseprprintsortedglobbasenamelenr existspyutilib subprocessrunjoin)optionscmddirfilerrr command_exec's$r)r$z[sz help_commands..z %%-%ds %%scSs|S)N)upper)vrrr]zhelp_commands..)r.)rpyomocommonZget_pyomo_commandsmaxrkeys)registrydfmtr.rrr help_commandsVs r;cCsvddl}ddlm}t}d|_d|_tdtdtdx0t|D]$}td|t| | |qJWdS)Nr) WriterFactoryz rzPyomo Problem Writersz---------------------z ) pyomo.environZpyomo.opt.baser<textwrap TextWrapperinitial_indentsubsequent_indentrrfilldoc)r4r<wrapperwriterrrr help_writersas  rFcCsddl}ddl}ddlm}t}d|_d|_tdtdtd|j j |}i}x8| D],}x&t |dtD]}|d||d<qxWqdWx2t|D]"}td |t|||qWdS) Nr) IModelCheckerz rzPyomo Model Checkersz--------------------Z_factory_aliasesrz )r=Zpyomo.common.pluginZ pyomo.checkerrGr>r?r@rArr5ZpluginZExtensionPoint extensionsgetattrsetrr7rB)r4rGrDeptmpcheckeraliasr.rrr help_checkersns"  rOcCsvddl}ddlm}t}d|_d|_tdtdtdx0t|D]$}td|t| | |qJWdS)Nr)DataManagerFactoryz rzPyomo Data Managersz-------------------z ) r=Zpyomo.dataportalrPr>r?r@rArrrBrC)r&r4rPrDxformrrrhelp_datamanagerss  rRc Cstjj}i}x|D]}tj|||<qWi}x*|D]"}|||jt}||q8W|jrt dt dt dt dt j t dt dt dxt |D]}t d|d}t d|xt ||D]}|dkr|t|dd}n|}t dt d |t ||j||jdkrZt dt ||jt dd } t d xVt ||jD]D} ||j| jrd } q~t dt d | ||j| jfq~W| r0t dt dxRt ||jD]@} ||j| jsqt dt d | ||j| jfqWt dt dxThe Pyomo library contains a set of functors that define operations that are likely to be major steps in Pyomo scripts. This API is defined with functors to ensure a consistent function syntax. Additionally, these functors can be accessed with a factory, thereby avoiding the need to import modules throughout Pyomo.-: z )r4r5ZPyomoAPIFactoryservices setdefaultZ __namespace__rJaddasciidocrdatetimedatetodayrr7r Z __short_doc__Z __long_doc__inputsoptionalrCoutputsr>r?rBsplit) r&rVfnamensZns_setZns_levelZtnameflagportrDlinerrrhelp_apis      """   rhcCstjtjtjtj}t}t|_dtj dd|j_ tj|j_tj |j_ y@g}ddl }x&| D]}|t|j|j dqlW||j_Wn YnXt|_tjdd}|dk r|tj|jd<tj|jd<tdtd tdtt|dS) Nz%d.%d.%dr)rbversionPATHz shell pathz python path#z4# Information About the Python and Shell Environment)rrrrrrrrpython version_inforjplatformpipget_installed_distributionsappend project_namepackages environmentenvirongetr`pathseprstr)r'infortrppackagerrrrhelp_environments.    r|cCsddl}ddlm}t}d|_d|_tdtdtdxnt|D]b}td|| |pfd}| |j j pxd}| drd |krd d |f}|rJt||qJWdS) Nr)TransformationFactoryz rzPyomo Model Transformationsz---------------------------z Z DEPRECATIONZDEPRECATrz [DEPRECATED])r=Z pyomo.corer}r>r?r@rArrrCZ get_class__init____doc__ startswithr%rB)r4r}rDrQ_docZ _init_docrrrhelp_transformationss"  rc Csddl}tjdd}tdtdtdt|dtdt|jj}tt dd |}t t t |}tjd |d d }x<|D]4}d t |d}t||||jj|fqWtdtjdd }t|dtdtdtdtdt|dtdt|jj}tt dd |}g}z.ttjx|D]}|j|}d} |drd} t|dsd} n|rd} y\|} | rx.t | dkr| ddkr| dd} qWddd| D} nd} Wnttfk rYnXn(|dks2t|dr8|jr8d} nd} || || |jj|fWdQRXqRWWdttjXt dd|D} t d d|D} d!| | f} tjd | | d"d }x |D]}t|| |qWtdtjdd }t|d#tdt|d$tdtd%tdt|d&tdt|d'tdtd(tdz2yttjtd)ddl}|j j!"}tt#d*d+|$D}t |dkrZtdtd,td-t|d.tdt|}t t t |}d t |d}x0|D](}t||||j j%|d/fq$Wtdn.tdtd,td-t|d0tdWnt&k rYnXWdttjtdXdS)1NrF)replace_whitespacerz!Pyomo Solvers and Solver Managersz!---------------------------------aPyomo uses 'solver managers' to execute 'solvers' that perform optimization and other forms of model analysis. A solver directly executes an optimizer, typically using an executable found on the user's PATH environment. Solver managers support a flexible mechanism for asyncronously executing solvers either locally or remotely. The following solver managers are available in Pyomo:cSs d|dkS)N_rr)xrrrr2r3zhelp_solvers..r )rAz %-zs %saIf no solver manager is specified, Pyomo uses the serial solver manager to execute solvers locally. The pyro and phpyro solver managers require the installation and configuration of the pyro software. The neos solver manager is used to execute solvers on the NEOS optimization server.zSerial Solver Interfacesz------------------------zTThe serial, pyro and phpyro solver managers support the following solver interfaces:cSs d|dkS)Nrrr)rrrrr2/r3rSlicense_is_valid+.css|]}t|VqdS)N)ry)r-r1rrrr/Cszhelp_solvers..py _metasolverr css|]}t|dVqdS)rN)r )r-rgrrrr/Tscss|]}t|dVqdS)rN)r )r-rgrrrr/Usz %%1s%%-%ds %%-%ds %%saThe leading symbol (one of *, -, +) indicates the current solver availability. A plus (+) indicates the solver is currently available to be run from Pyomo with the serial solver manager, and (if applicable) has a valid license. A minus (-) indicates the solver executables are available but do not reporthaving a valid license. The solver may still be usable in an unlicensed or "demo" mode for limited problem sizes. An asterisk (*) indicates meta-solvers or generic interfaces, which are always available.aPyomo also supports solver interfaces that are wrappers around third-party solver interfaces. These interfaces require a subsolver specification that indicates the solver being executed. For example, the following indicates that the ipopt solver will be used:z asl:ipoptz^The asl interface provides a generic wrapper for all solvers that use the AMPL Solver Library.a"Note that subsolvers can not be enumerated automatically for these interfaces. However, if a solver is specified that is not found, Pyomo assumes that the asl solver interface is being used. Thus the following solver name will launch ipopt if the 'ipopt' executable is on the user's path:z ipopt cSs&g|]}|dr|ddqS)ZAMPLN)endswithlower)r-rbrrr psz help_solvers..zNEOS Solver Interfacesz----------------------zThe neos solver manager supports solver interfaces that can be executed remotely on the NEOS optimization server. The following solver interfaces are available with your current system configuration:zUnexpected NEOS solverzThe neos solver manager supports solver interfaces that can be executed remotely on the NEOS optimization server. This server is not available with your current system configuration.)'r=r>r?rrBlistoptZSolverManagerFactoryrfilterr6mapr ryrCZ SolverFactoryloggingdisableWARNING availablehasattrrrjr%AttributeError NameErrorrrrNOTSETsocketsetdefaulttimeoutZpyomo.neos.kestrelZneoskestrelZ kestrelAMPLrJsolversrw ImportError)r4rDZsolvermgr_listnsformatZ solver_list_datarverZavailZ nameFieldLenZ verFieldLenr:_linerrbrrr help_solverss   $      0       (    rcCs tdtdtdtdtjjj}tj|}xR|D]J}tdtd||dx(t ||ddD]}td|qvWq@Wtdtdtd tdtjjj }tj|}x<|D]4}tdtd||dtd||dqWd S) zI Print information about modeling components supported by Pyomo. rz@----------------------------------------------------------------zPyomo Model Components:rrr;z zPyomo Virtual Sets:N) rr4corebaseZ_pyomoZmodel_componentsr"miscZ sort_indexr>wrapZpredefined_sets)data componentsindexirgZ pyomo_setsrrrprint_componentss*    rcCsd}|jr"|jrtdd}t|jrB|jr6tdd}td|jrTd}t||jrfd}t ||j rvd}t |j r|jrtdd}t |jr|jrtdd}t|jrd}|jrtdt|jrd}|jrtdt|stdS) NFzGThe '--commands' help information is not printed in an asciidoc format.TzIThe '--components' help information is not printed in an asciidoc format.zNThe '--transformations' help information is not printed in an asciidoc format.zFThe '--solvers' help information is not printed in an asciidoc format.zFThe '--writers' help information is not printed in an asciidoc format.zGThe '--checkers' help information is not printed in an asciidoc format.)commandsrYrr;rrapirh datamanagerrRrur|transformationsrrrwritersrFcheckersrO help_parser print_help)r&rerrr help_execsTrcCs|jddddddd|jdd ddd d|jd d ddd d|jddddddd|jdddddd|jddddddd|jddddddd|jdddddd d|jd!d"d#ddd$d|jd%d&d'ddd(d|S))Nz-az--apirrFz(Print a summary of the Pyomo Library API)rrrrz --asciidocrYzBGenerate output that is compatible with asciidoc's markup languagez --checkersrz!List the available model checkersz-cz --commandsrz/List the commands that are installed with Pyomoz --componentsrzFList the components that are available in Pyomo's modeling environmentz-dz--data-managersrz-Print a summary of the data managers in Pyomoz-iz--inforuz1Summarize the environment and Python installationz-sz --solversrz5Summarize the available solvers and solver interfacesz-tz--transformationsrz(List the available model transformationsz-wz --writersrz"List the available problem writers)r )r rrrsetup_help_parsers*   rrzPrint help information.zjThis pyomo subcommand is used to print information about Pyomo's subcommands and installed Pyomo services.)r*rr+)#ros.pathrrrZr>rargparserZpyutilib.subprocessr"Z pyutilib.miscrZ pyomo.commonr4Zpyomo.scripting.pyomo_parser getLoggerloggerrr) scriptingZ pyomo_parserZ add_subparserr;rFrOrRrhr|rrrrrrrrrr sJ       Qv/