Пример #1
0
def scenariotreeserver_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "pyro_host")
    safe_register_common_option(options, "pyro_port")
    safe_register_unique_option(
        options,
        "mpi",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Activate MPI based functionality. "
                "Requires the mpi4py module."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "import_module",
        PySPConfigValue(
            (),
            domain=_domain_tuple_of_str,
            description=(
                "The name of a user-defined python module to import that, "
                "e.g., registers a user-defined scenario tree worker class."
            ),
            doc=None,
            visibility=0))

    return options
Пример #2
0
def runadmm_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    ADMMSolver.register_options(options)
    ScenarioTreeManagerFactory.register_options(options)
    safe_register_common_option(options,
                               "verbose")
    safe_register_common_option(options,
                               "disable_gc")
    safe_register_common_option(options,
                               "profile")
    safe_register_common_option(options,
                               "traceback")
    safe_register_common_option(options,
                                "output_solver_log")
    safe_register_common_option(options,
                               "output_scenario_tree_solution")
    safe_register_unique_option(
        options,
        "default_rho",
        PySPConfigValue(
            1.0,
            domain=_domain_positive,
            description=(
                "The default rho value for all non-anticipative "
                "variables. Default is 1.0."
            ),
            doc=None,
            visibility=0),
        ap_args=("-r", "--default-rho"),
        ap_group=_admm_group_label)

    return options
Пример #3
0
def convertschuripopt_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "symbolic_solver_labels")
    safe_register_unique_option(
        options, "output_directory",
        PySPConfigValue(
            ".",
            domain=_domain_must_be_str,
            description=("The directory in which all SchurIpopt files "
                         "will be stored. Default is '.'."),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options, "ignore_bundles",
        PySPConfigValue(
            False,
            domain=bool,
            description=("Ignore bundles when converting the SP to "
                         "SchurIpopt input files."),
            doc=None,
            visibility=0))
    safe_register_common_option(options, "scenario_tree_manager")
    ScenarioTreeManagerClientSerial.register_options(options)
    ScenarioTreeManagerClientPyro.register_options(options)

    return options
Пример #4
0
def runschuripopt_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "output_scenario_tree_solution")
    safe_register_common_option(options, "output_solver_log")
    safe_register_common_option(options, "keep_solver_files")
    safe_register_common_option(options, "symbolic_solver_labels")
    ScenarioTreeManagerFactory.register_options(options)
    SchurIpoptSolver.register_options(options)
    # used to populate the implicit SchurIpopt options
    safe_register_unique_option(
        options,
        "solver_options",
        PySPConfigValue((),
                        domain=_domain_tuple_of_str_or_dict,
                        description=("Solver options to pass to SchurIpopt "
                                     "(e.g., relax_integrality=yes). This "
                                     "option can be used multiple times "
                                     "from the command line to specify more "
                                     "than one SchurIpopt option."),
                        doc=None,
                        visibility=0),
        ap_kwds={'action': 'append'},
        ap_group=_schuripopt_group_label)

    return options
Пример #5
0
def compile_scenario_tree_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_unique_option(
        options, "output_directory",
        PySPConfigValue(
            ".",
            domain=_domain_must_be_str,
            description=("The directory in which to store all output files. "
                         "Default is '.'."),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options, "compiled_reference_model_filename",
        PySPConfigValue(
            "PySP_CompiledReferenceModel.py",
            domain=_domain_must_be_str,
            description=(
                "The filename to use for the new reference model that uses "
                "the compiled scenarios. This will be prefixed by the "
                "output directory name where compiled scenarios are stored. "
                "Default is 'PySP_CompiledReferenceModel.py'."),
            doc=None,
            visibility=0))
    safe_register_common_option(options, "scenario_tree_manager")
    ScenarioTreeManagerClientSerial.register_options(options)
    ScenarioTreeManagerClientPyro.register_options(options)

    return options
Пример #6
0
def generate_scenario_tree_image_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_unique_option(
        options,
        "output_file",
        PySPConfigValue(
            "ScenarioStructure.pdf",
            domain=_domain_must_be_str,
            description=(
                "The name of the file in which to store the scenario " "tree image. Default is ScenarioStructure.pdf."
            ),
            doc=None,
            visibility=0,
        ),
    )
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "model_location")
    safe_register_common_option(options, "scenario_tree_location")
    safe_register_common_option(options, "scenario_tree_random_seed")
    safe_register_common_option(options, "scenario_tree_downsample_fraction")
    safe_register_common_option(options, "scenario_bundle_specification")
    safe_register_common_option(options, "create_random_bundles")
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    return options
Пример #7
0
def runddsip_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    DDSIPSolver.register_options(options)
    ScenarioTreeManagerFactory.register_options(options)
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "output_scenario_tree_solution")
    safe_register_common_option(options, "keep_solver_files")
    safe_register_common_option(options, "output_solver_log")
    safe_register_common_option(options, "symbolic_solver_labels")
    # used to populate the implicit DDSIP options
    safe_register_unique_option(
        options,
        "solver_options",
        PySPConfigValue(
            (),
            domain=_domain_tuple_of_str_or_dict,
            description=("Unregistered solver options that will be passed "
                         "to DDSIP via the config file (e.g., NODELIM=4, "
                         "CPLEX_1067=1). This option can be used multiple "
                         "times from the command line to specify more "
                         "than one DDSIP option."),
            doc=None,
            visibility=0),
        ap_kwds={'action': 'append'},
        ap_group=_ddsip_group_label)

    return options
