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()
.
Arguments
- x
a model object.
- file
output file name; if non-character (e.g.,
NULL
), no output will be written to file.- update
TRUE
if model settings should be written into the cpp file in a$SET
block.
Value
A list containing data that was written out to the cpp file, with added
item file
, is returned invisibly.
Details
See important details in mwrite_yaml()
.
Examples
temp <- tempfile(fileext = ".mod")
mod <- modlib("pk1", compile = FALSE)
x <- mwrite_cpp(mod, file = temp)
mod <- mread(x$file, compile = FALSE)
mod
#>
#>
#> ----------- source: file502e46d75824.mod -----------
#>
#> project: /private/var/fol.../T/RtmpF53bHU
#> shared object: file502e46d75824.mod-so-502e5167ed16 <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
#> ------------------------------------------------------