Executes the generated solve.py script inside solvers/pyomo/ after
ensuring a Python environment exists. By default the helper
setup_python_environment() is invoked so that a Conda environment named
"multimod" (configurable) is created, populated with Pyomo, and activated via
the reticulate toolkit. Once the environment is ready the solver script is
executed with system2() or processx and basic status information is
returned. Result loading is not implemented yet but the metadata emitted by
solve.py (e.g. solution/status.json) is surfaced when available.
Usage
solve_pyomo(
model = NULL,
model_dir,
solver_dir = "pyomo",
env_name = "multimod",
ensure_env = TRUE,
packages = c("pyomo"),
python_version = NULL,
ensure_miniconda = TRUE,
reinstall_env = FALSE,
python = NULL,
solver = NULL,
env = NULL,
load_results = FALSE,
verbose = c("buffer", "stream", "quiet"),
timeout = NULL,
...
)Arguments
- model
Optional multimod model; currently only used when
load_results = TRUEto indicate where solutions should be loaded (not yet implemented).- model_dir
Path to the saved model directory created by
save_model(). Must containsolvers/<solver_dir>/solve.py(generated viawrite_pyomo()).- solver_dir
Name of the solver sub-directory inside
model_dir/solvers. Defaults to "pyomo" to matchwrite_pyomo().- env_name
Name of the Conda environment handled by
setup_python_environment(). Defaults to "multimod".- ensure_env
Logical; when
TRUE(default) the helpersetup_python_environment()runs to create/activate the environment. Set toFALSEif you want to manage activation yourself.- packages
Character vector of Python packages to request when the helper runs. Defaults to
"pyomo".- python_version
Optional Python version passed through to
setup_python_environment().- ensure_miniconda
Forwarded to
setup_python_environment().- reinstall_env
When
TRUE, asks the helper to recreate the Conda environment before solving.- python
Optional path to a Python executable. When omitted the Python binary reported by
reticulate::py_config()for the activated environment is used.- solver
Optional solver name that is exported to the Python process via the
PYOMO_SOLVERenvironment variable.- env
Named character vector of additional environment variables to pass to the Python process.
- load_results
Logical; reserved for future work. When
TRUEa warning is issued because loading solutions back into R is not yet implemented.- verbose
Controls solver logging capture. Logical (
TRUE= buffer output,FALSE= quiet) or one of"buffer","stream","quiet".- timeout
Optional timeout (in seconds). Requires the
processxpackage.- ...
Additional arguments forwarded to
setup_python_environment().