Пример #8
0
def runadmm_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    ADMMSolver.register_options(options)
    ScenarioTreeManagerFactory.register_options(options)
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "output_solver_log")
    safe_register_common_option(options, "output_scenario_tree_solution")
    safe_register_unique_option(
        options,
        "default_rho",
        PySPConfigValue(
            1.0,
            domain=_domain_positive,
            description=("The default rho value for all non-anticipative "
                         "variables. Default is 1.0."),
            doc=None,
            visibility=0),
        ap_args=("-r", "--default-rho"),
        ap_group=_admm_group_label)

    return options
Пример #9
0
def scenariotreeserver_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "pyro_host")
    safe_register_common_option(options, "pyro_port")
    safe_register_unique_option(
        options, "mpi",
        PySPConfigValue(False,
                        domain=bool,
                        description=("Activate MPI based functionality. "
                                     "Requires the mpi4py module."),
                        doc=None,
                        visibility=0))
    safe_register_unique_option(
        options, "import_module",
        PySPConfigValue(
            (),
            domain=_domain_tuple_of_str,
            description=(
                "The name of a user-defined python module to import that, "
                "e.g., registers a user-defined scenario tree worker class."),
            doc=None,
            visibility=0))

    return options
Пример #10
0
def run_evaluate_xhat_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options,
                               "disable_gc")
    safe_register_common_option(options,
                               "profile")
    safe_register_common_option(options,
                               "traceback")
    safe_register_common_option(options,
                               "scenario_tree_manager")
    safe_register_common_option(options,
                               "output_scenario_tree_solution")
    safe_register_common_option(options,
                               "solution_saver_extension")
    safe_register_common_option(options,
                               "solution_loader_extension")
    safe_register_unique_option(
        options,
        "disable_solution_loader_check",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Indicates that no solution loader extension is required to "
                "run this script, e.g., because the scenario tree manager "
                "is somehow pre-populated with a solution."
            ),
            doc=None,
            visibility=0),
        ap_group=_extension_options_group_title)
    safe_register_unique_option(
        options,
        "output_scenario_costs",
        PySPConfigValue(
            None,
            domain=_domain_must_be_str,
            description=(
                "A file name where individual scenario costs from the solution "
                "will be stored. The format is determined from the extension used "
                "in the filename. Recognized extensions: [.csv, .json, .yaml]"
            ),
            doc=None,
            visibility=0))
    ScenarioTreeManagerFactory.register_options(options)
    ScenarioTreeManagerSolverFactory.register_options(options,
                                                      options_prefix="subproblem_")

    return options
