knitr::opts_chunk$set( collapse = TRUE, comment = ".", fig.path = "man/figures/README-", out.width = "100%" , message = FALSE )
The package name will probably change with time. For now, experimenting with alternate methods for model specification. I'm trying to leverage existing markup languages (i.e. yaml) to standardize input a bit and make writing the model more powerful and intuitive.
There is a 100% yaml model specification format in the works. For now, trying to refine specification of ODE models as a series of reactions.
# install.packages("devtools") devtools::install_github("kylebaron/mread.yaml")
library(mread.yaml) library(dplyr) library(mrgsolve)
Read some input code
examp <- system.file("examples", "two_cmt_model.cpp", package = "mread.yaml")
We are focusing on this new model specification block:
mod <- modelparse(readLines(examp)) blocks <- mod[c("ODE_ASSIGNMENTS", "REACTIONS")]
In the [ reactions ]
block of this simple model we, write the model in
reaction / arrow notation as a series of fluxes:
The remaining parts of the model specification file look similar to what we usually see: ```{yaml,eval=FALSE, code = readLines(examp)}
mread.yaml provides a function to read and parse this type of model specification file and return a model object just like `mrgsolve::mread()`. ```r mod <- mread_rxn(examp, delta = 0.1, end = 48)
Once the model is loaded, it functions just like you had written it using ODEs
mod
mrgsim(mod, ev(amt = 100)) %>% plot
In fact, all mread_rxn()
does, is parse the reactions and write that math
as ODEs, creating this .cpp
file that gets handled but regular old mread()
```{c, eval=FALSE, code = mod@code}
```
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.