Emits the model in the backend's own language – a GAMS, MathProg, Pyomo or
JuMP script with its data files, or an MPS matrix for lang = "mm" – and
does not solve it. This is the WRITE stage of interpolate -> write -> solve
-> read; write() is its short form.
Details
The destination is the scenario's own run directory, named with
run = "<label>", or an external directory with solver.dir. A run written
into the scenario is recorded with status: "written", so scenario_runs()
lists it and solve_scenario() runs it later without writing it again –
provided the problem has not changed since.
The parameter data is read through get_data_slot() by each backend's
writer, so an on-disk scenario (interpolate_model(ondisk = TRUE)) is
written from its store and the result does not depend on the storage mode.
See also
write(), the short form; solve_scenario() to run it;
read_solution() to read the solution back.
Other write scenario:
write()
Other solving:
read_solution(),
solve_by_region(),
solve_by_sample(),
solve_guided(),
solve_model(),
solve_recursive(),
with_solver_log()
Examples
if (FALSE) { # \dontrun{
open_project(tempdir())
topia_elc <- topia$modules$electricity
mod <- newModel("TOPIA", data = topia_elc$repo,
calendar = topia$modules$calendars$d365_h24_1dps,
region = topia_elc$regions,
horizon = topia$modules$horizons$BY2025_50_by10,
discount = 0.05)
mod <- setGeoscale(mod, topia_elc$geoscale)
scen_BASE <- interpolate_model(mod, name = "BASE")
# write the backend's model and data files without solving, to read them
# or to run the solver by hand
scen_BASE <- write_model(scen_BASE, solver = solver_options$glpk,
run = "glpk")
# ... solve it elsewhere, then read it back and keep it
scen_BASE <- read_solution(scen_BASE, run = "glpk", save = TRUE)
} # }