Пример #11
0
def run_evaluate_xhat_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options,
                               "disable_gc")
    safe_register_common_option(options,
                               "profile")
    safe_register_common_option(options,
                               "traceback")
    safe_register_common_option(options,
                               "scenario_tree_manager")
    safe_register_common_option(options,
                               "output_scenario_tree_solution")
    safe_register_common_option(options,
                               "solution_saver_extension")
    safe_register_common_option(options,
                               "solution_loader_extension")
    safe_register_unique_option(
        options,
        "disable_solution_loader_check",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Indicates that no solution loader extension is required to "
                "run this script, e.g., because the scenario tree manager "
                "is somehow pre-populated with a solution."
            ),
            doc=None,
            visibility=0),
        ap_group=_extension_options_group_title)
    safe_register_unique_option(
        options,
        "output_scenario_costs",
        PySPConfigValue(
            None,
            domain=_domain_must_be_str,
            description=(
                "A file name where individual scenario costs from the solution "
                "will be stored. The format is determined from the extension used "
                "in the filename. Recognized extensions: [.csv, .json, .yaml]"
            ),
            doc=None,
            visibility=0))
    ScenarioTreeManagerSolverClientSerial.register_options(options)
    ScenarioTreeManagerSolverClientPyro.register_options(options)

    return options
Пример #12
0
def runschuripopt_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options,
                               "verbose")
    safe_register_common_option(options,
                               "disable_gc")
    safe_register_common_option(options,
                               "profile")
    safe_register_common_option(options,
                               "traceback")
    safe_register_common_option(options,
                               "output_scenario_tree_solution")
    safe_register_common_option(options,
                                "output_solver_log")
    safe_register_common_option(options,
                                "keep_solver_files")
    safe_register_common_option(options,
                                "symbolic_solver_labels")
    ScenarioTreeManagerFactory.register_options(options)
    SchurIpoptSolver.register_options(options)
    # used to populate the implicit SchurIpopt options
    safe_register_unique_option(
        options,
        "solver_options",
        PySPConfigValue(
            (),
            domain=_domain_tuple_of_str_or_dict,
            description=(
                "Solver options to pass to SchurIpopt "
                "(e.g., relax_integrality=yes). This "
                "option can be used multiple times "
                "from the command line to specify more "
                "than one SchurIpopt option."
            ),
            doc=None,
            visibility=0),
        ap_kwds={'action': 'append'},
        ap_group=_schuripopt_group_label)

    return options
Пример #13
0
def runddsip_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    DDSIPSolver.register_options(options)
    ScenarioTreeManagerFactory.register_options(options)
    safe_register_common_option(options,
                               "verbose")
    safe_register_common_option(options,
                               "disable_gc")
    safe_register_common_option(options,
                               "profile")
    safe_register_common_option(options,
                               "traceback")
    safe_register_common_option(options,
                                "output_scenario_tree_solution")
    safe_register_common_option(options,
                                "keep_solver_files")
    safe_register_common_option(options,
                                "output_solver_log")
    safe_register_common_option(options,
                                "symbolic_solver_labels")
    # used to populate the implicit DDSIP options
    safe_register_unique_option(
        options,
        "solver_options",
        PySPConfigValue(
            (),
            domain=_domain_tuple_of_str_or_dict,
            description=(
                "Unregistered solver options that will be passed "
                "to DDSIP via the config file (e.g., NODELIM=4, "
                "CPLEX_1067=1). This option can be used multiple "
                "times from the command line to specify more "
                "than one DDSIP option."
            ),
            doc=None,
            visibility=0),
        ap_kwds={'action': 'append'},
        ap_group=_ddsip_group_label)

    return options
Пример #14
0
def generate_scenario_tree_image_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_unique_option(
        options, "output_file",
        PySPConfigValue(
            "ScenarioStructure.pdf",
            domain=_domain_must_be_str,
            description=("The name of the file in which to store the scenario "
                         "tree image. Default is ScenarioStructure.pdf."),
            doc=None,
            visibility=0))
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "model_location")
    safe_register_common_option(options, "scenario_tree_location")
    safe_register_common_option(options, "scenario_tree_random_seed")
    safe_register_common_option(options, "scenario_tree_downsample_fraction")
    safe_register_common_option(options, "scenario_bundle_specification")
    safe_register_common_option(options, "create_random_bundles")
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    return options
Пример #15
0
def convertschuripopt_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "symbolic_solver_labels")
    safe_register_unique_option(
        options,
        "output_directory",
        PySPConfigValue(
            ".",
            domain=_domain_must_be_str,
            description=(
                "The directory in which all SchurIpopt files "
                "will be stored. Default is '.'."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "ignore_bundles",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Ignore bundles when converting the SP to "
                "SchurIpopt input files."
            ),
            doc=None,
            visibility=0))
    safe_register_common_option(options, "scenario_tree_manager")
    ScenarioTreeManagerClientSerial.register_options(options)
    ScenarioTreeManagerClientPyro.register_options(options)

    return options
