Runs `glpsol` as a separate process with the given command-line arguments. A crash or a runaway solve cannot take down the R session, and `timeout` stops it on every platform.
glpsol_run(args = "--help", wd = NULL, timeout = 0, echo = TRUE)Character vector of command-line arguments, as for the `glpsol` CLI, e.g. `c("-m", "model.mod", "-d", "model.dat", "-o", "model.sol")`. Each element is quoted for the shell, so file names may contain spaces.
Working directory for the run; relative paths in `args` are resolved against it. `NULL` uses the current directory.
Time limit in seconds for the process; `0` means no limit. Unlike `–tmlim`, this also covers model translation and output writing.
If `TRUE`, the solver log is printed to the console as it runs. If `FALSE`, it is captured and returned in `log`.
Invisibly, a list with * `status`: exit status, `0` on success, * `timed_out`: `TRUE` if `timeout` was reached, * `log`: captured output lines (`character(0)` when `echo = TRUE`).
[glpsol_path()]
mod <- system.file("models", "transp.mod", package = "glpsol")
res <- glpsol_run(c("-m", mod), echo = FALSE)
res$status
#> [1] 0
tail(res$log, 3)
#> [1] "OPTIMAL LP SOLUTION FOUND" "Time used: 0.0 secs"
#> [3] "Memory used: 0.1 Mb (126664 bytes)"