Model code is written to a file in native mrgsolve format. This
can be useful for (1) breaking connection to NONMEM modeling outputs that
are imported by $NMXML
or $NMEXT
and (2) saving model updates (e.g.,
an updated parameter list). Models can be read back using mread()
.
mwrite_cpp(x, file, update = TRUE)
A list containing data that was written out to the cpp file, with added
item file
, is returned invisibly.
See important details in mwrite_yaml()
.
temp <- tempfile(fileext = ".mod")
mod <- modlib("pk1", compile = FALSE)
x <- mwrite_cpp(mod, file = temp)
mod <- mread(x$file, compile = FALSE)
mod
#>
#>
#> ---------- source: file1f03d055eb9d96.mod ----------
#>
#> project: /tmp/RtmpHEsilU
#> shared object: file1f03d055eb9d96.mod-so-1f03d02e7c9ec4 <not loaded>
#>
#> time: start: 0 end: 24 delta: 1
#> add: <none>
#>
#> compartments: EV CENT [2]
#> parameters: CL V KA [3]
#> captures: CP [1]
#> omega: 0x0
#> sigma: 0x0
#>
#> solver: atol: 1e-08 rtol: 1e-08 maxsteps: 20k
#> ------------------------------------------------------