Opening this PR to address some additional issues discovered when scrutinizing #1190
Add mwrite_cpp()
We can write to yaml and then convert to cpp; adding function to write straight to cpp; I'd like to keep both, but essential functionality probably could be handled just by writing to native mrgsolve (cpp) format
Adds unique names to OMEGA and SIGMA objects
Needed to avoid yaml parsing errors for duplicate map key
Yaml code is more verbose, but also easier to read
Rather than a single numeric vector, matrices are rendered as a list of numeric vectors for each row
In mrgsolve cpp format, still render matrices as a vector of numbers, but insert some tags to help readability
reprex
library(mrgsolve)
#>
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#>
#> filter
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
mod <- modlib("popex")
#> Building popex ...
#> done.
Write to yaml
a <- mwrite_yaml(mod, "popex-2.yaml")
yam <- readLines("popex-2.yaml")
Opening this PR to address some additional issues discovered when scrutinizing #1190
mwrite_cpp()
reprex
Write to yaml
omega rendered like this
Now, write to native mrgsolve format
Simulate from this
Convert a matrix to something for writing out
Created on 2024-07-20 with reprex v2.1.1