B _6A@sddlZddlZddlmZmZddlmZddlmZddl Z ddl m Z ddZ dd Zd d Zd d ZddZedfddZdddZdS)N)Options Container) pyomo_command)pympler_available) ConcreteModelcCst|d}|jdddddgd|jdd dd gd|jd d d dddd|jddddgd|jddd ddd|jdddddd|jddd tddd |jd!d"d#dd$gd|S)%Nz Model Optionsz --preprocessz--loadzSpecify a Python module that gets immediately executed (before the optimization model is setup). If this option is specified multiple times, then the modules are executed in the specified order.append preprocess)helpactiondestdefaultz --transformzQSpecify a list of transformations that are applied before the model is optimized.Ztransformationsz --model-namezJThe name of the model object that is created in the specified.Pyomo modulestoreNAMEZ model_name)r r metavarr r z--model-optionszEOptions passed into a create_model() function to construct the model.Z model_optionsz --save-modelzSpecify the filename to which the model is saved. The suffix of this filename specifies the file format. If debugging is on, then this defaults to writing the file 'unknown.lp'.Z save_modelz--symbolic-solver-labelsahWhen interfacing with the solver, use symbol names derived from the model. For example, "my_special_variable[1_2_3]" instead of "v1". Useful for debugging. When using the ASL interface (--solver-io=nl), generates corresponding .row (constraints) and .col (variables) files. The ordering in these files provides a mapping from ASL index to symbolic model names. store_trueZsymbolic_solver_labelsFz--file-determinismaRWhen interfacing with a solver using file based I/O, set the effort level for ensuring the file creation process is determistic. The default (1) sorts the index of components when transforming the model. Anything less than 1 disables index sorting. Anything greater than 1 additionaly sorts by component name to override declartion order.Zfile_determinism)r r typer r z--nsz --namespacezSpecify a namespace that is used to select data in Pyomo data files. If this is specified multiple times then the union of the data in these namespaces is used to create the model instance. namespaces)IOErroradd_argument_group add_argumentint)parsergrouprA/tmp/pip-unpacked-wheel-d4p3hk07/pyomo/scripting/pyomo_command.pyadd_model_groupsZ rcCs||d}|jddddddd|jd d d dd dd|jd dddddd|jddddddd|jddddddd|S)NzLogging Optionsz-qz--quietz?Disable all log messages except for those that refer to errors.rquietF)r r r r z-wz --warningzFEnable warning log messages for pyomo and pyutilib [default behavior].warningz-iz--infoz7Enable informative log messages for pyomo and pyutilib.infoz-vz --verbosezIndicate that debugging log messages should be printed. This option can be specified multiple times to add log messages for other parts of pyomo and pyutilib.countverboserz-dz--debugzThis option indicates that debugging is performed. This implies the verbose flag, but it also allows exceptions to trigger a failure in which the program stack is printed.debug)rr)rrrrradd_logging_groupOs6 r#cCsd}|d}|jd|dddd|jdd dd dd|jd d dd dd|jdddddd|jddddddd|jddddgd|jddddgd|jdddd td!d|jd"d#d$d%d&d'd|S)(NzThis option specifies the type of solver that is used to optimize the Pyomo model instance. Run the 'pyomo help --solvers' command to get detailed information concerning how solvers are executed.zSolver Optionsz--solverr ZsolverZglpk)r r r r z --solver-iozThe type of IO used to execute the solver. Different solvers support different types of IO, but the following are common options: lp - generate LP files, nl - generate NL files, python - direct Python interface, os - generate OSiL XML files.Z solver_ioz--solver-managerz?Specify the technique that is used to manage solver executions.Z smanager_typeserialz--solver-manager-pyro-hostz=The hostname to bind on when searching for a Pyro nameserver.Z pyro_hostz--solver-manager-pyro-portz9The port to bind on when searching for a Pyro nameserver.Z pyro_portr)r r r rr z--solver-optionszOptions passed into the solver.rZsolver_optionsz--solver-suffixesaOne or more solution suffixes to be extracted by the solver (e.g., rc, dual, or slack). Multiple options are specified by supplying the keyword options multiple times. The use of this option is not required when a suffix has been declared on the model using Pyomo's Suffix component.Zsolver_suffixesz --timelimitz6Limit to the number of seconds that the solver is run.Z timelimitrz--stream-solverz--stream-outputzLStream the solver output to provide information about the solver's progress.rteeF)rrr)rZ solver_helprrrradd_solver_groupssd r&cCs|d}|jddddgd|jddd d d d d|jd ddddd|jddd dd d|jddd dd d|jdddd dd d|S)NzPost-Solve Optionsz --postprocesszSpecify a Python module that gets executed after optimization. If this option is specified multiple times, then the modules are executed in the specified order.r postprocess)r r r r z-lz--logz7Print the solver logfile after performing optimization.rlogFz--save-resultsz4Specify the filename to which the results are saved.r Z save_resultsz--show-resultsz,Print the results object after optimization.Z show_resultsz--jsonzVPrint results in JSON format. The default is YAML, if the PyYAML utility is availablejsonz-sz --summaryz;Summarize the final solution after performing optimization.summary)rr)rrrrradd_postsolve_groups@ r+cCs|d}|jdddddd|jddd d d d d|jd dd dd d|jddd dd d|jdddd dd d|jdddddd|jddddtddtr|jd d!dd"tdd|jd#d$d d%d d|jd&d'dd(dd|jd)d*d d+d d|S),NzMiscellaneous Optionsz--outputz&Redirect output to the specified file.r output)r r r r z-cz--catch-errorszYThis option allows exceptions to trigger a failure in which the program stack is printed.rZcatchFz --disable-gczDisable the garbage collecter.Z disable_gcz --interactiveztAfter executing Pyomo, launch an interactive Python shell. If IPython is installed, this shell is an IPython shell. interactivez-kz --keepfileszKeep temporary files.Z keepfilesz--pathz8Give a path that is used to find the Pyomo python files.path.z --profilezjEnable profiling of Python code. The value of this option is the number of functions that are summarized.Zprofiler)r r r rr z--profile-memoryaIf Pympler is available, report memory usage statistics for the generated instance and any associated processing steps. A value of 0 indicates disabled. A value of 1 forces the print of the total memory after major stages of the pyomo script. A value of 2 forces summary memory statistics after major stages of the pyomo script. A value of 3 forces detailed memory statistics during instance creation and various steps of preprocessing. Values equal to 4 and higher currently provide no additional information. Higher values automatically enable all functionality associated with lower values, e.g., 3 turns on detailed and summary statistics.Zprofile_memoryz--report-timingzQReport various timing statistics during model construction. Defaults to disabled.Z report_timingz --tempdirz:Specify the directory where temporary files are generated.tempdirz --versionz#Display main Pyomo version and exitversion)rrrr)rrrrradd_misc_groupsx r2c Cst|d}|jjdkr$|tSy$tjj|tjjj ||dWn&tjjj |t dddYn&X|j rtjjj |t dddtSytjj|}Wn&tjjj |t dddYnFX|jjdks|jjs|jjrtjjj ||j|jddt|jdSyLtjjj||jd}tjjj||j|j|jdtjjj||j|jdWn&tjjj |t dddYn4Xtjjj ||j|j|jdt||j|j|jd SdS) N)options)r)modelinstanceresultsr")r6)r6r7opt)r6r7)r3r6r7local)rr5filename print_helprpyomo scriptingutilZsetup_environmentZapply_preprocessingfinalizererrorZ ConcretModelZ create_modelZruntimeloggingZ save_fileZ only_instancer6Zapply_optimizerZprocess_resultsr7r8Zapply_postprocessingr9)r3rdataZ model_dataZopt_datarrr run_pyomosx                   rCcCs,ddlm}|dkr|S|dg|SdS)Nr)mainZsolve)Zpyomo.scripting.pyomo_mainrD)argsrDrrrrunvs rF)N)sysargparseZ pyutilib.miscrrZ pyomo.commonrZpyomo.common.dependenciesrZpyomo.scripting.utilr<Z pyomo.corerrr#r&r+r2rCrFrrrr s   :$>&B]