B @`KS@sddlZddlZddlZddlZddlZddlZddlZddlZddlZ ddl Z ddl m Z ddlZ edZddZddZee jjjded d d d d dZddZddZddZddZddZddZddZddZdd Zd!d"Z e e jjjd#ed$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-bi3529v6/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)optionsZcmddirfilerrr command_exec&s$r(r$zZsz help_commands..z %%-%ds %%scSs|S)N)upper)vrrr\zhelp_commands..)r-)rpyomocommonZget_pyomo_commandsmaxrkeys)registrydfmtr-rrr help_commandsUs 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)r3r;wrapperwriterrrr help_writers`s  rEcCsddl}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.checkerrFr=r>r?r@rr4ZpluginZExtensionPoint extensionsgetattrsetrr6rA)r3rFrCeptmpcheckeraliasr-rrr help_checkersms"  rNcCsvddl}ddlm}t}d|_d|_tdtdtdx0t|D]$}td|t| | |qJWdS)Nr)DataManagerFactoryz rzPyomo Data Managersz-------------------z ) r<Zpyomo.dataportalrOr=r>r?r@rrrArB)r&r3rOrCxformrrrhelp_datamanagerss  rQc 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 )r3r4ZPyomoAPIFactoryservices setdefaultZ __namespace__rIaddasciidocrdatetimedatetodayrr6r Z __short_doc__Z __long_doc__inputsoptionalrBoutputsr=r>rAsplit) r&rUfnamensZns_setZns_levelZtnameflagportrClinerrrhelp_apis      """   rgcCst}t|_dtjdd|j_tj|j_tj|j_y@g}ddl}x&|D]}| t|j |jdqPW||j_ Wn YnXt|_ t jdd}|dk r|t j|j d<tj|j d<tdtd tdtt|dS) Nz%d.%d.%dr)raversionPATHz shell pathz python path#z4# Information About the Python and Shell Environment)rpythonr version_inforirplatformpipget_installed_distributionsappend project_namepackages environmentrenvirongetr_pathseprrstr)inforsropackagerrrrhelp_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?r@rrrBZ get_class__init____doc__ startswithr%rA)r3r|rCrP_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}zttjx|D]}|j|}d} |drd} |rd} y\|} | rx.t | dkr| ddkr| dd} qWddd| D} nd} Wnttfk rYnXn(|dkst|dr$|jr$d} nd} || || |jj|fWdQRXqRWWdttjXt dd|D} t dd|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 |dkrFtdtd+td,t|d-tdt|}t t t |}d t |d}x0|D](}t||||j j%|d.fqWtdn.tdtd+td,t|d/tdWnt&k rYnXWdttjtdXdS)0NrF)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)xrrrr1r2zhelp_solvers..r )r@z %-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)rrrrr1.r2rR+.css|]}t|VqdS)N)rx)r,r0rrrr.@szhelp_solvers..py _metasolverr css|]}t|dVqdS)rN)r )r,rfrrrr.Qscss|]}t|dVqdS)rN)r )r,rfrrrr.Rsz %%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 report having 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,rarrr msz 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>rrAlistoptZSolverManagerFactoryrfilterr5mapr rxrBZ SolverFactoryloggingdisableWARNING availableZlicense_is_validrir%AttributeError NameErrorhasattrrrqNOTSETsocketsetdefaulttimeoutZpyomo.neos.kestrelZneoskestrelZ kestrelAMPLrIsolversrv ImportError)r3rCZsolvermgr_listnsformatZ solver_list_datarverZavailZ nameFieldLenZ verFieldLenr9_linerrarrr 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) rr3corebaseZ_pyomoZmodel_componentsr"miscZ sort_indexr=wrapZpredefined_sets)data componentsindexirfZ 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.)commandsrXrr:rrapirg datamanagerrQrtr{transformationsrrrwritersrEcheckersrN help_parser print_help)r&rdrrr 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 --asciidocrXzBGenerate 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--infortz1Summarize 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.pathrrrYr=rrZpyutilib.subprocessr"Z pyomo.commonr3Zpyomo.common.collectionsrZpyomo.scripting.pyomo_parser getLoggerloggerrr( scriptingZ pyomo_parserZ add_subparserr:rErNrQrgr{rrrrrrrrrr sH       Qt/