Пример #16
0
def compile_scenario_tree_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_unique_option(
        options,
        "output_directory",
        PySPConfigValue(
            ".",
            domain=_domain_must_be_str,
            description=(
                "The directory in which to store all output files. "
                "Default is '.'."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "compiled_reference_model_filename",
        PySPConfigValue(
            "PySP_CompiledReferenceModel.py",
            domain=_domain_must_be_str,
            description=(
                "The filename to use for the new reference model that uses "
                "the compiled scenarios. This will be prefixed by the "
                "output directory name where compiled scenarios are stored. "
                "Default is 'PySP_CompiledReferenceModel.py'."
            ),
            doc=None,
            visibility=0))
    safe_register_common_option(options, "scenario_tree_manager")
    ScenarioTreeManagerClientSerial.register_options(options)
    ScenarioTreeManagerClientPyro.register_options(options)

    return options
Пример #17
0
def run_generate_distributed_NL_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "scenario_tree_manager")
    safe_register_common_option(options, "symbolic_solver_labels")
    safe_register_unique_option(
        options,
        "output_directory",
        PySPConfigValue(
            ".",
            domain=_domain_must_be_str,
            description=(
                "The directory in which to store all output files. "
                "Default is '.'."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "linking_suffix_name",
        PySPConfigValue(
            "variable_id",
            domain=_domain_must_be_str,
            description=(
                "The suffix name used to identify common variables "
                "across NL files. Default is 'ipopt_blend_id'."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "objective_suffix_name",
        PySPConfigValue(
            "objective_weight",
            domain=_domain_must_be_str,
            description=(
                "The suffix name used to identify the relative "
                "objective weight for each NL-file subproblem."
                "Default is 'ipopt_blend_weight'."
            ),
            doc=None,
            visibility=0))
    ScenarioTreeManagerClientSerial.register_options(options)
    ScenarioTreeManagerClientPyro.register_options(options)

    return options
Пример #18
0
Файл: ef.py Проект: Pyomo/pyomo
def runef_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    EFSolver.register_options(options)
    ScenarioTreeManagerClientSerial.register_options(options)
    safe_register_common_option(options,
                                "verbose")
    safe_register_common_option(options,
                                "disable_gc")
    safe_register_common_option(options,
                                "profile")
    safe_register_common_option(options,
                                "traceback")
    safe_register_common_option(options,
                                "symbolic_solver_labels")
    safe_register_common_option(options,
                                "output_solver_log")
    safe_register_common_option(options,
                                "keep_solver_files")
    safe_register_common_option(options,
                                "output_scenario_tree_solution")
    safe_register_common_option(options,
                                "solution_saver_extension")
    safe_register_common_option(options,
                                "solution_loader_extension")
    safe_register_unique_option(
        options,
        "solution_writer",
        PySPConfigValue(
            (),
            domain=_domain_tuple_of_str,
            description=(
                "The name of a python module specifying a user-defined "
                "plugin implementing the ISolutionWriterExtension "
                "interface. Invoked to save a scenario tree solution. Use "
                "this option when generating a template configuration file "
                "or invoking command-line help in order to include any "
                "plugin-specific options. This option can used multiple "
                "times from the command line to specify more than one "
                "plugin."
            ),
            doc=None,
            visibility=0),
        ap_kwds={'action': 'append'},
        ap_group=_extension_options_group_title)
    safe_register_unique_option(
        options,
        "output_file",
        PySPConfigValue(
            None,
            domain=_domain_must_be_str,
            description=(
                "The name of the extensive form output file "
                "(currently LP, MPS, and NL file formats are "
                "supported). If the option value does not end "
                "in '.lp', '.mps', or '.nl', then the output format "
                "will be inferred from the settings for the chosen "
                "solver interface, and the appropriate suffix "
                "will be appended to the name. Use of this option "
                "will disable the solve."
            ),
            doc=None,
            visibility=0),
        ap_group=_output_options_group_title)
    safe_register_unique_option(
        options,
        "output_scenario_costs",
        PySPConfigValue(
            None,
            domain=_domain_must_be_str,
            description=(
                "A file name where individual scenario costs from the "
                "solution will be stored. The format is determined "
                "from the extension used in the filename. Recognized "
                "extensions: [.csv, .json, .yaml]"
            ),
            doc=None,
            visibility=0))

    #
    # Deprecated
    #

    class _DeprecatedActivateJSONIOSolutionSaver(
            pyutilib.misc.config.argparse.Action):
        def __init__(self, option_strings, dest, nargs=None, **kwargs):
            if nargs is not None:
                raise ValueError("nargs not allowed")
            super(_DeprecatedActivateJSONIOSolutionSaver, self).\
                __init__(option_strings, dest, nargs=0, **kwargs)
        def __call__(self, parser, namespace, values, option_string=None):
            logger.warning(
                "DEPRECATED: The '--activate-json-io-solution-saver "
                "command-line option has been deprecated and will "
                "be removed in the future. Please the following instead: "
                "'----solution-saver-extension=pyomo.pysp.plugins.jsonio'")
            val = getattr(namespace,
                          'CONFIGBLOCK.solution_saver_extension', [])
            setattr(namespace,
                    'CONFIGBLOCK.solution_saver_extension',
                    val + ["pyomo.pysp.plugins.jsonio"])

    def _warn_activate_jsonio_solution_saver(val):
        # don't use logger here since users might not import
        # the pyomo logger in a scripting interface
        sys.stderr.write(
            "\tWARNING: The 'activate_jsonio_solution_saver' "
            "config item will be ignored "
            "unless it is being used as a command-line option "
            "where it can be redirected to 'solution_saver_extension'. "
            "Please use 'solution_saver_extension=pyomo.pysp.plugins.jsonio' "
            "instead.\n")
        return _domain_tuple_of_str(val)

    safe_declare_unique_option(
        options,
        "activate_jsonio_solution_saver",
        PySPConfigValue(
            None,
            domain=_warn_activate_jsonio_solution_saver,
            description=(
                "Deprecated alias for "
                "--solution-saver-extension=pyomo.pysp.plugins.jsonio"
            ),
            doc=None,
            visibility=1),
        ap_kwds={'action':_DeprecatedActivateJSONIOSolutionSaver},
        ap_group=_deprecated_options_group_title,
        declare_for_argparse=True)

    return options
Пример #19
0
def convertddsip_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "symbolic_solver_labels")
    safe_register_unique_option(
        options, "output_directory",
        PySPConfigValue(".",
                        domain=_domain_must_be_str,
                        description=("The directory in which all DDSIP files "
                                     "will be stored. Default is '.'."),
                        doc=None,
                        visibility=0))
    safe_register_unique_option(
        options, "first_stage_suffix",
        PySPConfigValue(
            "__DDSIP_FIRSTSTAGE",
            domain=_domain_must_be_str,
            description=("The suffix used to identify first-stage variables. "
                         "Default: '__DDSIP_FIRSTSTAGE'"),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options, "enforce_derived_nonanticipativity",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Adds nonanticipativity constraints for variables flagged "
                "as derived within their respective time stage (except for "
                "the final time stage). The default behavior behavior is "
                "to treat derived variables as belonging to the final "
                "time stage."),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options, "disable_consistency_checks",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Disables consistency checks that attempt to find issues "
                "with the DDSIP conversion. By default, these checks are run "
                "after conversion takes place and leave behind a temporary "
                "directory with per-scenario output files if the checks fail. "
                "This option is not recommended, but can be used if the "
                "consistency checks are prohibitively slow."),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options, "keep_scenario_files",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Keeps around the per-scenario DDSIP files created for testing "
                "whether a conversion is valid (whether or not the validation "
                "checks are performed). These files can be useful for "
                "debugging purposes."),
            doc=None,
            visibility=0))
    safe_register_common_option(options, "scenario_tree_manager")
    ScenarioTreeManagerClientSerial.register_options(options)
    ScenarioTreeManagerClientPyro.register_options(options)

    return options
Пример #20
0
def pysp2smps_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "symbolic_solver_labels")
    safe_register_common_option(options, "file_determinism")
    safe_register_unique_option(
        options,
        "explicit",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Generate SMPS files using explicit scenarios "
                "(or bundles). ** This option is deprecated. It is "
                "the default behavior. ** "
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "core_format",
        PySPConfigValue(
            "mps",
            domain=_domain_must_be_str,
            description=(
                "The format used to generate the core SMPS problem file. "
                "Choices are: [mps, lp]. The default format is MPS."
            ),
            doc=None,
            visibility=0),
        ap_kwds={'choices': ['mps','lp']})
    safe_register_unique_option(
        options,
        "output_directory",
        PySPConfigValue(
            ".",
            domain=_domain_must_be_str,
            description=(
                "The directory in which all SMPS related output files "
                "will be stored. Default is '.'."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "basename",
        PySPConfigValue(
            None,
            domain=_domain_must_be_str,
            description=(
                "The basename to use for all SMPS related output "
                "files. ** Required **"
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "disable_consistency_checks",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Disables consistency checks that attempt to find issues "
                "with the SMPS conversion. By default, these checks are run "
                "after conversion takes place and leave behind a temporary "
                "directory with per-scenario output files if the checks fail. "
                "This option is not recommended, but can be used if the "
                "consistency checks are prohibitively slow."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "keep_scenario_files",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Keeps around the per-scenario SMPS files created for testing "
                "whether a conversion is valid (whether or not the validation "
                "checks are performed). These files can be useful for "
                "debugging purposes."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "keep_auxiliary_files",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Keep auxiliary files for the template scenario that are normally "
                "used for testing the validity of the SMPS conversion. "
                "These include the .row, .col, .sto.struct, and .[mps,lp].det files."
            ),
            doc=None,
            visibility=0))
    safe_register_common_option(options, "scenario_tree_manager")
    ScenarioTreeManagerClientSerial.register_options(options)
    ScenarioTreeManagerClientPyro.register_options(options)

    return options
Пример #21
0
def runef_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    EFSolver.register_options(options)
    ScenarioTreeManagerClientSerial.register_options(options)
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "symbolic_solver_labels")
    safe_register_common_option(options, "output_solver_log")
    safe_register_common_option(options, "keep_solver_files")
    safe_register_common_option(options, "output_scenario_tree_solution")
    safe_register_common_option(options, "solution_saver_extension")
    safe_register_common_option(options, "solution_loader_extension")
    safe_register_unique_option(
        options,
        "solution_writer",
        PySPConfigValue(
            (),
            domain=_domain_tuple_of_str,
            description=(
                "The name of a python module specifying a user-defined "
                "plugin implementing the ISolutionWriterExtension "
                "interface. Invoked to save a scenario tree solution. Use "
                "this option when generating a template configuration file "
                "or invoking command-line help in order to include any "
                "plugin-specific options. This option can used multiple "
                "times from the command line to specify more than one "
                "plugin."),
            doc=None,
            visibility=0),
        ap_kwds={'action': 'append'},
        ap_group=_extension_options_group_title)
    safe_register_unique_option(
        options,
        "output_file",
        PySPConfigValue(
            None,
            domain=_domain_must_be_str,
            description=("The name of the extensive form output file "
                         "(currently LP, MPS, and NL file formats are "
                         "supported). If the option value does not end "
                         "in '.lp', '.mps', or '.nl', then the output format "
                         "will be inferred from the settings for the chosen "
                         "solver interface, and the appropriate suffix "
                         "will be appended to the name. Use of this option "
                         "will disable the solve."),
            doc=None,
            visibility=0),
        ap_group=_output_options_group_title)
    safe_register_unique_option(
        options, "output_scenario_costs",
        PySPConfigValue(
            None,
            domain=_domain_must_be_str,
            description=(
                "A file name where individual scenario costs from the "
                "solution will be stored. The format is determined "
                "from the extension used in the filename. Recognized "
                "extensions: [.csv, .json, .yaml]"),
            doc=None,
            visibility=0))

    #
    # Deprecated
    #

    class _DeprecatedActivateJSONIOSolutionSaver(
            pyutilib.misc.config.argparse.Action):
        def __init__(self, option_strings, dest, nargs=None, **kwargs):
            if nargs is not None:
                raise ValueError("nargs not allowed")
            super(_DeprecatedActivateJSONIOSolutionSaver, self).\
                __init__(option_strings, dest, nargs=0, **kwargs)

        def __call__(self, parser, namespace, values, option_string=None):
            logger.warning(
                "DEPRECATED: The '--activate-json-io-solution-saver "
                "command-line option has been deprecated and will "
                "be removed in the future. Please the following instead: "
                "'----solution-saver-extension=pyomo.pysp.plugins.jsonio'")
            val = getattr(namespace, 'CONFIGBLOCK.solution_saver_extension',
                          [])
            setattr(namespace, 'CONFIGBLOCK.solution_saver_extension',
                    val + ["pyomo.pysp.plugins.jsonio"])

    def _warn_activate_jsonio_solution_saver(val):
        # don't use logger here since users might not import
        # the pyomo logger in a scripting interface
        sys.stderr.write(
            "\tWARNING: The 'activate_jsonio_solution_saver' "
            "config item will be ignored "
            "unless it is being used as a command-line option "
            "where it can be redirected to 'solution_saver_extension'. "
            "Please use 'solution_saver_extension=pyomo.pysp.plugins.jsonio' "
            "instead.\n")
        return _domain_tuple_of_str(val)

    safe_declare_unique_option(
        options,
        "activate_jsonio_solution_saver",
        PySPConfigValue(
            None,
            domain=_warn_activate_jsonio_solution_saver,
            description=(
                "Deprecated alias for "
                "--solution-saver-extension=pyomo.pysp.plugins.jsonio"),
            doc=None,
            visibility=1),
        ap_kwds={'action': _DeprecatedActivateJSONIOSolutionSaver},
        ap_group=_deprecated_options_group_title,
        declare_for_argparse=True)

    return options
Пример #22
0
    def _declare_options(cls, options=None):
        if options is None:
            options = PySPConfigBlock()
        safe_register_unique_option(
            options,
            "sd_executable",
            PySPConfigValue(
                "sd",
                domain=_domain_must_be_str,
                description=(
                    "Name of the executable used when launching the "
                    "SD solver. By default, the name 'sd' will be used."),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "stopping_rule_tolerance",
            PySPConfigValue(
                "nominal",
                domain=_domain_sd_tolerance,
                description=("Stopping rule tolerance used by the SD solver. "
                             "Must be one of: %s. Default is 'nominal'." %
                             (str(_domain_sd_tolerance._values))),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "single_replication",
            PySPConfigValue(
                False,
                domain=bool,
                description=("Disables multiple replication procedure in "
                             "SD and uses a single replication."),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "print_cycle",
            PySPConfigValue(
                100,
                domain=_domain_positive_integer,
                description=("Number of iterations between output of "
                             "solution data to screen and file."),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "eval_run_flag",
            PySPConfigValue(
                False,
                domain=bool,
                description=(
                    "Set to evaluate on the run. This should be "
                    "only used for instances with relatively complete "
                    "recourse. This flag is not recommended because "
                    "accurate function evaluations are unnecessarily "
                    "time consuming. It is best to use a large print "
                    "cycle when this option is activated."),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "eval_flag",
            PySPConfigValue(
                False,
                domain=bool,
                description=(
                    "Set to get an estimated objective function value "
                    "for the final incumbent of each replication."),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "eval_seed1",
            PySPConfigValue(
                2668655841019641,
                domain=int,
                description=(
                    "Random number seed for re-sampling omegas during "
                    "optimality test. Default is None, meaning no "
                    "seed will be provided."),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "eval_error",
            PySPConfigValue(
                0.01,
                domain=_domain_positive,
                description=(
                    "Objective evaluation is accurate to within "
                    "this much, with 95%% confidence. Default is 0.01."),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "mean_dev",
            PySPConfigValue(
                0.05,
                domain=_domain_positive,
                description=("Solution tolerance for deciding the usage of "
                             "mean solution. Default is 0.05."),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "min_iterations",
            PySPConfigValue(
                None,
                domain=_domain_nonnegative_integer,
                description=("Number of iterations which must pass before "
                             "optimality is checked. Default is None, meaning "
                             "no minimum is given."),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "max_iterations",
            PySPConfigValue(
                5000,
                domain=_domain_positive_integer,
                description=("Maximum number of iterations for any given "
                             "problem. Default is 5000."),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)

        return options
Пример #23
0
    def _declare_options(cls, options=None):
        if options is None:
            options = PySPConfigBlock()
        safe_register_unique_option(
            options,
            "sd_executable",
            PySPConfigValue(
                "sd",
                domain=_domain_must_be_str,
                description=(
                    "Name of the executable used when launching the "
                    "SD solver. By default, the name 'sd' will be used."
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "stopping_rule_tolerance",
            PySPConfigValue(
                "nominal",
                domain=_domain_sd_tolerance,
                description=(
                    "Stopping rule tolerance used by the SD solver. "
                    "Must be one of: %s. Default is 'nominal'."
                    % (str(_domain_sd_tolerance._values))
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "single_replication",
            PySPConfigValue(
                False,
                domain=bool,
                description=(
                    "Disables multiple replication procedure in "
                    "SD and uses a single replication."
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "print_cycle",
            PySPConfigValue(
                100,
                domain=_domain_positive_integer,
                description=(
                    "Number of iterations between output of "
                    "solution data to screen and file."
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "eval_run_flag",
            PySPConfigValue(
                False,
                domain=bool,
                description=(
                    "Set to evaluate on the run. This should be "
                    "only used for instances with relatively complete "
                    "recourse. This flag is not recommended because "
                    "accurate function evaluations are unnecessarily "
                    "time consuming. It is best to use a large print "
                    "cycle when this option is activated."
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "eval_flag",
            PySPConfigValue(
                False,
                domain=bool,
                description=(
                    "Set to get an estimated objective function value "
                    "for the final incumbent of each replication."
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "eval_seed1",
            PySPConfigValue(
                2668655841019641,
                domain=int,
                description=(
                    "Random number seed for re-sampling omegas during "
                    "optimality test. Default is None, meaning no "
                    "seed will be provided."
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "eval_error",
            PySPConfigValue(
                0.01,
                domain=_domain_positive,
                description=(
                    "Objective evaluation is accurate to within "
                    "this much, with 95%% confidence. Default is 0.01."
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "mean_dev",
            PySPConfigValue(
                0.05,
                domain=_domain_positive,
                description=(
                    "Solution tolerance for deciding the usage of "
                    "mean solution. Default is 0.05."
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "min_iterations",
            PySPConfigValue(
                None,
                domain=_domain_nonnegative_integer,
                description=(
                    "Number of iterations which must pass before "
                    "optimality is checked. Default is None, meaning "
                    "no minimum is given."
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)
        safe_register_unique_option(
            options,
            "max_iterations",
            PySPConfigValue(
                5000,
                domain=_domain_positive_integer,
                description=(
                    "Maximum number of iterations for any given "
                    "problem. Default is 5000."
                ),
                doc=None,
                visibility=0),
            ap_group=_sd_group_label)

        return options
Пример #24
0
def convertddsip_register_options(options=None):
    if options is None:
        options = PySPConfigBlock()
    safe_register_common_option(options, "disable_gc")
    safe_register_common_option(options, "profile")
    safe_register_common_option(options, "traceback")
    safe_register_common_option(options, "verbose")
    safe_register_common_option(options, "symbolic_solver_labels")
    safe_register_unique_option(
        options,
        "output_directory",
        PySPConfigValue(
            ".",
            domain=_domain_must_be_str,
            description=(
                "The directory in which all DDSIP files "
                "will be stored. Default is '.'."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "first_stage_suffix",
        PySPConfigValue(
            "__DDSIP_FIRSTSTAGE",
            domain=_domain_must_be_str,
            description=(
                "The suffix used to identify first-stage variables. "
                "Default: '__DDSIP_FIRSTSTAGE'"
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "enforce_derived_nonanticipativity",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Adds nonanticipativity constraints for variables flagged "
                "as derived within their respective time stage (except for "
                "the final time stage). The default behavior behavior is "
                "to treat derived variables as belonging to the final "
                "time stage."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "disable_consistency_checks",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Disables consistency checks that attempt to find issues "
                "with the DDSIP conversion. By default, these checks are run "
                "after conversion takes place and leave behind a temporary "
                "directory with per-scenario output files if the checks fail. "
                "This option is not recommended, but can be used if the "
                "consistency checks are prohibitively slow."
            ),
            doc=None,
            visibility=0))
    safe_register_unique_option(
        options,
        "keep_scenario_files",
        PySPConfigValue(
            False,
            domain=bool,
            description=(
                "Keeps around the per-scenario DDSIP files created for testing "
                "whether a conversion is valid (whether or not the validation "
                "checks are performed). These files can be useful for "
                "debugging purposes."
            ),
            doc=None,
            visibility=0))
    safe_register_common_option(options, "scenario_tree_manager")
    ScenarioTreeManagerClientSerial.register_options(options)
    ScenarioTreeManagerClientPyro.register_options(options)

    return options